Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzushioh committed Mar 6, 2018
1 parent 1809268 commit a640a51
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 132 deletions.
139 changes: 7 additions & 132 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

EthereumKit is a Swift framework that enables you to create Ethereum wallet and use it in your app.

🚨 __EthereumKit is currently under development. not ready for the production use__ 🚨

## Features
- Mnemonic recovery phrease in [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)
- [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)/[BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) HD wallet
- [EIP55](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md) format address encoding
- See currency balance of an address.
- Get transactions of an address.
- Get transaction count of an address.
- [EIP155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md) replay attack protection
- Sign transaction

## How to Use

Expand All @@ -21,155 +18,33 @@ EthereumKit is a Swift framework that enables you to create Ethereum wallet and
```swift
let entropy = Data(hex: "000102030405060708090a0b0c0d0e0f")
let mnemonic = Mnemonic.create(entropy: entropy)
print(mnemonic)
// abandon amount liar amount expire adjust cage candy arch gather drum buyer

let seed = Mnemonic.createSeed(mnemonic: mnemonic)
print(seed.toHexString())
```

- BIP32: PrivateKey and key derivation.

```swift
// m/44'/60'/0'/0
let masterPrivateKey = PrivateKey(seed: seed, network: .main)
let purpose = masterPrivateKey.derived(at: 44, hardens: true)
let coinType = purpose.derived(at: 60, hardens: true)
let account = coinType.derived(at: 0, hardens: true)
let change = account.derived(at: 0)

// m/44'/60'/0'/0/0
let privateKey = change.derived(at: 0)
```

- Create your wallet and generate addresse.
- BIP32: Key derivation and address generation

```swift
// It generates master key pair from the seed provided.
let wallet = Wallet(seed: seed, network: .main)

let firstAddress = wallet.receiveAddress(at: 0)
let firstAddress = wallet.generateAddress(at: 0)
// 0x83f1caAdaBeEC2945b73087F803d404F054Cc2B7

let secondAddress = wallet.receiveAddress(at: 1)
let secondAddress = wallet.generateAddress(at: 1)
// 0xb3c3D923CFc4d551b38Db8A86BbA42B623D063cE

let thirdAddress = wallet.receiveAddress(at: 2)
let thirdAddress = wallet.generateAddress(at: 2)
// 0x82e35B34CfBEB9704E51Eb17f8263d919786E66a

```

- See a currenct balance of address.

```swift
let geth = Geth(network: .test)
geth.getBalance(address: "0x91c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F") { result in
// do something with `Balance`.
}
```


## Supported JSONRPC APIs

`Geth` in EthereumKit communicates with Ethereum via JSONRPC. It connects to `Ropsten` for test network and `Mainnet` for main network. (Will support localhost soon⚠️)

***

#### `GetBalance`

Return a balance of specified address based on the `BlockParameter`.

##### Parameters

1. `address` - the Address you want to get a balance of.
2. `blockParameter`: based on what block parameter you want to see a balance. default is `latest`. see the [default block parameter](#the-default-block-parameter).

##### Returns

`Balance` of specified address.

##### Example
```swift
let geth = Geth(network: .test)
geth.getAccount(address: "0x91c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F") { result in
// do something...
}
```

***

#### `GetAccount`

Returns a balance of specified address and map it to `Account` model.

##### Parameters

1. `address` - the Address you want to get a balance of.
2. `blockParameter`: based on what block parameter you want to see a balance. default is `latest`. see the [default block parameter](#the-default-block-parameter).
## Etherscan APIs

##### Returns

`Account` of specified address.

##### Example
```swift
let geth = Geth(network: .test)
geth.getAccount(address: "0x91c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F") { result in
// do something...
}
```

***

#### `GetTransactionCount`

Returns a number of transactions that a specified address has.

##### Parameters

1. `address` - the Address you want to get a balance of.
2. `blockParameter`: based on what block parameter you want to see a balance. default is `latest`. see the [default block parameter](#the-default-block-parameter).

##### Returns

A number of transactions the specified address has.

##### Example
```swift
let geth = Geth(network: .test)
geth.getTransactionCount(address: "0x91c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F") { result in
// do something...
}
```

## Etherscan API

#### `GetTransactions`

Return a list of transactions of specified address

##### Parameters

1. `address` - the Address you want to get a balance of.
2. `sort` - asc or des
3. `startblock` - from which block you want to search
4. `endblock` - to which block you want to search

##### Returns

List of `Transaction` of specified address.

##### Example
```swift
let geth = Geth(network: .test)
geth.getTransactions(address: "0x91c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F", sort: .asc, startBlock: 0, endBlock: 9999999) { result in
// do something...
}
```

## Installation
#### [Carthage](https://github.com/Carthage/Carthage)
Expand Down
25 changes: 25 additions & 0 deletions docs/Etherscan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Etherscan Requests

#### `GetTransactions`

Return a list of transactions of specified address

##### Parameters

1. `address` - the Address you want to get a balance of.
2. `sort` - asc or des
3. `startblock` - from which block you want to search
4. `endblock` - to which block you want to search

##### Returns

List of `Transaction` of specified address.

##### Example
```swift
let geth = Geth(network: .test)
geth.getTransactions(address: "0x91c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F", sort: .asc, startBlock: 0, endBlock: 9999999) { result in
// do something...
}
```
71 changes: 71 additions & 0 deletions docs/JSONRPC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
## JSONRPC Requests

#### `GetBalance`

Return a balance of specified address based on the `BlockParameter`.

##### Parameters

1. `address` - the Address you want to get a balance of.
2. `blockParameter`: based on what block parameter you want to see a balance. default is `latest`. see the [default block parameter](#the-default-block-parameter).

##### Returns

`Balance` of specified address.

##### Example
```swift
let geth = Geth(network: .test)
geth.getAccount(address: "0x91c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F") { result in
// do something...
}
```

***

#### `GetAccount`

Returns a balance of specified address and map it to `Account` model.

##### Parameters

1. `address` - the Address you want to get a balance of.
2. `blockParameter`: based on what block parameter you want to see a balance. default is `latest`. see the [default block parameter](#the-default-block-parameter).

##### Returns

`Account` of specified address.

##### Example
```swift
let geth = Geth(network: .test)
geth.getAccount(address: "0x91c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F") { result in
// do something...
}
```

***

#### `GetTransactionCount`

Returns a number of transactions that a specified address has.

##### Parameters

1. `address` - the Address you want to get a balance of.
2. `blockParameter`: based on what block parameter you want to see a balance. default is `latest`. see the [default block parameter](#the-default-block-parameter).

##### Returns

A number of transactions the specified address has.

##### Example
```swift
let geth = Geth(network: .test)
geth.getTransactionCount(address: "0x91c79f31De5208fadCbF83f0a7B0A9b6d8aBA90F") { result in
// do something...
}
```

0 comments on commit a640a51

Please sign in to comment.