Skip to content

Commit 3eefe38

Browse files
committed
resrtuct the readme
1 parent f656172 commit 3eefe38

File tree

1 file changed

+35
-15
lines changed

1 file changed

+35
-15
lines changed

README.md

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ Here's a few use cases of our library:
132132
Create keystore and account with password.
133133

134134
```
135+
//TODO
135136
```
136137

137138
### Initializing Ethereum address
@@ -162,28 +163,35 @@ let balanceResult = web3Main.eth.getBalance(address)
162163
guard case .success(let balance) = balanceResult else {return}
163164
```
164165
### Getting gas price
165-
```let web3Main = Web3.InfuraMainnetWeb3()
166+
```
167+
let web3Main = Web3.InfuraMainnetWeb3()
166168
let gasPriceResult = web3Main.eth.getGasPrice()
167169
guard case .success(let gasPrice) = gasPriceResult else {return}
168170
```
169-
### Getting ERC20 token balance
170-
```let contractAddress = EthereumAddress("0x45245bc59219eeaaf6cd3f382e078a461ff9de7b")! // BKX token on Ethereum mainnet
171-
let contract = web3.contract(Web3.Utils.erc20ABI, at: contractAddress, abiVersion: 2)! // utilize precompiled ERC20 ABI for your concenience
172-
guard let bkxBalanceResult = contract.method("balanceOf", parameters: [coldWalletAddress] as [AnyObject], options: options)?.call(options: nil) else {return} // encode parameters for transaction
173-
guard case .success(let bkxBalance) = bkxBalanceResult, let bal = bkxBalance["0"] as? BigUInt else {return} // bkxBalance is [String: Any], and parameters are enumerated as "0", "1", etc in order of being returned. If returned parameter has a name in ABI, it is also duplicated
174-
print("BKX token balance = " + String(bal))
175-
```
176171

177172
### Sending ETH
178-
```let web3Rinkeby = Web3.InfuraRinkebyWeb3()
173+
```
174+
let web3Rinkeby = Web3.InfuraRinkebyWeb3()
179175
web3Rinkeby.addKeystoreManager(bip32keystoreManager) // attach a keystore if you want to sign locally. Otherwise unsigned request will be sent to remote node
180176
options.from = bip32ks?.addresses?.first! // specify from what address you want to send it
181177
intermediateSend = web3Rinkeby.contract(Web3.Utils.coldWalletABI, at: coldWalletAddress, abiVersion: 2)!.method(options: options)! // an address with a private key attached in not different from any other address, just has very simple ABI
182178
let sendResultBip32 = intermediateSend.send(password: "changeme")
183179
```
184180

185-
### Sending ERC20
186-
```var convenienceTransferOptions = Web3Options.defaultOptions()
181+
### ERC20 Iteraction:
182+
183+
#### Getting ERC20 token balance
184+
```
185+
let contractAddress = EthereumAddress("0x45245bc59219eeaaf6cd3f382e078a461ff9de7b")! // BKX token on Ethereum mainnet
186+
let contract = web3.contract(Web3.Utils.erc20ABI, at: contractAddress, abiVersion: 2)! // utilize precompiled ERC20 ABI for your concenience
187+
guard let bkxBalanceResult = contract.method("balanceOf", parameters: [coldWalletAddress] as [AnyObject], options: options)?.call(options: nil) else {return} // encode parameters for transaction
188+
guard case .success(let bkxBalance) = bkxBalanceResult, let bal = bkxBalance["0"] as? BigUInt else {return} // bkxBalance is [String: Any], and parameters are enumerated as "0", "1", etc in order of being returned. If returned parameter has a name in ABI, it is also duplicated
189+
print("BKX token balance = " + String(bal))
190+
```
191+
192+
#### Sending ERC20
193+
```
194+
var convenienceTransferOptions = Web3Options.defaultOptions()
187195
convenienceTransferOptions.gasPrice = gasPriceRinkeby
188196
let convenienceTokenTransfer = web3Rinkeby.eth.sendERC20tokensWithNaturalUnits(tokenAddress: EthereumAddress("0xa407dd0cbc9f9d20cdbd557686625e586c85b20a")!, from: (ks?.addresses?.first!)!, to: EthereumAddress("0x6394b37Cf80A7358b38068f0CA4760ad49983a1B")!, amount: "0.0001", options: convenienceTransferOptions) // there are also convenience functions to send ETH and ERC20 under the .eth structure
189197
let gasEstimateResult = convenienceTokenTransfer!.estimateGas(options: nil)
@@ -199,16 +207,28 @@ switch convenienceTransferResult {
199207
}
200208
```
201209

202-
## Global plans
203-
- Full reference `web3js` functionality
204-
- Light Ethereum subprotocol (LES) integration
210+
## [Apps using this library](https://github.com/matterinc/web3swift/wiki/Apps-using-web3swift)
211+
212+
If you are using `web3swift` in your app or know of an app that uses it, please add it to this list. It would be much appreciated! 👍
205213

206-
## [Apps using this library](https://github.com/matterinc/web3swift/wiki/Apps-using-web3swift)
214+
* [MEWconnect-iOS](https://github.com/MyEtherWallet/MEWconnect-iOS)
215+
* [Peepeth iOS client](https://github.com/matterinc/PeepethClient)
216+
* [Ethereum & ERC20Tokens Wallet](https://itunes.apple.com/us/app/ethereum-erc20tokens-wallet/id1386738877?ls=1&mt=8)
217+
* [BankexWallet](https://github.com/BANKEX/Pay-iOS)
218+
* [YOUR APP CAN BE THERE (click me)](https://github.com/matterinc/web3swift/issues) :wink:
207219

208220
If you've used this project in a live app, please let us know!
209221

210222
*If you are using `web3swift` in your app or know of an app that uses it, please add it to [this](https://github.com/matterinc/web3swift/wiki/Apps-using-web3swift) list.*
211223

224+
225+
226+
## Future plans
227+
228+
- Full reference `web3js` functionality
229+
- Light Ethereum subprotocol (LES) integration
230+
231+
212232
## Special thanks to
213233

214234
- Gnosis team and their library [Bivrost-swift](https://github.com/gnosis/bivrost-swift) for inspiration for the ABI decoding approach

0 commit comments

Comments
 (0)