Skip to content

Commit

Permalink
Merge pull request #1 from benjyz/master
Browse files Browse the repository at this point in the history
add example with keys
  • Loading branch information
miguelmota authored Jul 20, 2018
2 parents 489b6d4 + cb7081b commit c3b72c5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions example/keys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"fmt"
"log"

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

func main() {
mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
fmt.Println("deriving from mnenonic")
fmt.Println(mnemonic)
wallet, err := hdwallet.NewFromMnemonic(mnemonic)
if err != nil {
log.Fatal(err)
}

path := hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/0")
account, err := wallet.Derive(path, false)
if err != nil {
log.Fatal(err)
}

fmt.Println("account address", account.Address.Hex())

pk, _ := wallet.PrivateKeyHex(account)
fmt.Println("private key hex: ", pk)

pub, _ := wallet.PublicKeyHex(account)
fmt.Println("public key hex: ", pub)

}

0 comments on commit c3b72c5

Please sign in to comment.