Ethereum HD Wallet derivations in Go (golang) https://github.com/miguelmota/go-ethereum-hdwallet
  • Go 97.6%
  • Makefile 2.4%
Find a file
2025-10-31 23:08:48 +05:30
.github Create FUNDING.yml 2019-06-01 16:00:56 -07:00
cmd/geth-hdwallet Add initial CLI 2021-03-13 22:18:02 -08:00
example update makefile 2018-07-20 00:44:36 -07:00
.gitignore Update .gitignore 2025-04-24 15:07:35 -07:00
.goreleaser.yml Update .goreleaser.yml 2021-03-13 23:49:52 -08:00
.travis.yml Update .travis.yml 2021-07-26 00:19:34 -07:00
CONTRIBUTING.md Add CONTRIBUTING.md file with guidelines for reporting bugs, suggesting enhancements, and submitting pull requests 2025-04-24 13:29:37 -07:00
funding.json Add projectId file 2025-04-27 12:26:20 -07:00
go.mod Changed module path 2025-10-31 23:08:48 +05:30
go.sum Remove vendoring and update versions 2025-10-31 23:06:49 +05:30
Gopkg.lock dep ensure 2018-07-20 00:49:03 -07:00
Gopkg.toml dep init 2018-07-05 00:57:16 -07:00
hdwallet.go Remove vendoring and update versions 2025-10-31 23:06:49 +05:30
hdwallet_test.go Remove vendoring and update versions 2025-10-31 23:06:49 +05:30
LICENSE update readme 2019-01-19 21:01:10 -08:00
Makefile Update Makefile and README 2025-04-24 15:15:19 -07:00
README.md Update README 2025-04-27 12:11:27 -07:00


logo


go-ethereum-hdwallet

Ethereum HD Wallet derivations from [mnemonic] seed in Go (golang). Implements the go-ethereum accounts.Wallet interface.

License Build Status Go Report Card GoDoc PRs Welcome

Install

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

Documenation

https://godoc.org/github.com/miguelmota/go-ethereum-hdwallet

Getting started

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"
	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.Hex()) // 0xC49926C4124cEe1cbA0Ea94Ea31a6c12318df947

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

	fmt.Println(account.Address.Hex()) // 0x8230645aC28A4EdD1b0B53E7Cd8019744E9dD559
}

Signing transaction

package main

import (
	"log"
	"math/big"

	"github.com/davecgh/go-spew/spew"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/core/types"
	"github.com/miguelmota/go-ethereum-hdwallet"
)

func main() {
	mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
	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, true)
	if err != nil {
		log.Fatal(err)
	}

	nonce := uint64(0)
	value := big.NewInt(1000000000000000000)
	toAddress := common.HexToAddress("0x0")
	gasLimit := uint64(21000)
	gasPrice := big.NewInt(21000000000)
	var data []byte

	tx := types.NewTransaction(nonce, toAddress, value, gasLimit, gasPrice, data)
	signedTx, err := wallet.SignTx(account, tx, nil)
	if err != nil {
		log.Fatal(err)
	}

	spew.Dump(signedTx)
}

CLI

go install github.com/miguelmota/go-ethereum-hdwallet/cmd/geth-hdwallet@latest
$ geth-hdwallet -mnemonic "tag volcano eight thank tide danger coast health above argue embrace heavy" -path "m/44'/60'/0'/0/0"

public address: 0xC49926C4124cEe1cbA0Ea94Ea31a6c12318df947
private key: 63e21d10fd50155dbba0e7d3f7431a400b84b4c2ac1ee38872f82448fe3ecfb9

Development

Build CLI:

make build

Format code:

make format

Test

Run tests:

make test

Release

Git tag after committing latest changes:

git tag v0.1.x

Create a release with goreleaser:

make release

Contributing

Pull requests are welcome!

For contributions please create a new branch and submit a pull request for review.

License

Released under the MIT license.

© Miguel Mota