Skip to content

Commit

Permalink
add example with keys
Browse files Browse the repository at this point in the history
  • Loading branch information
benjyz committed Jul 11, 2018
1 parent 489b6d4 commit cb7081b
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 cb7081b

Please sign in to comment.