From 8bf59504653adf41a9a35ce9343388372568366c Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Fri, 14 Jun 2019 14:50:46 -0700 Subject: [PATCH 1/5] update documentation headers --- Documentation/Usage.md | 52 ++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/Documentation/Usage.md b/Documentation/Usage.md index 5224c97b3..02c5b59e5 100755 --- a/Documentation/Usage.md +++ b/Documentation/Usage.md @@ -91,7 +91,7 @@ class ERC20Token { ### Create Account -#### Create Account With Private Key +#### With Private Key ```swift let password = "web3swift" // We recommend here and everywhere to use the password set by the user. @@ -102,7 +102,7 @@ let address = keystore.addresses!.first!.address let wallet = Wallet(address: address, data: keyData, name: name, isHD: false) ``` -#### Create Account With Mnemonics Phrase +#### With Mnemonics Phrase ```swift let password = "web3swift" @@ -121,7 +121,7 @@ let wallet = Wallet(address: address, data: keyData, name: name, isHD: true) ### Import Account -#### Import Account With Private Key +#### With Private Key ```swift let password = "web3swift" @@ -135,7 +135,7 @@ let address = keystore.addresses!.first!.address let wallet = Wallet(address: address, data: keyData, name: name, isHD: false) ``` -#### Import Account With Mnemonics Phrase +#### With Mnemonics Phrase ```swift let password = "web3swift" @@ -165,7 +165,7 @@ if wallet.isHD { } ``` -### Get wallet Private key +### Get wallet private key ```swift let password = "web3swift" @@ -195,7 +195,7 @@ web3.addKeystoreManager(keystoreManager) ### Ethereum Address -#### Initializing Ethereum Address +#### Initializing ```swift let coldWalletAddress = EthereumAddress("0x6394b37Cf80A7358b38068f0CA4760ad49983a1B")! @@ -205,7 +205,7 @@ Ethereum addresses are checksum checked if they are not lowercased or uppercased ### Get Balance -#### Getting ETH balance +#### Get ETH balance ```swift let walletAddress = EthereumAddress(wallet.address)! // Address which balance we want to know @@ -213,7 +213,7 @@ let balanceResult = try! web3.eth.getBalance(address: walletAddress) let balanceString = Web3.Utils.formatToEthereumUnits(balanceResult, toUnits: .eth, decimals: 3)! ``` -#### Getting ERC20 token balance +#### Get ERC20 token balance ```swift let walletAddress = EthereumAddress(wallet.address)! // Your wallet address @@ -239,7 +239,7 @@ let balanceString = Web3.Utils.formatToEthereumUnits(balanceResult, toUnits: .et #### Prepare Transaction -##### Preparing Transaction For Sending Ether +##### Send Ether ```swift let value: String = "1.0" // In Ether @@ -259,7 +259,7 @@ let tx = contract.write( transactionOptions: options)! ``` -##### Preparing Transaction For Sending ERC-20 Tokens +##### Send ERC-20 Token ```swift let value: String = "1.0" // In Tokens @@ -281,7 +281,7 @@ let tx = contract.write( transactionOptions: options)! ``` -##### Preparing Write Transaction for sending to some Contract and use its method +##### Write Transaction and call smart contract method ```swift let value: String = "0.0" // Any amount of Ether you need to send @@ -306,7 +306,7 @@ let tx = contract.write( transactionOptions: options)! ``` -##### Preparing Read Transaction to call some Contract method +##### Read Transaction to call smart contract method ```swift let walletAddress = EthereumAddress(wallet.address)! // Your wallet address @@ -328,17 +328,17 @@ let tx = contract.read( transactionOptions: options)! ``` -#### Send Transaction +#### Send Transaction -##### Writing +##### Write ```swift let password = "web3swift" let result = try! transaction.send(password: password) ``` -##### Reading - +##### Read + ```swift let result = try! transaction.call() ``` @@ -361,13 +361,13 @@ Later, in order to open a connection to WebSocket server, you will use socket pr class DelegateClass: Web3SocketDelegate { var socketProvider: WebsocketProvider? = nil // WebSocket Provider var socketProvider: InfuraWebsocketProvider? = nil // Infura WebSocket Provider - + // Protocol method, here will be messages, received from WebSocket server func received(message: Any) { // Make something with message } } -``` +``` ### Custom Websocket Provider @@ -380,31 +380,31 @@ socketProvider.connectSocket() /// Some code /// ... socketProvider.disconnectSocket() -``` +``` Or you can create already connected WebsocketProvider ```swift socketProvider = WebsocketProvider.connectToSocket("ws://your.endpoint", delegate: delegate) ``` -#### Send message +#### Send message ```swift // String message -socketProvider.writeMessage(String()) +socketProvider.writeMessage(String()) // Data message socketProvider.writeMessage(Data()) ``` -### Infura Websocket Provider +### Infura Websocket interactions -#### Connect to Infura endpoint +#### Connect to Infura endpoint ```swift socketProvider = InfuraWebsocketProvider.connectToInfuraSocket(.Mainnet, delegate: delegate) ``` -#### Connect to custom endpoint with API similar to Infura WSS endpoint +#### Connect to custom Infura-like endpoint ```swift socketProvider = InfuraWebsocketProvider.connectToSocket("ws://your.endpoint", delegate: delegate) @@ -481,7 +481,7 @@ 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!. ... +let doSomething = try! ens.resolver!. ... ``` ### BaseRegistrar @@ -504,5 +504,3 @@ You can set ReverseRegistrar as ENS instance property and use its methods from i ens.setReverseRegistrar(withAddresss: address) let doSomething = try! ens.reverseRegistrar!. ... ``` - - From 4390da18b9bc4bfd9140729e58d2368117acc0ad Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Fri, 14 Jun 2019 15:07:27 -0700 Subject: [PATCH 2/5] update doc usage TOC --- Documentation/Usage.md | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/Documentation/Usage.md b/Documentation/Usage.md index 02c5b59e5..5f55715c4 100755 --- a/Documentation/Usage.md +++ b/Documentation/Usage.md @@ -1,5 +1,64 @@ # Usage +--- +## Table of contents: + + + +- [About source and GitHub repositories](#about-source-and-github-repositories) + +- [Introduction](#introduction) + - [Preffered models](#preffered-models) + - [Preffered keys Wallet Model (Account)](#preffered-keys-wallet-model-account) + - [Preffered ERC-20 Model](#preffered-erc-20-model) +- [Account Management](#account-management) + - [Create Account](#create-account) + - [With Private Key](#with-private-key) + - [With Mnemonics Phrase](#with-mnemonics-phrase) + - [Import Account](#import-account) + - [With Private Key](#with-private-key-1) + - [With Mnemonics Phrase](#with-mnemonics-phrase-1) + - [Get Keystore Manager from wallet data](#get-keystore-manager-from-wallet-data) + - [Get wallet private key](#get-wallet-private-key) +- [Ethereum Endpoints interaction](#ethereum-endpoints-interaction) + - [web3 instance](#web3-instance) + - [Ethereum Address](#ethereum-address) + - [Initializing](#initializing) + - [Get Balance](#get-balance) + - [Get ETH balance](#get-eth-balance) + - [Get ERC20 token balance](#get-erc20-token-balance) + - [Transactions Operations](#transactions-operations) + - [Prepare Transaction](#prepare-transaction) + - [Send Ether](#send-ether) + - [Send ERC-20 Token](#send-erc-20-token) + - [Write Transaction and call smart contract method](#write-transaction-and-call-smart-contract-method) + - [Read Transaction to call smart contract method](#read-transaction-to-call-smart-contract-method) + - [Send Transaction](#send-transaction) + - [Write](#write) + - [Read](#read) + - [Chain state](#chain-state) + - [Get Block number](#get-block-number) +- [Websockets](#websockets) + - [Web3socketDelegate](#web3socketdelegate) + - [Custom Websocket Provider](#custom-websocket-provider) + - [Connect to custom endpoint](#connect-to-custom-endpoint) + - [Send message](#send-message) + - [Infura Websocket interactions](#infura-websocket-interactions) + - [Connect to Infura endpoint](#connect-to-infura-endpoint) + - [Connect to custom Infura-like endpoint](#connect-to-custom-infura-like-endpoint) + - [Create a filter in the node to notify when something happened](#create-a-filter-in-the-node-to-notify-when-something-happened) + - [Get new pending transactions](#get-new-pending-transactions) + - [Create a new subscription over particular events](#create-a-new-subscription-over-particular-events) + - [Subscribe on new pending transactions](#subscribe-on-new-pending-transactions) +- [ENS](#ens) + - [Registry](#registry) + - [Resolver](#resolver) + - [BaseRegistrar](#baseregistrar) + - [RegistrarController](#registrarcontroller) + - [ReverseRegistrar](#reverseregistrar) + + + --- - **[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)* From 6989328088e4f4bef4aac4d0e1dc69173985422b Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Fri, 14 Jun 2019 15:08:34 -0700 Subject: [PATCH 3/5] add reference links --- Documentation/Usage.md | 150 ++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 99 deletions(-) diff --git a/Documentation/Usage.md b/Documentation/Usage.md index 5f55715c4..0b906f308 100755 --- a/Documentation/Usage.md +++ b/Documentation/Usage.md @@ -5,108 +5,60 @@ -- [About source and GitHub repositories](#about-source-and-github-repositories) - -- [Introduction](#introduction) - - [Preffered models](#preffered-models) - - [Preffered keys Wallet Model (Account)](#preffered-keys-wallet-model-account) - - [Preffered ERC-20 Model](#preffered-erc-20-model) -- [Account Management](#account-management) - - [Create Account](#create-account) - - [With Private Key](#with-private-key) - - [With Mnemonics Phrase](#with-mnemonics-phrase) - - [Import Account](#import-account) - - [With Private Key](#with-private-key-1) - - [With Mnemonics Phrase](#with-mnemonics-phrase-1) - - [Get Keystore Manager from wallet data](#get-keystore-manager-from-wallet-data) - - [Get wallet private key](#get-wallet-private-key) -- [Ethereum Endpoints interaction](#ethereum-endpoints-interaction) - - [web3 instance](#web3-instance) - - [Ethereum Address](#ethereum-address) - - [Initializing](#initializing) - - [Get Balance](#get-balance) - - [Get ETH balance](#get-eth-balance) - - [Get ERC20 token balance](#get-erc20-token-balance) - - [Transactions Operations](#transactions-operations) - - [Prepare Transaction](#prepare-transaction) - - [Send Ether](#send-ether) - - [Send ERC-20 Token](#send-erc-20-token) - - [Write Transaction and call smart contract method](#write-transaction-and-call-smart-contract-method) - - [Read Transaction to call smart contract method](#read-transaction-to-call-smart-contract-method) - - [Send Transaction](#send-transaction) - - [Write](#write) - - [Read](#read) - - [Chain state](#chain-state) - - [Get Block number](#get-block-number) -- [Websockets](#websockets) - - [Web3socketDelegate](#web3socketdelegate) - - [Custom Websocket Provider](#custom-websocket-provider) - - [Connect to custom endpoint](#connect-to-custom-endpoint) - - [Send message](#send-message) - - [Infura Websocket interactions](#infura-websocket-interactions) - - [Connect to Infura endpoint](#connect-to-infura-endpoint) - - [Connect to custom Infura-like endpoint](#connect-to-custom-infura-like-endpoint) - - [Create a filter in the node to notify when something happened](#create-a-filter-in-the-node-to-notify-when-something-happened) - - [Get new pending transactions](#get-new-pending-transactions) - - [Create a new subscription over particular events](#create-a-new-subscription-over-particular-events) - - [Subscribe on new pending transactions](#subscribe-on-new-pending-transactions) -- [ENS](#ens) - - [Registry](#registry) - - [Resolver](#resolver) - - [BaseRegistrar](#baseregistrar) - - [RegistrarController](#registrarcontroller) - - [ReverseRegistrar](#reverseregistrar) +- [About source and GitHub repositories](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#about-source-and-github-repositories) + +- [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 (Account)](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) + - [With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#with-private-key) + - [With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#with-mnemonics-phrase) + - [Import Account](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#import-account) + - [With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#with-private-key-1) + - [With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#with-mnemonics-phrase-1) + - [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) + - [Initializing](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#initializing) + - [Get Balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-balance) + - [Get ETH balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-eth-balance) + - [Get ERC20 token balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-erc20-token-balance) + - [Transactions Operations](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#transactions-operations) + - [Prepare Transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#prepare-transaction) + - [Send Ether](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-ether) + - [Send ERC-20 Token](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-erc-20-token) + - [Write Transaction and call smart contract method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#write-transaction-and-call-smart-contract-method) + - [Read Transaction to call smart contract method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#read-transaction-to-call-smart-contract-method) + - [Send Transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-transaction) + - [Write](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#write) + - [Read](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#read) + - [Chain state](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#chain-state) + - [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) + - [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 interactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#infura-websocket-interactions) + - [Connect to Infura endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-infura-endpoint) + - [Connect to custom Infura-like endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-custom-infura-like-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) + - [ReverseRegistrar](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#reverseregistrar) ---- -- **[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) -- **[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) - - [ReverseRegistrar](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#reverseregistrar) - ## Introduction To work with platforms based on blockchain technology, in particular with Ethereum-like blockchains, developer must be fluent in concepts such as a crypto wallet, private and public key, smart contract, token and others. We will use these concepts without explaining their meanings. For more information about Ethereum, we recommend reading the book [Mastering Ethereum](https://github.com/ethereumbook/ethereumbook), by Andreas M. Antonopoulos and Gavin Wood. From ca224b9345abb0cf0ab2480f307409aca5c0fd5f Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Fri, 14 Jun 2019 15:44:02 -0700 Subject: [PATCH 4/5] update readme structure --- README.md | 206 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 119 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index 91428ab7e..ba459a847 100755 --- a/README.md +++ b/README.md @@ -13,72 +13,34 @@ **web3swift** is your toolbelt for any kind interactions with Ethereum network. - - * [Ready Features](#features) - * [Design Decisions](#design-decisions) - * [Requirements](#requirements) - * [Migration Guides](#migration-guides) - * [Communication](#communication) - * [Installation](#installation) - + [CocoaPods](#cocoapods) - + [Carthage](#carthage) - * [Example Project](#example-project) - * [Popular questions](#popular-questions) - * [What's next](#whats-next) - * [Credits](#credits) - + [Security Disclosure](#security-disclosure) - * [Donations](#donations) - * [License](#license) - ---- - - [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) - - **[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) - - [ReverseRegistrar](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#reverseregistrar) -## Ready Features + + + + +- [Documentation](#documentation) +- [What we have already done:](#what-we-have-already-done) +- [Design Decisions](#design-decisions) +- [Requirements](#requirements) +- [Migration Guides](#migration-guides) +- [Communication](#communication) +- [Installation](#installation) + - [CocoaPods](#cocoapods) + - [Carthage](#carthage) +- [Example Project](#example-project) +- [Popular questions](#popular-questions) + - [Is it possible to get Mnemonic Phrase (Seed Phrase) from Private key using web3swift?](#is-it-possible-to-get-mnemonic-phrase-seed-phrase-from-private-key-using-web3swift) + - [How to interact with custom smart-contract with web3swift?](#how-to-interact-with-custom-smart-contract-with-web3swift) + - [How to set test local node?](#how-to-set-test-local-node) +- [What's next](#whats-next) +- [Credits](#credits) + - [Security Disclosure](#security-disclosure) +- [Donations](#donations) +- [License](#license) + + + + +## What we have already done: - [x] Swift implementation of [web3.js](https://github.com/ethereum/web3.js/) functionality :zap: - [x] Interaction with remote node via JSON RPC :thought_balloon: @@ -115,7 +77,7 @@ - [x] [EIP-1155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md) (Multi Token Standard, also known as ERC-1155) - [x] [EIP-1376](https://github.com/ethereum/EIPs/issues/1376) (Service-Friendly Token, also known as ERC-1376) - [x] [ST-20](https://github.com/PolymathNetwork/polymath-core) - ST-20 token is an Ethereum-based token implemented on top of the ERC-20 protocol that adds the ability for tokens to control transfers based on specific rules - + - [x] RLP encoding - [x] Batched requests in concurrent mode - [x] Base58 encoding scheme @@ -139,19 +101,27 @@ - [web3swift 2.0 Migration Guide](https://github.com/matterinc/web3swift/blob/master/Documentation/web3swift%202.0%20Migration%20Guide.md) -## Communication +## Projects that using web3swift + +If you are using this library in your project, please [add a link](https://github.com/matter-labs/web3swift/edit/develop/README.md) to this repo. + +* [MyEtherWallet/MEWconnect-iOS](https://github.com/MyEtherWallet/MEWconnect-iOS) +* [Peepeth iOS client](https://github.com/matterinc/PeepethClient) +* [Ethereum & ERC20Tokens Wallet](https://itunes.apple.com/us/app/ethereum-erc20tokens-wallet/id1386738877?ls=1&mt=8) +* [BankexWallet](https://github.com/BANKEX/Pay-iOS) +* [GeoChain](https://github.com/awallish/GeoChain) +* [NewHorizonLabs/TRX-Wallet](https://github.com/NewHorizonLabs/TRX-Wallet) +* [SteadyAction/EtherWalletKit](https://github.com/SteadyAction/EtherWalletKit) +* [UP Wallet/loopr-ios](https://github.com/Loopring/loopr-ios) +* [MyENS Wallet](https://github.com/barrasso/enswallet) +* [LoanStar](https://github.com/barrasso/loan-star) +* [AlphaWallet](https://github.com/AlphaWallet/alpha-wallet-ios) +* [Follow_iOS](https://github.com/FollowInc/Follow_iOS) +* [Biomedical Data Sharing dApp - Geolocation](https://github.com/HD2i/Geolocation-iOS) +* [YOUR APP CAN BE THERE (click me)](https://github.com/matter-labs/web3swift/edit/develop/README.md) :wink: -When using this lib, please make references to this repo and give your start! :) *Nothing makes developers happier than seeing someone else use our work and go wild with it.* -If you are using web3swift in your app or know of an app that uses it, please add it to [this list](https://github.com/matter-labs/web3swift/wiki/Apps-using-web3swift). - -- If you **need help**, [open an issue](https://github.com/matter-labs/web3swift/issues). -- If you need to **find or understand an API**, check [our documentation](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md). -- If you'd like to **see web3swift best practices**, check [Apps using this library](https://github.com/matter-labs/web3swift/wiki/Apps-using-web3swift). -- If you **found a bug**, [open an issue](https://github.com/matter-labs/web3swift/issues). -- If you **have a feature request**, [open an issue](https://github.com/matter-labs/web3swift/issues). -- If you **want to contribute**, [submit a pull request](https://github.com/matter-labs/web3swift/pulls). ## Installation @@ -208,6 +178,64 @@ github "matter-labs/web3swift" "master" Run `carthage update` to build the framework. By default, Carthage performs checkouts and builds in a new directory 'Carthage' in the same location as your Cartfile. Open this directory, go to 'Build' directory, choose iOS or macOS directory and use framework from chosen directory in your Xcode project. + +--- +## Documentation + +Full source please look at [Documentation folder](https://github.com/matter-labs/web3swift/blob/master/Documentation/) + +Here is quick references for basic features: + +- [Preffered models](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-models) + - [Preffered keys Wallet Model (Account)](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) + - [With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#with-private-key) + - [With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#with-mnemonics-phrase) + - [Import Account](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#import-account) + - [With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#with-private-key-1) + - [With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#with-mnemonics-phrase-1) + - [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) + - [Initializing](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#initializing) + - [Get Balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-balance) + - [Get ETH balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-eth-balance) + - [Get ERC20 token balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-erc20-token-balance) + - [Transactions Operations](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#transactions-operations) + - [Prepare Transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#prepare-transaction) + - [Send Ether](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-ether) + - [Send ERC-20 Token](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-erc-20-token) + - [Write Transaction and call smart contract method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#write-transaction-and-call-smart-contract-method) + - [Read Transaction to call smart contract method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#read-transaction-to-call-smart-contract-method) + - [Send Transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-transaction) + - [Write](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#write) + - [Read](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#read) + - [Chain state](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#chain-state) + - [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) + - [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 interactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#infura-websocket-interactions) + - [Connect to Infura endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-infura-endpoint) + - [Connect to custom Infura-like endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-custom-infura-like-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) + - [ReverseRegistrar](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#reverseregistrar) + + ## Example Project You can try lib by running the example project: @@ -225,7 +253,7 @@ In web3swift there is no backward conversion from Private key to Mnemonic Phrase The simplest solution is to encrypt the phrase using users pincode and save it in some other secure keystore. Mnemonic Phrase is very sensitive data and you must be very careful to let the user get it. -Our advise if you want to show it to user - ask to save a Passphrase when creating BIP32Keystore. +Our advise if you want to show it to user - ask to save a Passphrase when creating BIP32Keystore. #### How to interact with custom smart-contract with web3swift? @@ -272,7 +300,7 @@ func setLocalNode(port: Int = 8545) -> Web3? { ## What's next -- [x] Objective-C - a proxy bridge to build your DApp on Objective-C using web3swift +- [x] Objective-C - a proxy bridge to build your DApp on Objective-C using web3swift - [x] Complete Documentation (https://web3swift.github.io/web3swift) - [x] Modularity with the basic Web3 subspec/SPM (the most basic functions like transaction signing and interacting with an http rpc server) and other modules with additional functionality - [x] [R-Token](https://github.com/harborhq/r-token) - Smart Contracts for applying regulatory compliance to tokenized securities issuance and trading @@ -283,23 +311,27 @@ func setLocalNode(port: Int = 8545) -> Web3? { ## Credits -Alex Vlasov, [@shamatar](https://github.com/shamatar), alex.m.vlasov@gmail.com - +Alex Vlasov, [@shamatar](https://github.com/shamatar) Petr Korolev, [@skywinder](https://github.com/skywinder) - -Anton Grigorev [@baldyash](https://github.com/BaldyAsh), antongrigorjev2010@gmail.com +Anton Grigorev, [@baldyash](https://github.com/BaldyAsh) ### Security Disclosure If you believe you have identified a security vulnerability with web3swift, you should report it as soon as possible via email to [Alex Vlasov](https://github.com/shamatar) alex.m.vlasov@gmail.com. Please do not post it to a public issue tracker. -## Donations - -[The Matters](https://github.com/orgs/matter-labs/people) are charged with open-sourсe and do not require money for using their web3swift lib. +[Matter Labs](https://github.com/orgs/matter-labs/people) are charged with open-sourсe and do not require money for using their web3swift lib. We want to continue to do everything we can to move the needle forward. If you use any of our libraries for work, see if your employers would be interested in donating. Any amount you can donate today to help us reach our goal would be greatly appreciated. -Our Ether wallet address: 0xe22b8979739d724343bd002f9f432f5990879901 +## Contribute + +- If you **need help**, [open an issue](https://github.com/matter-labs/web3swift/issues). +- If you need to **find or understand an API**, check [our documentation](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md). +- If you'd like to **see web3swift best practices**, check [Apps using this library](https://github.com/matter-labs/web3swift/wiki/Apps-using-web3swift). +- If you **found a bug**, [open an issue](https://github.com/matter-labs/web3swift/issues). +- If you **have a feature request**, [open an issue](https://github.com/matter-labs/web3swift/issues). +- If you **want to contribute**, [submit a pull request](https://github.com/matter-labs/web3swift/pulls). +- Donation Our Ether wallet address: 0xe22b8979739d724343bd002f9f432f5990879901 ![Donate](http://qrcoder.ru/code/?0xe22b8979739d724343bd002f9f432f5990879901&4&0) From 515f80eee50a0bcdbec79103d09b015604498667 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Fri, 14 Jun 2019 15:55:39 -0700 Subject: [PATCH 5/5] update grammar & typos --- Documentation/Usage.md | 188 ++++++++++++++++++++--------------------- README.md | 52 ++++++------ 2 files changed, 120 insertions(+), 120 deletions(-) diff --git a/Documentation/Usage.md b/Documentation/Usage.md index 0b906f308..a5310f799 100755 --- a/Documentation/Usage.md +++ b/Documentation/Usage.md @@ -7,71 +7,71 @@ - [About source and GitHub repositories](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#about-source-and-github-repositories) -- [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 (Account)](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) - - [With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#with-private-key) - - [With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#with-mnemonics-phrase) - - [Import Account](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#import-account) - - [With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#with-private-key-1) - - [With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#with-mnemonics-phrase-1) - - [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) - - [Initializing](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#initializing) - - [Get Balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-balance) - - [Get ETH balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-eth-balance) - - [Get ERC20 token balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-erc20-token-balance) - - [Transactions Operations](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#transactions-operations) - - [Prepare Transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#prepare-transaction) - - [Send Ether](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-ether) - - [Send ERC-20 Token](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-erc-20-token) - - [Write Transaction and call smart contract method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#write-transaction-and-call-smart-contract-method) - - [Read Transaction to call smart contract method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#read-transaction-to-call-smart-contract-method) - - [Send Transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-transaction) - - [Write](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#write) - - [Read](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#read) - - [Chain state](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#chain-state) - - [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) - - [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 interactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#infura-websocket-interactions) - - [Connect to Infura endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-infura-endpoint) - - [Connect to custom Infura-like endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-custom-infura-like-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) - - [ReverseRegistrar](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#reverseregistrar) +- [Introduction](#introduction) + - [Preffered models](#preffered-models) + - [Preferred keys Wallet Model (Account)](#preferred-keys-wallet-model-account) + - [Preffered ERC-20 Model](#preffered-erc-20-model) +- [Account Management](#account-management) + - [Create Account](#create-account) + - [With Private Key](#with-private-key) + - [With Mnemonics Phrase](#with-mnemonics-phrase) + - [Import Account](#import-account) + - [With Private Key](#with-private-key-1) + - [With Mnemonics Phrase](#with-mnemonics-phrase-1) + - [Get Keystore Manager from wallet data](#get-keystore-manager-from-wallet-data) + - [Get private key](#get-private-key) +- [Ethereum Endpoints interaction](#ethereum-endpoints-interaction) + - [web3 instance](#web3-instance) + - [Ethereum Address](#ethereum-address) + - [Initializing](#initializing) + - [Get Balance](#get-balance) + - [Get ETH balance](#get-eth-balance) + - [Get ERC20 token balance](#get-erc20-token-balance) + - [Transactions Operations](#transactions-operations) + - [Prepare Transaction](#prepare-transaction) + - [Send Ether](#send-ether) + - [Send ERC-20 Token](#send-erc-20-token) + - [Write Transaction and call smart contract method](#write-transaction-and-call-smart-contract-method) + - [Read Transaction to call smart contract method](#read-transaction-to-call-smart-contract-method) + - [Send Transaction](#send-transaction) + - [Write](#write) + - [Read](#read) + - [Chain state](#chain-state) + - [Get Block number](#get-block-number) +- [Websockets](#websockets) + - [Web3socketDelegate](#web3socketdelegate) + - [Custom Websocket Provider](#custom-websocket-provider) + - [Connect to custom endpoint](#connect-to-custom-endpoint) + - [Send message](#send-message) + - [Infura Websocket interactions](#infura-websocket-interactions) + - [Connect to Infura endpoint](#connect-to-infura-endpoint) + - [Connect to custom Infura-like endpoint](#connect-to-custom-infura-like-endpoint) + - [Create a filter in the node to notify when something happened](#create-a-filter-in-the-node-to-notify-when-something-happened) + - [Get new pending transactions](#get-new-pending-transactions) + - [Create a new subscription over particular events](#create-a-new-subscription-over-particular-events) + - [Subscribe on new pending transactions](#subscribe-on-new-pending-transactions) +- [ENS](#ens) + - [Registry](#registry) + - [Resolver](#resolver) + - [BaseRegistrar](#baseregistrar) + - [RegistrarController](#registrarcontroller) + - [ReverseRegistrar](#reverseregistrar) ## Introduction -To work with platforms based on blockchain technology, in particular with Ethereum-like blockchains, developer must be fluent in concepts such as a crypto wallet, private and public key, smart contract, token and others. We will use these concepts without explaining their meanings. For more information about Ethereum, we recommend reading the book [Mastering Ethereum](https://github.com/ethereumbook/ethereumbook), by Andreas M. Antonopoulos and Gavin Wood. +To work with platforms based on blockchain technology, in particular with Ethereum-like blockchains, a developer must be fluent in concepts such as a crypto wallet, private and public key, smart contract, token and others. We will use these concepts without explaining their meanings. For more information about Ethereum, we recommend reading the book [Mastering Ethereum](https://github.com/ethereumbook/ethereumbook), by Andreas M. Antonopoulos and Gavin Wood. -**To create keystore we forced our users to use some password, which will be used in some operations, like transactions sending. We believe that security is important for such operations and this increases its level. You are free to use a pre-compiled password in your code, that is not set by the keystore user, at your own risk.** +**To create keystore we forced our users to use some password, which will be used in some operations, like transactions sending. We believe that security is essential for such, and this increases its level. You are free to use a pre-compiled password in your code, that is not set by the keystore user, at your own risk.** *In code examples we used force-unwrapped Swift optionals for better readability of example code. We recommend that you do not use this method to get rid of optional values.* ### Preffered models -To describe the library's capabilities, we will use the models described below, however you can use the models that are convenient for you. +To describe the library's capabilities, we will use the models described below. However, you can use the models that are convenient for you. -#### Preffered keys Wallet Model (Account) +#### Preferred keys Wallet Model (Account) ```swift struct Wallet { @@ -120,10 +120,10 @@ let password = "web3swift" let bitsOfEntropy: Int = 128 // Entropy is a measure of password strength. Usually used 128 or 256 bits. let mnemonics = try! BIP39.generateMnemonics(bitsOfEntropy: bitsOfEntropy)! let keystore = try! BIP32Keystore( - mnemonics: mnemonics, - password: password, - mnemonicsPassword: "", - language: .english)! + mnemonics: mnemonics, + password: password, + mnemonicsPassword: "", + language: .english)! let name = "New HD Wallet" let keyData = try! JSONEncoder().encode(keystore.keystoreParams) let address = keystore.addresses!.first!.address @@ -152,10 +152,10 @@ let wallet = Wallet(address: address, data: keyData, name: name, isHD: false) let password = "web3swift" let mnemonics = "fine have legal roof fury bread egg knee wrong idea must edit" // Some mnemonic phrase let keystore = try! BIP32Keystore( - mnemonics: mnemonics, - password: password, - mnemonicsPassword: "", - language: .english)! + mnemonics: mnemonics, + password: password, + mnemonicsPassword: "", + language: .english)! let name = "New HD Wallet" let keyData = try! JSONEncoder().encode(keystore.keystoreParams) let address = keystore.addresses!.first!.address @@ -168,15 +168,15 @@ let wallet = Wallet(address: address, data: keyData, name: name, isHD: true) let data = wallet.data let keystoreManager: KeystoreManager if wallet.isHD { - let keystore = BIP32Keystore(data)! - keystoreManager = KeystoreManager([keystore]) + let keystore = BIP32Keystore(data)! + keystoreManager = KeystoreManager([keystore]) } else { - let keystore = EthereumKeystoreV3(data)! - keystoreManager = KeystoreManager([keystore]) + let keystore = EthereumKeystoreV3(data)! + keystoreManager = KeystoreManager([keystore]) } ``` -### Get wallet private key +### Get private key ```swift let password = "web3swift" @@ -237,10 +237,10 @@ options.gasPrice = .automatic options.gasLimit = .automatic let method = "balanceOf" let tx = contract.read( - method, - parameters: [exploredAddress] as [AnyObject], - extraData: Data(), - transactionOptions: options)! + method, + parameters: [exploredAddress] as [AnyObject], + extraData: Data(), + transactionOptions: options)! let tokenBalance = try! tx.call() let balanceBigUInt = tokenBalance["0"] as! BigUInt let balanceString = Web3.Utils.formatToEthereumUnits(balanceResult, toUnits: .eth, decimals: 3)! @@ -264,10 +264,10 @@ options.from = walletAddress options.gasPrice = .automatic options.gasLimit = .automatic let tx = contract.write( - "fallback", - parameters: [AnyObject](), - extraData: Data(), - transactionOptions: options)! + "fallback", + parameters: [AnyObject](), + extraData: Data(), + transactionOptions: options)! ``` ##### Send ERC-20 Token @@ -286,10 +286,10 @@ options.gasPrice = .automatic options.gasLimit = .automatic let method = "transfer" let tx = contract.write( - method, - parameters: [toAddress, amount] as [AnyObject], - extraData: Data(), - transactionOptions: options)! + method, + parameters: [toAddress, amount] as [AnyObject], + extraData: Data(), + transactionOptions: options)! ``` ##### Write Transaction and call smart contract method @@ -311,10 +311,10 @@ options.from = walletAddress options.gasPrice = .automatic options.gasLimit = .automatic let tx = contract.write( - contractMethod, - parameters: parameters, - extraData: extraData, - transactionOptions: options)! + contractMethod, + parameters: parameters, + extraData: extraData, + transactionOptions: options)! ``` ##### Read Transaction to call smart contract method @@ -333,10 +333,10 @@ options.from = walletAddress options.gasPrice = .automatic options.gasLimit = .automatic let tx = contract.read( - contractMethod, - parameters: parameters, - extraData: extraData, - transactionOptions: options)! + contractMethod, + parameters: parameters, + extraData: extraData, + transactionOptions: options)! ``` #### Send Transaction @@ -366,17 +366,17 @@ let blockNumber = try! web3.eth.getBlockNumber() ### Web3socketDelegate -To receive messages from endpoint you need to create a class that adopt to Web3SocketDelegate protocol. -Later, in order to open a connection to WebSocket server, you will use socket provider (WebsocketProvider or InfuraWebsocketProvider). And we recommend you to make it a property, so it doesn't get deallocated right after being setup. +To receive messages from endpoint you need to create a class that adopts to Web3SocketDelegate protocol. +Later, to open a connection to WebSocket server, you will use socket provider (`WebsocketProvider` or `InfuraWebsocketProvider`). And we recommend you to make it a property, so it doesn't get deallocated right after being setup. ```swift class DelegateClass: Web3SocketDelegate { - var socketProvider: WebsocketProvider? = nil // WebSocket Provider - var socketProvider: InfuraWebsocketProvider? = nil // Infura WebSocket Provider + var socketProvider: WebsocketProvider? = nil // WebSocket Provider + var socketProvider: InfuraWebsocketProvider? = nil // Infura WebSocket Provider - // Protocol method, here will be messages, received from WebSocket server - func received(message: Any) { - // Make something with message - } + // Protocol method, here will be messages, received from WebSocket server + func received(message: Any) { + // Make something with message + } } ``` diff --git a/README.md b/README.md index ba459a847..54b194362 100755 --- a/README.md +++ b/README.md @@ -55,28 +55,28 @@ - [x] Supports Web3View functionality - WKWebView with injected "web3" provider - [x] Possibility to add or remove "middleware" that intercepts, modifies and even cancel transaction workflow on stages "before assembly", "after assembly"and "before submission" - [x] Literally following the standards: - - [x] [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) HD Wallets: Deterministic Wallet - - [x] [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) (Seed phrases) - - [x] [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) (Key generation prefixes) - - [x] [EIP-20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md) (A standard interface for tokens - ERC-20) - - [x] [EIP-67](https://github.com/ethereum/EIPs/issues/67) (Standard URI scheme with metadata, value and byte code) - - [x] [EIP-155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md) (Replay attacks protection) *enforced!* - - [x] [EIP-681](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-681.md) (A standard way of representing various transactions, especially payment requests in Ethers and ERC-20 tokens as URLs) - - [x] [EIP-721](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md) (A standard interface for non-fungible tokens, also known as deeds - ERC-721) - - [x] [EIP-165](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md) (Standard Interface Detection, also known as ERC-165) - - [x] [EIP-777](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-777.md) (New Advanced Token Standard, also known as ERC-777) - - [x] [EIP-820](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-820.md) (Pseudo-introspection Registry Contract, also known as ERC-820) - - [x] [EIP-888](https://github.com/ethereum/EIPs/issues/888) (MultiDimensional Token Standard, also known as ERC-888) - - [x] [EIP-1400](https://github.com/ethereum/EIPs/issues/1411) (Security Token Standard, also known as ERC-1400) - - [x] [EIP-1410](https://github.com/ethereum/EIPs/issues/1410) (Partially Fungible Token Standard, also known as ERC-1410) - - [x] [EIP-1594](https://github.com/ethereum/EIPs/issues/1594) (Core Security Token Standard, also known as ERC-1594) - - [x] [EIP-1643](https://github.com/ethereum/EIPs/issues/1643) (Document Management Standard, also known as ERC-1643) - - [x] [EIP-1644](https://github.com/ethereum/EIPs/issues/1644) (Controller Token Operation Standard, also known as ERC-1644) - - [x] [EIP-1633](https://github.com/ethereum/EIPs/issues/1634) (Re-Fungible Token, also known as ERC-1633) - - [x] [EIP-721x](https://github.com/loomnetwork/erc721x) (An extension of ERC721 that adds support for multi-fungible tokens and batch transfers, while being fully backward-compatible, also known as ERC-721x) - - [x] [EIP-1155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md) (Multi Token Standard, also known as ERC-1155) - - [x] [EIP-1376](https://github.com/ethereum/EIPs/issues/1376) (Service-Friendly Token, also known as ERC-1376) - - [x] [ST-20](https://github.com/PolymathNetwork/polymath-core) - ST-20 token is an Ethereum-based token implemented on top of the ERC-20 protocol that adds the ability for tokens to control transfers based on specific rules + - [x] [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) HD Wallets: Deterministic Wallet + - [x] [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) (Seed phrases) + - [x] [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) (Key generation prefixes) + - [x] [EIP-20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md) (A standard interface for tokens - ERC-20) + - [x] [EIP-67](https://github.com/ethereum/EIPs/issues/67) (Standard URI scheme with metadata, value and byte code) + - [x] [EIP-155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md) (Replay attacks protection) *enforced!* + - [x] [EIP-681](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-681.md) (A standard way of representing various transactions, especially payment requests in Ethers and ERC-20 tokens as URLs) + - [x] [EIP-721](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md) (A standard interface for non-fungible tokens, also known as deeds - ERC-721) + - [x] [EIP-165](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md) (Standard Interface Detection, also known as ERC-165) + - [x] [EIP-777](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-777.md) (New Advanced Token Standard, also known as ERC-777) + - [x] [EIP-820](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-820.md) (Pseudo-introspection Registry Contract, also known as ERC-820) + - [x] [EIP-888](https://github.com/ethereum/EIPs/issues/888) (MultiDimensional Token Standard, also known as ERC-888) + - [x] [EIP-1400](https://github.com/ethereum/EIPs/issues/1411) (Security Token Standard, also known as ERC-1400) + - [x] [EIP-1410](https://github.com/ethereum/EIPs/issues/1410) (Partially Fungible Token Standard, also known as ERC-1410) + - [x] [EIP-1594](https://github.com/ethereum/EIPs/issues/1594) (Core Security Token Standard, also known as ERC-1594) + - [x] [EIP-1643](https://github.com/ethereum/EIPs/issues/1643) (Document Management Standard, also known as ERC-1643) + - [x] [EIP-1644](https://github.com/ethereum/EIPs/issues/1644) (Controller Token Operation Standard, also known as ERC-1644) + - [x] [EIP-1633](https://github.com/ethereum/EIPs/issues/1634) (Re-Fungible Token, also known as ERC-1633) + - [x] [EIP-721x](https://github.com/loomnetwork/erc721x) (An extension of ERC721 that adds support for multi-fungible tokens and batch transfers, while being fully backward-compatible, also known as ERC-721x) + - [x] [EIP-1155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md) (Multi Token Standard, also known as ERC-1155) + - [x] [EIP-1376](https://github.com/ethereum/EIPs/issues/1376) (Service-Friendly Token, also known as ERC-1376) + - [x] [ST-20](https://github.com/PolymathNetwork/polymath-core) - ST-20 token is an Ethereum-based token implemented on top of the ERC-20 protocol that adds the ability for tokens to control transfers based on specific rules - [x] RLP encoding - [x] Batched requests in concurrent mode @@ -176,7 +176,7 @@ Add the following line to the Cartfile and save it: github "matter-labs/web3swift" "master" ``` -Run `carthage update` to build the framework. By default, Carthage performs checkouts and builds in a new directory 'Carthage' in the same location as your Cartfile. Open this directory, go to 'Build' directory, choose iOS or macOS directory and use framework from chosen directory in your Xcode project. +Run `carthage update` to build the framework. By default, Carthage performs checkouts and builds in a new directory 'Carthage' in the same location as your Cartfile. Open this directory, go to 'Build' directory, choose iOS or macOS directory and use the framework from the chosen directory in your Xcode project. --- @@ -184,7 +184,7 @@ Run `carthage update` to build the framework. By default, Carthage performs chec Full source please look at [Documentation folder](https://github.com/matter-labs/web3swift/blob/master/Documentation/) -Here is quick references for basic features: +Here are quick references for basic features: - [Preffered models](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-models) - [Preffered keys Wallet Model (Account)](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-keys-wallet-model-account) @@ -247,13 +247,13 @@ You can try lib by running the example project: ## Popular questions -#### Is it possible to get Mnemonic Phrase (Seed Phrase) from Private key using web3swift? +#### Is it possible to get a Mnemonic Phrase (Seed Phrase) from Private key using web3swift? In web3swift there is no backward conversion from Private key to Mnemonic Phrase. Also it is theoretically impossible to recover a phrase from a Private key. After Seed Phrase is converted to some initial entropy the “master key is derived” and the initial entropy is discarded. The simplest solution is to encrypt the phrase using users pincode and save it in some other secure keystore. Mnemonic Phrase is very sensitive data and you must be very careful to let the user get it. -Our advise if you want to show it to user - ask to save a Passphrase when creating BIP32Keystore. +Our advise if you want to show it to a user - ask to save a Passphrase when creating BIP32Keystore. #### How to interact with custom smart-contract with web3swift?