Skip to content

Commit

Permalink
Updated KeystoreManager and fixed Carthage iOS version
Browse files Browse the repository at this point in the history
Web3 KeystoreManager is not nullable anymore
You can also use `Web3.keystoreManager.append(keystore)`
Added AGuide class where you can check some guides

Fixed carthage iOS version #262
  • Loading branch information
v57 committed Nov 19, 2018
1 parent 9928577 commit 9909ee6
Show file tree
Hide file tree
Showing 20 changed files with 621 additions and 199 deletions.
90 changes: 13 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ Don't forget to set the iOS version in a Podfile, otherwise you get an error if
```


## Documentation

> Hi. We spend a lot of time working on documentation. If you have some questions after reading it just [open an issue](https://github.com/bankex/web3swift/issues) or ask in our [discord channel](https://discord.gg/3ETv2ST). We would be happy to answer you.

Most of the classes are documented and have some examples on how to use it.

### [Read documentation in using Xcode](Documentation/Read Documentation Using Xcode.md)
### [Github Pages](https://bankex.github.io/web3swift)

#### We would appreciate it if you translate our documentation into another language, and will be happy to provide you with all the necessary information on how to do this. We will compensate you for translations that will be included in the master branch.

## Check this out
- Private key and transaction were created directly on an iOS device and sent directly to [Infura](https://infura.io) node
- Native API
Expand Down Expand Up @@ -112,11 +123,12 @@ On Rinkeby TXid = 0xc6eca60ecac004a1501a4323a10edb7fa4cd1a0896675f6b51704c84deda

## Example
You can try it yourself by running the example project:

- Clone the repo
- `cd Example/web3swiftExample`
- run `pod install` from the `Example/web3swiftExample` directory.
- `open ./web3swiftExample.xcworkspace`
-

## Communication
- if you ****need help****, use [Stack Overflow](https://stackoverflow.com/questions/tagged/web3swift) (tag 'web3swift')
- If you'd like to ****ask a general question****, use [Stack Overflow](https://stackoverflow.com/questions/tagged/web3swift).
Expand All @@ -136,82 +148,6 @@ You can try it yourself by running the example project:
- [x] Manage user's private keys through encrypted keystore abstractions
- [x] Batched requests in concurrent mode, checks balances of 580 tokens (from the latest MyEtherWallet repo) over 3 seconds

## Usage

Here's a few use cases of our library

### Initializing Ethereum address

```bash
let coldWalletAddress: Address = "0x6394b37Cf80A7358b38068f0CA4760ad49983a1B"
let constractAddress: Address = "0x45245bc59219eeaaf6cd3f382e078a461ff9de7b"
```
Ethereum addresses are checksum checked if they are not lowercased and always length checked

### Setting options

```bash
var options = Web3Options.default
// public var to: Address? = nil - to what address transaction is aimed
// public var from: Address? = nil - form what address it should be sent (either signed locally or on the node)
// public var gasLimit: BigUInt? = BigUInt(90000) - default gas limit
// public var gasPrice: BigUInt? = BigUInt(5000000000) - default gas price, quite small
// public var value: BigUInt? = BigUInt(0) - amount of WEI sent along the transaction
options.gasPrice = gasPrice
options.gasLimit = gasLimit
options.from = "0xE6877A4d8806e9A9F12eB2e8561EA6c1db19978d"
```

### Getting ETH balance

```bash
let address: Address = "0xE6877A4d8806e9A9F12eB2e8561EA6c1db19978d"
let web3Main = Web3(infura: .mainnet)
let balance: BigUInt = try web3Main.eth.getBalance(address)
```

### Getting gas price

```bash
let web3Main = Web3(infura: .mainnet)
let gasPrice: BigUInt = try web3Main.eth.getGasPrice()
```

### Getting ERC20 token balance

```bash
let contractAddress: Address = "0x45245bc59219eeaaf6cd3f382e078a461ff9de7b" // BKX token on Ethereum mainnet
let balance = try ERC20(contractAddress).balance(of: "0x6394b37Cf80A7358b38068f0CA4760ad49983a1B")
print("BKX token balance = " + String(bal))
```



### Sending ETH

```bash
let mnemonics = Mnemonics()
let keystore = try BIP32Keystore(mnemonics: mnemonics)
let keystoreManager = KeystoreManager([keystore])
let web3Rinkeby = Web3(infura: .rinkeby)
web3Rinkeby.addKeystoreManager(keystoreManager) // attach a keystore if you want to sign locally. Otherwise unsigned request will be sent to remote node
var options = Web3Options.default
options.from = keystore.addresses.first! // specify from what address you want to send it
let intermediateSend = try web3Rinkeby.contract(Web3Utils.coldWalletABI, at: coldWalletAddress).method(options: options) // an address with a private key attached in not different from any other address, just has very simple ABI
let sendResultBip32 = try intermediateSend.send(password: "BANKEXFOUNDATION")
```



### Sending ERC20

```bash
let web3 = Web3(infura: .rinkeby)
let erc20 = ERC20("0xa407dd0cbc9f9d20cdbd557686625e586c85b20a", from: yourAddress)
let result = try erc20.transfer(to: "0x6394b37Cf80A7358b38068f0CA4760ad49983a1B", amount: NaturalUnits("0.0001"))
}
```

## Global plans
- Full reference `web3js` functionality
- Light Ethereum subprotocol (LES) integration
Expand Down
2 changes: 1 addition & 1 deletion Sources/ABIv2/SolidityTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ To:


Automatically converts uint to uint256.
So return the same hash for
So it will return the same hash for
```
"transfer(address,address,uint256)"
```
Expand Down
Loading

0 comments on commit 9909ee6

Please sign in to comment.