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.
This uses the same structure as in
encrypt()
, but without a private key argument.
-
key
¶ Get the private key.
-
signHash
(message_hash)¶ Sign the hash of a message.
This uses the same structure as in
signHash()
but without specifying the private key.Caution
Deprecated for
sign_message()
. To be removed in v0.6Parameters: message_hash (bytes) – 32 byte hash of the message to sign
-
signTransaction
(transaction_dict)¶ Sign a transaction dict.
This uses the same structure as in
sign_transaction()
but without specifying the private key.Caution
Deprecated for
sign_transaction()
. This method will be removed in v0.6Parameters: transaction_dict (dict) – transaction with all fields specified
-
sign_message
(signable_message)¶ Generate a string with the encrypted key.
This uses the same structure as in
sign_message()
, but without a private key argument.
-
sign_transaction
(transaction_dict)¶ Sign a transaction dict.
This uses the same structure 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
Specify 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.
This uses the same structure as in
signHash()
but without specifying the private key.Caution
Deprecated for
sign_message()
. To be removed in v0.6Parameters: message_hash (bytes) – 32 byte hash of the message to sign
-
signTransaction
(transaction_dict)¶ Sign a transaction dict.
This uses the same structure as in
sign_transaction()
but without specifying the private key.Caution
Deprecated for
sign_transaction()
. This method will be removed in v0.6Parameters: transaction_dict (dict) – transaction with all fields specified
-
sign_message
(signable_message: eth_account.messages.SignableMessage) → eth_account.datastructures.SignedMessage¶ Sign the EIP-191 message.
This uses the same structure 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 dict.
This uses the same structure as in
sign_transaction()
but without specifying the private key.Parameters: transaction_dict (dict) – transaction with all fields specified
-