-
-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from benjyz/master
add example with keys
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
} |