Documentation ¶
Overview ¶
The eth package provides wrappers and functionality common to all Ethereum development.
Index ¶
- Constants
- func Ether(e int64) *big.Int
- func EtherFraction(numerator, denominator int64) *big.Int
- func NewMnemonic(bitSize int) (string, error)
- func WithPersonalMessagePrefix(message []byte) []byte
- type HDPathPrefix
- type Signer
- func (s *Signer) Address() common.Address
- func (s *Signer) Mnemonic() string
- func (s *Signer) PersonalSign(buf []byte) ([]byte, error)
- func (s *Signer) PersonalSignAddress(addr common.Address) ([]byte, error)
- func (s *Signer) PersonalSignWithNonce(buf []byte) ([]byte, [32]byte, error)
- func (s *Signer) RawSign(buf []byte) ([]byte, error)
- func (s *Signer) Sign(buf []byte) ([]byte, error)
- func (s *Signer) String() string
- func (s *Signer) TransactorWithChainID(chainID *big.Int) (*bind.TransactOpts, error)
Constants ¶
const DefaultHDPathPrefix = HDPathPrefix("m/44'/60'/0'/0/")
DefaultHDPathPrefix is the default format for derived accounts when using SignerFromSeedPhrase().
const Symbol = `Ξ`
Symbol is the ETH symbol.
Variables ¶
This section is empty.
Functions ¶
func EtherFraction ¶
EtherFraction returns numerator/denominator ETH in Wei.
func NewMnemonic ¶
NewMnemonic is a convenience wrapper around go-bip39 entropy and mnemonic creation.
func WithPersonalMessagePrefix ¶ added in v0.19.0
WithPersonalMessagePrefix converts a given message to conform to the signed data standard according to EIP-191.
Types ¶
type HDPathPrefix ¶
type HDPathPrefix string
An HDPathPrefix is a prefix for use in deriving private keys from BIP39 mnemonics. It is appended with the account number. Values MUST include a trailing slash.
func (HDPathPrefix) SignerFromPRF ¶ added in v0.21.0
SignerFromPRF deterministically derives a private key from the pseudo-random function and the input bytes. By definition, the output of a PRF is indistinguishable from a random function.
The input parameter allows for different sets of HD wallets to be derived from the same underlying PRF key. Only the PRF key need be secret.
SignerFromPRF can be thought of as a method for securely creating new mnemonic seed phrases from a single underlying key and different input parameters. Although the resulting mnemonic is accessible, SignerFromPRF is intended for use in an automated environment, which is why it relies on Google Tink.
func (HDPathPrefix) SignerFromPRFSet ¶ added in v0.21.0
SignerFromPRFSet returns hdp.SifnerFromPRF() using the set's primary PRF. This is simply a convenience function as the prf package doesn't accomodate direct creation of a prf.PRF.
func (HDPathPrefix) SignerFromSeedPhrase ¶
func (hdp HDPathPrefix) SignerFromSeedPhrase(mnemonic, password string, account uint) (*Signer, error)
SignerFromSeedPhrase confirms that the mnemonic is valid under BIP39 and then uses it to derive a private key (see HDPathF)
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
A Signer abstracts signing of arbitrary messages by wrapping an ECDSA private key and, optionally, its associated BIP39 mnemonic.
func NewSigner ¶
NewSigner is equivalent to DefaultHDPathPrefix.SignerFromSeedPhrase(NewMnemonic(), "", 0).
func (*Signer) Mnemonic ¶
Mnemonic returns the mnemonic used to derive the Signer's private key. USE WITH CAUTION.
func (*Signer) PersonalSign ¶ added in v0.19.0
PersonalSign returns an EIP-191 conform personal ECDSA signature of buf Convenience wrapper for s.CompactSign(WithPersonalMessagePrefix(buf))
func (*Signer) PersonalSignAddress ¶ added in v0.19.0
SignAddress is a convenience wrapper for s.PersonalSign(addr.Bytes()).
func (*Signer) PersonalSignWithNonce ¶ added in v0.19.0
PersonalSignWithNonce generates a 32-byte nonce with crypto/rand and returns s.PersonalSign(append(buf, nonce)).
func (*Signer) RawSign ¶
RawSign returns an ECDSA signature of buf. USE WITH CAUTION as signed data SHOULD be hashed first to avoid chosen-plaintext attacks. Prefer Signer.Sign().
func (*Signer) TransactorWithChainID ¶ added in v0.29.0
TransactorWithChainID returns bind.NewKeyedTransactorWithChainID(<key>, chainID) where <key> is the Signer's private key.