Signers

These classes abstract away the private key, as opposed to eth_account.account.Account, which explicitly requires the private key on each usage.

All the signer classes in this package must meet the interface specified by BaseAccount.

Currently there is only one Local Signer. Some upcoming alternatives to the basic local signer include hierarchical deterministic (HD) wallets and hardware wallets.

Local Signer

class eth_account.signers.local.LocalAccount(key, account)

Bases: eth_account.signers.base.BaseAccount

A collection of convenience methods to sign and encrypt, with an embedded private key.

Variables:key (bytes) – the 32-byte private key data
>>> my_local_account.address
"0xF0109fC8DF283027b6285cc889F5aA624EaC1F55"
>>> my_local_account.key
b"\x01\x23..."

You can also get the private key by casting the account to bytes:

>>> bytes(my_local_account)
b"\\x01\\x23..."
address

The checksummed public address for this account.

>>> my_account.address
"0xF0109fC8DF283027b6285cc889F5aA624EaC1F55"
encrypt(password, kdf=None, iterations=None)

Generate a string with the encrypted key, as in encrypt(), but without a private key argument.

key

Get the private key.

privateKey

Caution

Deprecated for :var:`~eth_account.signers.local.LocalAccount.key`. This attribute will be removed in v0.5

signHash(message_hash)

Sign the hash of a message, as in signHash() but without specifying the private key.

Caution

Deprecated for sign_message(). To be removed in v0.5

Parameters:message_hash (bytes) – 32 byte hash of the message to sign
signTransaction(transaction_dict)

Caution

Deprecated for sign_transaction().

This method will be removed in v0.5

sign_message(signable_message)

Generate a string with the encrypted key, as in sign_message(), but without a private key argument.

sign_transaction(transaction_dict)

Sign a transaction, as in sign_transaction() but without specifying the private key.

Parameters:transaction_dict (dict) – transaction with all fields specified

Abstract Signer

class eth_account.signers.base.BaseAccount

Bases: abc.ABC

Abstract class that defines a collection of convenience methods to sign transactions and message hashes.

address

The checksummed public address for this account.

>>> my_account.address
"0xF0109fC8DF283027b6285cc889F5aA624EaC1F55"
signHash(message_hash)

Sign the hash of a message, as in signHash() but without specifying the private key.

Caution

Deprecated for sign_message(). To be removed in v0.5

Parameters:message_hash (bytes) – 32 byte hash of the message to sign
signTransaction(transaction_dict)

Caution

Deprecated for sign_transaction(). This method will be removed in v0.5

sign_message(signable_message: eth_account.messages.SignableMessage)

Sign the EIP-191 message, as in sign_message() but without specifying the private key.

Parameters:signable_message – The encoded message, ready for signing
sign_transaction(transaction_dict)

Sign a transaction, as in sign_transaction() but without specifying the private key.

Parameters:transaction_dict (dict) – transaction with all fields specified