Giter Site home page Giter Site logo

qg5 / ethereum-hdwallet Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 87 KB

A Go library for hierarchical deterministic wallets (HD wallets) compatible with Ethereum.

License: MIT License

Go 100.00%
bip32 bip44 ethereum hd hdwallet wallet golang ethereum-hdwallet

ethereum-hdwallet's Introduction

Ethereum HDWallet

A Go library for hierarchical deterministic wallets (HD wallets) compatible with Ethereum.

Go Reference

Installation

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

Getting Started

package main

import (
	"fmt"
	"log"

	"github.com/ethereum/go-ethereum/crypto"
	"github.com/qg5/ethereum-hdwallet/ethd"
)

func main() {
	wallet, err := ethd.New("misery easy pilot elbow adapt carpet spot sword bless device tuition diet arm elite naive", "")
	if err != nil {
		log.Fatal(err)
	}

	// This will generate the following derivation path: "m/44'/60'/0'/0/1"
	path, err := ethd.CreateDerivationPath(0)
	if err != nil {
		log.Fatal(err)
	}

	derived, err := wallet.Derive(path)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Private key: 0x%x\n", crypto.FromECDSA(derived.PrivateKey)) // 0xa1abf97524bf5ed4add70cde3a7d131eec08b9ab4f7cc1e746edce7f078132c5
	fmt.Printf("Public key: 0x%x\n", crypto.CompressPubkey(&derived.PublicKey)) // 0x02717c2f423ea93de87d1589dc4aeb760c30b368bd5e8b05fc40145f5ada78b2a2
	fmt.Println("Address:", derived.Address) // 0x773d3ACc0322A90924c53536a44eF38D50CfC9D1
}

Resources

Ian Coleman BIP39

ethereum-hdwallet's People

Contributors

qg5 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.