Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzushioh committed Jun 16, 2018
1 parent fdbecf5 commit 625d961
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Documentation/ERC20.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ERC20 Token

## Transfer

* Create an instance of an ERC20 token

```swift
let erc20Token = ERC20(contractAddress: "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07", decimal: 18, symbol: "OMG")
```

* Create a data parameter which will be sent with `RawTransaction` data section

**Put contract address to `RawTransaction` `to` parameter**

```swift
let parameterData: Data
do {
parameterData = try erc20Token.generateDataParameter(toAddress: "0x88b44BC83add758A3642130619D61682282850Df", amount: "100")
} catch let error {
fatalError("Error: \(error.localizedDescription)")
}

let rawTransaction = RawTransaction(
wei: "0",
to: erc20Token.contractAddress,
gasPrice: Converter.toWei(GWei: 10),
gasLimit: 21000,
nonce: 10,
data: parameterData
)
```

* Sign tx and send a parameter data with `sendRawTransaction` RPC

```swift

let tx: String
do {
tx = try wallet.sign(rawTransaction: rawTransaction)
} catch let error {
fatalError("Error: \(error.localizedDescription)")
}

geth.sendRawTransaction(rawTransaction: tx) { result in
// do something with response
}
```
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ geth.sendRawTransaction(rawTransaction: tx) { result in
## Documentations

- [Getting Started](Documentation/GettingStarted.md)
- [ERC20 Token](Documentation/ERC20.md)
- [JSONRPC API](Documentation/JSONRPC.md)
- [Etherscan API](Documentation/Etherscan.md)

Expand Down

0 comments on commit 625d961

Please sign in to comment.