Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Jul 5, 2018
1 parent 82eb119 commit 8d7b9bc
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
40 changes: 37 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,50 @@
# go-ethereum-hdwallet

> Ethereum HD Wallet derivations from mnemonic
> Ethereum HD Wallet derivations from mnemonic in Go (golang)
## Install

```bash
go get github.com/miguelmota/go-ethereum-hdwallet
go get -u github.com/miguelmota/go-ethereum-hdwallet
```

## Example
## Documenation

[https://godoc.org/github.com/miguelmota/go-ethereum-hdwallet](https://godoc.org/github.com/miguelmota/go-ethereum-hdwallet)

## Getting Started

```go
package main

import (
"fmt"

"github.com/miguelmota/go-ethereum-hdwallet"
)

func main() {
mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
root, _ := hdwallet.New(hdwallet.Config{
Mnemonic: mnemonic,
Path: `m/44'/60'/0'/0`,
})

wallet0, _ := root.Derive(0)
fmt.Println(wallet0.AddressHex()) // 0xC49926C4124cEe1cbA0Ea94Ea31a6c12318df947

wallet1, _ := root.Derive(1)
fmt.Println(wallet1.AddressHex()) // 0x8230645aC28A4EdD1b0B53E7Cd8019744E9dD559

wallet2, _ := root.Derive(2)
fmt.Println(wallet2.AddressHex()) // 0x65c150B7eF3B1adbB9cB2b8041C892b15eDde05A
}
```

## Test

```bash
make test
```

## License
Expand Down
19 changes: 19 additions & 0 deletions example/example.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
package main

import (
"fmt"

"github.com/miguelmota/go-ethereum-hdwallet"
)

func main() {
mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
root, _ := hdwallet.New(hdwallet.Config{
Mnemonic: mnemonic,
Path: `m/44'/60'/0'/0`,
})

wallet0, _ := root.Derive(0)
fmt.Println(wallet0.AddressHex()) // 0xC49926C4124cEe1cbA0Ea94Ea31a6c12318df947

wallet1, _ := root.Derive(1)
fmt.Println(wallet1.AddressHex()) // 0x8230645aC28A4EdD1b0B53E7Cd8019744E9dD559

wallet2, _ := root.Derive(2)
fmt.Println(wallet2.AddressHex()) // 0x65c150B7eF3B1adbB9cB2b8041C892b15eDde05A
}

0 comments on commit 8d7b9bc

Please sign in to comment.