Wallet

The wallet package is an implementation of the Signer interface for an ECDSA private key and it represents an Ethereum account. It supports loading the private key from different mediums.

Random

Create a random key:

key, err := wallet.GenerateKey()

Mnemonic

Create the key from a mnemonic phrase:

mnemonic := ""
key, err := wallet.NewWalletFromMnemonic(mnemonic)

PrivateKey

Create the key from a private key (in bytes):

key, err := wallet.NewWalletFromPrivKey([]byte{})

Hardware file

Create the key from an encrypted JSON wallet following the keystore format.

key, err := wallet.NewJSONWalletFromFile("./file.json")