From b2627ed4f8b338b0f25f56d848d0f10ee7796dea Mon Sep 17 00:00:00 2001 From: Anton Grigorev Date: Fri, 19 Apr 2019 18:27:25 +0300 Subject: [PATCH 1/2] Update Usage.md --- Documentation/Usage.md | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/Documentation/Usage.md b/Documentation/Usage.md index cde3cb161..64a8f3789 100755 --- a/Documentation/Usage.md +++ b/Documentation/Usage.md @@ -41,6 +41,11 @@ - [Get new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-new-pending-transactions) - [Create a new subscription over particular events](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-a-new-subscription-over-particular-events) - [Subscribe on new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#subscribe-on-new-pending-transactions) +- **[ENS](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ens)** + - [Registry](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#registry) + - [Resolver](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#resolver) + - [BaseRegistrar](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#baseregistrar) + - [RegistrarController](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#registrarcontroller) ## Introduction @@ -432,3 +437,66 @@ try! socketProvider.subscribe(params: <[Encodable]>) try! socketProvider.subscribeOnNewPendingTransactions() ``` +## ENS + +You need ENS instance for future actions: +```swift +let web = web3(provider: InfuraProvider(Networks.Mainnet)!) +let ens = ENS(web3: web)! +``` + +### Registry + +You can get/set owner, resolver, ttl via ENS property registry: +```swift +let owner = try! ens.registry.getOwner(node: node) +let resultSettingOwner = try! ens.registry.setOwner(node: node, owner: owner, options: options, password: password) +... +``` + +### Resolver + +You use convenient resolver methods from ENS instance: +```swift +let address = try! ens.getAddress(forNode: node) +let name = try! ens.getName(forNode: node) +let content = try! ens.getContent(forNode: node) +let abi = try! ens.getABI(forNode: node) +let pubkey = try! ens.getPublicKey(forNode: node) +let text = try! ens.getText(forNode: node, key: key) + +let result = try! ens.setAddress(forNode: node, address: address, options: options, password: password) +let result = try! ens.setName(forNode: node, name: name, options: options, password: password) +let result = try! ens.setContent(forNode: node, hash: hash, options: options, password: password) +let result = try! ens.setABI(forNode: node, contentType: .JSON, data: data, options: options, password: password) +let result = try! ens.setPublicKey(forNode: node, publicKey: publicKey, options: options, password: password) +let result = try! ens.setText(forNode: node, key: key, value: value, options: options, password: password) +``` +or you can get resolver to use its methods directly: +```swift +let resolver = try! ens.registry.getResolver(forDomain: domain) +let doSomething = try! resolver. ... +``` +or set it as ENS instance property and use its methods from it: +```swift +try! ens.setENSResolver(withDomain: domain) +let doSomething = try! ens.resolver!. ... +``` + +### BaseRegistrar +You can set BaseRegistrar as ENS instance property and use its methods from it: +```swift +ens.setBaseRegistrar(withAddress: address) +let doSomething = try! ens.baseRegistrar!. ... +``` + +### RegistrarController +You can set RegistrarController as ENS instance property and use its methods from it: +```swift +ens.setRegistrarController(withAddresss: address) +let doSomething = try! ens.registrarController!. ... +``` + + + + From b9f46eecba937d398410ff02519f18638e1c1f45 Mon Sep 17 00:00:00 2001 From: Anton Grigorev Date: Fri, 19 Apr 2019 18:29:32 +0300 Subject: [PATCH 2/2] Update README.md --- README.md | 83 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 208b2e7a3..8f4be85b2 100755 --- a/README.md +++ b/README.md @@ -33,45 +33,50 @@ --- - [Usage Doc](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md) - **[Introduction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#introduction)** - - *[Preffered models](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-models)* - - [Preffered keys Wallet Model](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-keys-wallet-model-account) - - [Preffered ERC-20 Model](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-erc-20-model) -- **[Account Management](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#account-management)** - - *[Create Account](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account)* - - [Create Account With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account-with-private-key) - - [Create Account With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account-with-mnemonics-phrase) - - *[Import Account](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account)* - - [Import Account With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#import-account-with-private-key) - - [Import Account With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#import-account-with-mnemonics-phrase) - - [Get Keystore Manager from wallet data](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-keystore-manager-from-wallet-data) - - [Get wallet Private key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-wallet-private-key) -- **[Ethereum Endpoints interaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ethereum-endpoints-interaction)** - - [web3 instance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#web3-instance) - - [Ethereum Address](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ethereum-address) - - *[Get Balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-balance)* - - [Getting ETH balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#getting-eth-balance) - - [Getting ERC20 token balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#getting-erc20-token-balance) - - *[Transactions Operations](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#transactions-operations)* - - [Preparing Transaction For Sending Ether](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-transaction-for-sending-ether) - - [Preparing Transaction For Sending ERC-20 Tokens](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-transaction-for-sending-erc-20-tokens) - - [Preparing Write Transaction for sending to some Contract and use its method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-write-transaction-for-sending-to-some-contract-and-use-its-method) - - [Preparing Read Transaction to call some Contract method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-read-transaction-to-call-some-contract-method) - - [Send write transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#writing) - - [Send read transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#reading) - - [Get Block number](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-block-number) -- **[Websockets](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#websockets)** - - [Web3socketDelegate](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#web3socketdelegate) - - [Get latest new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-latest-new-pending-transactions) - - *[Custom Websocket Provider](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#custom-websocket-provider)* - - [Connect to custom endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-custom-endpoint) - - [Send message](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-message) - - *[Infura Websocket Provider](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#infura-websocket-provider)* - - [Connect to Infura endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-infura-endpoint) - - [Connect to custom endpoint with API similar to Infura WSS endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-custom-endpoint-with-api-similar-to-infura-wss-endpoint) - - [Create a filter in the node to notify when something happened](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-a-filter-in-the-node-to-notify-when-something-happened) - - [Get new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-new-pending-transactions) - - [Create a new subscription over particular events](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-a-new-subscription-over-particular-events) - - [Subscribe on new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#subscribe-on-new-pending-transactions) + - *[Preffered models](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-models)* + - [Preffered keys Wallet Model](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-keys-wallet-model-account) + - [Preffered ERC-20 Model](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-erc-20-model) + - **[Account Management](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#account-management)** + - *[Create Account](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account)* + - [Create Account With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account-with-private-key) + - [Create Account With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account-with-mnemonics-phrase) + - *[Import Account](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account)* + - [Import Account With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#import-account-with-private-key) + - [Import Account With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#import-account-with-mnemonics-phrase) + - [Get Keystore Manager from wallet data](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-keystore-manager-from-wallet-data) + - [Get wallet Private key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-wallet-private-key) + - **[Ethereum Endpoints interaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ethereum-endpoints-interaction)** + - [web3 instance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#web3-instance) + - [Ethereum Address](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ethereum-address) + - *[Get Balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-balance)* + - [Getting ETH balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#getting-eth-balance) + - [Getting ERC20 token balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#getting-erc20-token-balance) + - *[Transactions Operations](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#transactions-operations)* + - [Preparing Transaction For Sending Ether](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-transaction-for-sending-ether) + - [Preparing Transaction For Sending ERC-20 Tokens](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-transaction-for-sending-erc-20-tokens) + - [Preparing Write Transaction for sending to some Contract and use its method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-write-transaction-for-sending-to-some-contract-and-use-its-method) + - [Preparing Read Transaction to call some Contract method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-read-transaction-to-call-some-contract-method) + - [Send write transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#writing) + - [Send read transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#reading) + - [Get Block number](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-block-number) + - **[Websockets](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#websockets)** + - [Web3socketDelegate](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#web3socketdelegate) + - [Get latest new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-latest-new-pending-transactions) + - *[Custom Websocket Provider](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#custom-websocket-provider)* + - [Connect to custom endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-custom-endpoint) + - [Send message](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-message) + - *[Infura Websocket Provider](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#infura-websocket-provider)* + - [Connect to Infura endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-infura-endpoint) + - [Connect to custom endpoint with API similar to Infura WSS endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-custom-endpoint-with-api-similar-to-infura-wss-endpoint) + - [Create a filter in the node to notify when something happened](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-a-filter-in-the-node-to-notify-when-something-happened) + - [Get new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-new-pending-transactions) + - [Create a new subscription over particular events](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-a-new-subscription-over-particular-events) + - [Subscribe on new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#subscribe-on-new-pending-transactions) + - **[ENS](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ens)** + - [Registry](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#registry) + - [Resolver](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#resolver) + - [BaseRegistrar](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#baseregistrar) + - [RegistrarController](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#registrarcontroller) ## Ready Features - [x] Swift implementation of [web3.js](https://github.com/ethereum/web3.js/) functionality :zap: