ETH_ACCOUNT(1)

NAME
eth_account - eth-account Documentation

Sign Ethereum transactions and messages with local private keys

INSTALLATION

    python -m pip install eth-account

  eth_account

  Account

class eth_account.account.Account
    The primary entry point for working with Ethereum private keys.

    It does not require a connection to an Ethereum node.

create(extra_entropy: str <https://docs.python.org/3.10/library/stdtypes.html#str> | bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | int <https://docs.python.org/3.10/library/functions.html#int> = '') -> LocalAccount <#eth_account.signers.local.LocalAccount>
    Creates a new private key, and returns it as a LocalAccount.

Parameters
    extra_entropy (str <https://docs.python.org/3.10/library/stdtypes.html#str> or bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> or int <https://docs.python.org/3.10/library/functions.html#int>) -- Add extra randomness to whatever randomness your OS can provide

Returns
    an object with private key and convenience methods

        >>> from eth_account import Account
        >>> acct = Account.create('KEYSMASH FJAFJKLDSKF7JKFDJ 1530')
        >>> acct.address
        '0x5ce9454909639D2D17A3F753ce7d93fa0b9aB12E'
        >>> acct.key
        HexBytes('0x8676e9a8c86c8921e922e61e0bb6e9e9689aad4c99082620610b00140e5f21b8')
        # These methods are also available: sign_message(), sign_transaction(),
        # encrypt().
        # They correspond to the same-named methods in Account.*
        # but without the private key argument

create_with_mnemonic(passphrase: str <https://docs.python.org/3.10/library/stdtypes.html#str> = '', num_words: int <https://docs.python.org/3.10/library/functions.html#int> = 12, language: Language = Language.ENGLISH, account_path: str <https://docs.python.org/3.10/library/stdtypes.html#str> = "m/44'/60'/0'/0/0") -> tuple <https://docs.python.org/3.10/library/stdtypes.html#tuple>[LocalAccount <#eth_account.signers.local.LocalAccount>, str <https://docs.python.org/3.10/library/stdtypes.html#str>]
    Create a new private key and related mnemonic.

    Caution: This feature is experimental, unaudited, and likely to change soon

    Creates a new private key, and returns it as a LocalAccount, alongside the mnemonic that can used to regenerate it using any BIP39-compatible wallet.

Parameters

•   passphrase (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- Extra passphrase to encrypt the seed phrase

•   num_words (int <https://docs.python.org/3.10/library/functions.html#int>) -- Number of words to use with seed phrase. Default is 12 words. Must be one of [12, 15, 18, 21, 24].

•   language (Language) -- Language to use for BIP39 mnemonic seed phrase.

•   account_path (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- Specify an alternate HD path for deriving the seed using BIP32 HD wallet key derivation.

Returns
    A tuple consisting of an object with private key and convenience methods, and the mnemonic seed phrase that can be used to restore the account.

Return type
    (LocalAccount <#eth_account.signers.local.LocalAccount>, str <https://docs.python.org/3.10/library/stdtypes.html#str>)

        >>> from eth_account import Account
        >>> Account.enable_unaudited_hdwallet_features()
        >>> acct, mnemonic = Account.create_with_mnemonic()
        >>> acct.address
        '0x5ce9454909639D2D17A3F753ce7d93fa0b9aB12E'
        >>> acct == Account.from_mnemonic(mnemonic)
        True
        # These methods are also available:
        # sign_message(), sign_transaction(), encrypt()
        # They correspond to the same-named methods in Account.*
        # but without the private key argument

static decrypt(keyfile_json: str <https://docs.python.org/3.10/library/stdtypes.html#str> | dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>], password: str <https://docs.python.org/3.10/library/stdtypes.html#str>) -> HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>
    Decrypts a private key.

    The key may have been encrypted using an Ethereum client or encrypt().

Parameters

•   keyfile_json (dict <https://docs.python.org/3.10/library/stdtypes.html#dict> or str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- The encrypted key

•   password (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- The password that was used to encrypt the key

Returns
    the raw private key

Return type
    HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>

        >>> encrypted = {
        ...     "address": "5ce9454909639D2D17A3F753ce7d93fa0b9aB12E",
        ...     "crypto": {
        ...         "cipher": "aes-128-ctr",
        ...         "cipherparams": {"iv": "482ef54775b0cc59f25717711286f5c8"},
        ...         "ciphertext": "cb636716a9fd46adbb31832d964df2082536edd5399a3393327dc89b0193a2be",
        ...         "kdf": "scrypt",
        ...         "kdfparams": {},
        ...         "kdfparams": {
        ...             "dklen": 32,
        ...             "n": 262144,
        ...             "p": 8,
        ...             "r": 1,
        ...             "salt": "d3c9a9945000fcb6c9df0f854266d573",
        ...         },
        ...         "mac": "4f626ec5e7fea391b2229348a65bfef532c2a4e8372c0a6a814505a350a7689d",
        ...     },
        ...     "id": "b812f3f9-78cc-462a-9e89-74418aa27cb0",
        ...     "version": 3,
        ... }
        >>> Account.decrypt(encrypted, "password")
        HexBytes('0xb25c7db31feed9122727bf0939dc769a96564b2de4c4726d035b36ecf1e5b364')

classmethod enable_unaudited_hdwallet_features() -> None <https://docs.python.org/3.10/library/constants.html#None>
    Use this flag to enable unaudited HD Wallet features.

classmethod encrypt(private_key: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | int <https://docs.python.org/3.10/library/functions.html#int> | HexStr | PrivateKey, password: str <https://docs.python.org/3.10/library/stdtypes.html#str>, kdf: Literal <https://docs.python.org/3.10/library/typing.html#typing.Literal>['pbkdf2', 'scrypt'] | None <https://docs.python.org/3.10/library/constants.html#None> = None, iterations: int <https://docs.python.org/3.10/library/functions.html#int> | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]
    Creates a dictionary with an encrypted version of your private key. To import this keyfile into Ethereum clients like geth and parity: encode this dictionary with json.dumps() <https://docs.python.org/3.10/library/json.html#json.dumps> and save it to disk where your client keeps key files.

Parameters

•   private_key (hex str, bytes, int or eth_keys.datatypes.PrivateKey) -- The raw private key

•   password (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- The password which you will need to unlock the account in your client

•   kdf (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- The key derivation function to use when encrypting your private key

•   iterations (int <https://docs.python.org/3.10/library/functions.html#int>) -- The work factor for the key derivation function

Returns
    The data to use in your encrypted file

Return type
    dict <https://docs.python.org/3.10/library/stdtypes.html#dict>

    If kdf is not set, the default key derivation function falls back to the environment variable ETH_ACCOUNT_KDF. If that is not set, then 'scrypt' will be used as the default.

        >>> from pprint import pprint
        >>> encrypted = Account.encrypt(
        ...     0xB25C7DB31FEED9122727BF0939DC769A96564B2DE4C4726D035B36ECF1E5B364,
        ...     "password",
        ... )
        >>> pprint(encrypted)
        {'address': '5ce9454909639D2D17A3F753ce7d93fa0b9aB12E',
         'crypto': {'cipher': 'aes-128-ctr',
                    'cipherparams': {'iv': '...'},
                    'ciphertext': '...',
                    'kdf': 'scrypt',
                    'kdfparams': {'dklen': 32,
                                  'n': 262144,
                                  'p': 1,
                                  'r': 8,
                                  'salt': '...'},
                    'mac': '...'},
         'id': '...',
         'version': 3}
        >>> with open("my-keyfile", "w") as f:
        ...     f.write(json.dumps(encrypted))

from_key(private_key: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | int <https://docs.python.org/3.10/library/functions.html#int> | HexStr | PrivateKey) -> LocalAccount <#eth_account.signers.local.LocalAccount>
    Returns a convenient object for working with the given private key.

Parameters
    private_key (hex str, bytes, int or eth_keys.datatypes.PrivateKey) -- The raw private key

Returns
    object with methods for signing and encrypting

Return type
    LocalAccount <#eth_account.signers.local.LocalAccount>

        >>> acct = Account.from_key(
        ...     0xB25C7DB31FEED9122727BF0939DC769A96564B2DE4C4726D035B36ECF1E5B364
        ... )
        >>> acct.address
        '0x5ce9454909639D2D17A3F753ce7d93fa0b9aB12E'
        >>> acct.key
        HexBytes('0xb25c7db31feed9122727bf0939dc769a96564b2de4c4726d035b36ecf1e5b364')
        # These methods are also available: sign_message(), sign_transaction(),
        # encrypt(). They correspond to the same-named methods in Account.*
        # but without the private key argument

from_mnemonic(mnemonic: str <https://docs.python.org/3.10/library/stdtypes.html#str>, passphrase: str <https://docs.python.org/3.10/library/stdtypes.html#str> = '', account_path: str <https://docs.python.org/3.10/library/stdtypes.html#str> = "m/44'/60'/0'/0/0") -> LocalAccount <#eth_account.signers.local.LocalAccount>
    Generate an account from a mnemonic.

    Caution: This feature is experimental, unaudited, and likely to change soon

Parameters

•   mnemonic (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- space-separated list of BIP39 mnemonic seed words

•   passphrase (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- Optional passphrase used to encrypt the mnemonic

•   account_path (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- Specify an alternate HD path for deriving the seed using BIP32 HD wallet key derivation.

Returns
    object with methods for signing and encrypting

Return type
    LocalAccount <#eth_account.signers.local.LocalAccount>

        >>> from eth_account import Account
        >>> Account.enable_unaudited_hdwallet_features()
        >>> acct = Account.from_mnemonic(
        ...     "coral allow abandon recipe top tray caught video climb similar "
        ...     "prepare bracket antenna rubber announce gauge volume "
        ...     "hub hood burden skill immense add acid"
        ... )
        >>> acct.address
        '0x9AdA5dAD14d925f4df1378409731a9B71Bc8569d'
        # These methods are also available: sign_message(), sign_transaction(),
        #  encrypt(). They correspond to the same-named methods in Account.*
        # but without the private key argument

    Or, generate multiple accounts from a mnemonic.

        >>> from eth_account import Account
        >>> Account.enable_unaudited_hdwallet_features()
        >>> iterator = 0
        >>> for i in range(10):
        ...     acct = Account.from_mnemonic(
        ...         "health embark april buyer eternal leopard "
        ...         "want before nominee head thing tackle",
        ...         account_path=f"m/44'/60'/0'/0/{iterator}",
        ...     )
        ...     iterator = iterator + 1
        ...     acct.address
        '0x61Cc15522D06983Ac7aADe23f9d5433d38e78195'
        '0x1240460F6E370f28079E5F9B52f9DcB759F051b7'
        '0xd30dC9f996539826C646Eb48bb45F6ee1D1474af'
        '0x47e64beb58c9A469c5eD086aD231940676b44e7C'
        '0x6D39032ffEF9987988a069F52EFe4d95D0770555'
        '0x3836A6530D1889853b047799Ecd8827255072e77'
        '0xed5490dEfF8d8FfAe45cb4066C3daC7C6BFF6a22'
        '0xf04F9Ff322799253bcC6B12762AD127570a092c5'
        '0x900F7fa9fbe85BB25b6cdB94Da24D807f7feb213'
        '0xa248e118b0D19010387b1B768686cd9B473FA137'

    Caution: For the love of Bob please do not use this mnemonic, it is for testing purposes only.

recover_message(signable_message: SignableMessage <#eth_account.messages.SignableMessage>, vrs: tuple <https://docs.python.org/3.10/library/stdtypes.html#tuple>[VRS, VRS, VRS] | None <https://docs.python.org/3.10/library/constants.html#None> = None, signature: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> ChecksumAddress
    Get the address of the account that signed the given message. You must specify exactly one of: vrs or signature

Parameters

•   signable_message -- the message that was signed

•   vrs (tuple <https://docs.python.org/3.10/library/stdtypes.html#tuple>(v, r <#eth_account.datastructures.SignedSetCodeAuthorization.r>, s <#eth_account.datastructures.SignedSetCodeAuthorization.s>), each element is hex str, bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> or int <https://docs.python.org/3.10/library/functions.html#int>) -- the three pieces generated by an elliptic curve signature

•   signature (hex str or bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> or int <https://docs.python.org/3.10/library/functions.html#int>) -- signature bytes concatenated as r+s+v

Returns
    address of signer, hex-encoded & checksummed

Return type
    str <https://docs.python.org/3.10/library/stdtypes.html#str>

        >>> from eth_account.messages import encode_defunct
        >>> from eth_account import Account
        >>> message = encode_defunct(text="I♥SF")
        >>> vrs = (
        ...     28,
        ...     "0xe6ca9bba58c88611fad66a6ce8f996908195593807c4b38bd528d2cff09d4eb3",
        ...     "0x3e5bfbbf4d3e39b1a2fd816a7680c19ebebaf3a141b239934ad43cb33fcec8ce",
        ... )
        >>> Account.recover_message(message, vrs=vrs)
        '0x5ce9454909639D2D17A3F753ce7d93fa0b9aB12E'
        # All of these recover calls are equivalent:
        # variations on vrs
        >>> vrs = (
        ...     "0x1c",
        ...     "0xe6ca9bba58c88611fad66a6ce8f996908195593807c4b38bd528d2cff09d4eb3",
        ...     "0x3e5bfbbf4d3e39b1a2fd816a7680c19ebebaf3a141b239934ad43cb33fcec8ce",
        ... )
        >>> Account.recover_message(message, vrs=vrs)
        '0x5ce9454909639D2D17A3F753ce7d93fa0b9aB12E'
        >>> # Caution about this approach: likely problems if there are leading 0s
        >>> vrs = (
        ...     0x1C,
        ...     0xE6CA9BBA58C88611FAD66A6CE8F996908195593807C4B38BD528D2CFF09D4EB3,
        ...     0x3E5BFBBF4D3E39B1A2FD816A7680C19EBEBAF3A141B239934AD43CB33FCEC8CE,
        ... )
        >>> Account.recover_message(message, vrs=vrs)
        '0x5ce9454909639D2D17A3F753ce7d93fa0b9aB12E'
        >>> vrs = (
        ...     b"\x1c",
        ...     b"\xe6\xca\x9b\xbaX\xc8\x86\x11\xfa\xd6jl\xe8\xf9\x96\x90\x81\x95Y8\x07\xc4\xb3\x8b\xd5(\xd2\xcf\xf0\x9dN\xb3",
        ...     b">[\xfb\xbfM>9\xb1\xa2\xfd\x81jv\x80\xc1\x9e\xbe\xba\xf3\xa1A\xb29\x93J\xd4<\xb3?\xce\xc8\xce",
        ... )
        >>> Account.recover_message(message, vrs=vrs)
        '0x5ce9454909639D2D17A3F753ce7d93fa0b9aB12E'
        # variations on signature
        >>> signature = "0xe6ca9bba58c88611fad66a6ce8f996908195593807c4b38bd528d2cff09d4eb33e5bfbbf4d3e39b1a2fd816a7680c19ebebaf3a141b239934ad43cb33fcec8ce1c"
        >>> Account.recover_message(message, signature=signature)
        '0x5ce9454909639D2D17A3F753ce7d93fa0b9aB12E'
        >>> signature = b"\xe6\xca\x9b\xbaX\xc8\x86\x11\xfa\xd6jl\xe8\xf9\x96\x90\x81\x95Y8\x07\xc4\xb3\x8b\xd5(\xd2\xcf\xf0\x9dN\xb3>[\xfb\xbfM>9\xb1\xa2\xfd\x81jv\x80\xc1\x9e\xbe\xba\xf3\xa1A\xb29\x93J\xd4<\xb3?\xce\xc8\xce\x1c"
        >>> Account.recover_message(message, signature=signature)
        '0x5ce9454909639D2D17A3F753ce7d93fa0b9aB12E'
        >>> # Caution about this approach: likely problems if there are leading 0s
        >>> signature = 0xE6CA9BBA58C88611FAD66A6CE8F996908195593807C4B38BD528D2CFF09D4EB33E5BFBBF4D3E39B1A2FD816A7680C19EBEBAF3A141B239934AD43CB33FCEC8CE1C
        >>> Account.recover_message(message, signature=signature)
        '0x5ce9454909639D2D17A3F753ce7d93fa0b9aB12E'

recover_transaction(serialized_transaction: HexStr | bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | int <https://docs.python.org/3.10/library/functions.html#int>) -> ChecksumAddress
    Get the address of the account that signed this transaction.

Parameters
    serialized_transaction (hex str, bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> or int <https://docs.python.org/3.10/library/functions.html#int>) -- the complete signed transaction

Returns
    address of signer, hex-encoded & checksummed

Return type
    ChecksumAddress

        >>> raw_transaction = "0xf86a8086d55698372431831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca008025a009ebb6ca057a0535d6186462bc0b465b561c94a295bdb0621fc19208ab149a9ca0440ffd775ce91a833ab410777204d5341a6f9fa91216a6f3ee2c051fea6a0428"
        >>> Account.recover_transaction(raw_transaction)
        '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23'

set_key_backend(backend: CoinCurveECCBackend | NativeECCBackend) -> None <https://docs.python.org/3.10/library/constants.html#None>
    Change the backend used by the underlying eth-keys library.

    (The default is fine for most users)

Parameters
    backend -- any backend that works in eth_keys.KeyApi(backend) <https://github.com/ethereum/eth-keys/#keyapibackendnone>

sign_authorization(authorization_dict: AuthorizationDict, private_key: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | int <https://docs.python.org/3.10/library/functions.html#int> | HexStr | PrivateKey) -> SignedSetCodeAuthorization <#eth_account.datastructures.SignedSetCodeAuthorization>
    Sign an authorization using a local private key to be included in a EIP-7702 transaction.

Parameters

•   authorization_dict (dict <https://docs.python.org/3.10/library/stdtypes.html#dict>) -- the required keys are: chainId, address, and nonce

•   private_key (hex str, bytes, int or eth_keys.datatypes.PrivateKey) -- the private key to sign the data with

Returns
    the dictionary with the signature fields added, suitable for inclusion in a EIP-7702 transaction

Return type
    dict <https://docs.python.org/3.10/library/stdtypes.html#dict>

    Note: You need to sign one or more authorizations from an EOA willing to have a smart contract code associated with the EOA for the life of the transaction. The variable auth in the code below is the authorization dictionary containing the following keys:

•   chainId is the chain id for the chain where the EOA is located. If 0 is specified, authorization is signed for all chains

•   address is the address of the smart contract code to be associated with the EOA, as bytes

•   nonce is the nonce of the EOA, used to prevent replay attacks

    To create a transaction that associates the code with the EOA, you need to create a transaction with an authorizationList, representing a list of signed authorizations for the transaction.

        >>> from eth_account import Account
        >>> key = (
        ...     "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        ... )
        >>> auth = {
        ...     "chainId": 1337,
        ...     "address": "0x5ce9454909639d2d17a3f753ce7d93fa0b9ab12e",
        ...     # If the tx sender is the same as the authority, the nonce needs to be 1 higher than the current (transaction) nonce.
        ...     # This is because the nonce is increased before tx execution and again when processing the authorization.
        ...     "nonce": 1,
        ... }
        >>> signed_auth = Account.sign_authorization(auth, key)
        >>> signed_auth
        SignedSetCodeAuthorization(chain_id=1337,
         address=b'\\\xe9EI\tc\x9d-\x17\xa3\xf7S\xce}\x93\xfa\x0b\x9a\xb1.',
         nonce=1,
         y_parity=0,
         r=52163433520757118830640642673035732532535423029712132518776649895118143897479,
         s=57576671166887700066365341925867052133948674355067837907255957076179513983345,
         signature='0x735375048fc96b87390b5a11c411fc57245d8e55038bf49e659d048a0d1a3f877f4b3db448845cb217812f23c6b345e99f2d21c44ec10e93a8f039814167417100',
         authorization_hash=HexBytes('0x9026f77ed6740d6d08f0cdc0591a86b2232700020a816718fbf760785e9ca2f2'))
        >>> tx = {
        ...     "gas": 100000,
        ...     "maxFeePerGas": 2000000000,
        ...     "maxPriorityFeePerGas": 2000000000,
        ...     "data": "0x252dba42",  # replace with calldata for the contract at the auth ``address``
        ...     "nonce": 0,
        ...     "to": "0x09616C3d61b3331fc4109a9E41a8BDB7d9776609",
        ...     "value": 0,
        ...     "accessList": (),
        ...     "authorizationList": [signed_auth],
        ...     "chainId": 1337,
        ... }
        >>> signed = Account.sign_transaction(tx, key)
        >>> w3.eth.send_raw_transaction(signed.raw_transaction)

sign_message(signable_message: SignableMessage <#eth_account.messages.SignableMessage>, private_key: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | int <https://docs.python.org/3.10/library/functions.html#int> | HexStr | PrivateKey) -> SignedMessage <#eth_account.datastructures.SignedMessage>
    Sign the provided message.

    This API supports any messaging format that will encode to EIP-191 messages.

    If you would like historical compatibility with w3.eth.sign() <https://web3py.readthedocs.io/en/latest/web3.eth.html#web3.eth.Eth.sign> you can use encode_defunct().

    Other options are the "validator", or "structured data" standards. You can import all supported message encoders in eth_account.messages.

Parameters

•   signable_message -- the encoded message for signing

•   private_key (hex str, bytes, int or eth_keys.datatypes.PrivateKey) -- the key to sign the message with

Returns
    Various details about the signature - most importantly the fields: v, r, and s

Return type
    SignedMessage <#eth_account.datastructures.SignedMessage>

        >>> msg = "I♥SF"
        >>> from eth_account.messages import encode_defunct
        >>> msghash = encode_defunct(text=msg)
        >>> msghash
        SignableMessage(version=b'E',
         header=b'thereum Signed Message:\n6',
         body=b'I\xe2\x99\xa5SF')
        >>> # If you're curious about the internal fields of SignableMessage, take a look at EIP-191, linked above
        >>> key = (
        ...     "0xb25c7db31feed9122727bf0939dc769a96564b2de4c4726d035b36ecf1e5b364"
        ... )
        >>> Account.sign_message(msghash, key)
        SignedMessage(message_hash=HexBytes('0x1476abb745d423bf09273f1afd887d951181d25adc66c4834a70491911b7f750'),
         r=104389933075820307925104709181714897380569894203213074526835978196648170704563,
         s=28205917190874851400050446352651915501321657673772411533993420917949420456142,
         v=28,
         signature=HexBytes('0xe6ca9bba58c88611fad66a6ce8f996908195593807c4b38bd528d2cff09d4eb33e5bfbbf4d3e39b1a2fd816a7680c19ebebaf3a141b239934ad43cb33fcec8ce1c'))

sign_transaction(transaction_dict: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Sequence <https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sequence>[AccessListEntry] | bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | HexStr | int <https://docs.python.org/3.10/library/functions.html#int>], private_key: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | int <https://docs.python.org/3.10/library/functions.html#int> | HexStr | PrivateKey, blobs: Sequence <https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sequence>[bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>] | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> SignedTransaction <#eth_account.datastructures.SignedTransaction>
    Sign a transaction using a local private key.

    It produces signature details and the hex-encoded transaction suitable for broadcast using w3.eth.send_raw_transaction() <https://web3py.readthedocs.io/en/latest/web3.eth.html#web3.eth.Eth.send_raw_transaction>.

    To create the transaction dict that calls a contract, use my_contract.functions.myFunction().build_transaction() <https://web3py.readthedocs.io/en/latest/web3.contract.html#web3.contract.ContractFunction.build_transaction>.

    Note: For non-legacy (typed) transactions, if the transaction type is not explicitly provided, it may be determined from the transaction parameters of a well-formed transaction. See below for examples on how to sign with different transaction types.

Parameters

•   transaction_dict (dict <https://docs.python.org/3.10/library/stdtypes.html#dict>) -- the transaction with available keys, depending on the type of transaction: nonce, chainId, to, data, value, gas, gasPrice, type, accessList, maxFeePerGas, and maxPriorityFeePerGas

•   private_key (hex str, bytes, int or eth_keys.datatypes.PrivateKey) -- the private key to sign the data with

•   blobs (list <https://docs.python.org/3.10/library/stdtypes.html#list> of bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> or HexBytes) -- optional list of blobs to sign in addition to the transaction

Returns
    Various details about the signature - most importantly the fields: v, r, and s

Return type
    SignedTransaction <#eth_account.datastructures.SignedTransaction>

        >>> # EIP-1559 dynamic fee transaction (more efficient and preferred over legacy txn)
        >>> from eth_account import Account
        >>> dynamic_fee_transaction = {
        ...     "type": 2,  # optional - can be implicitly determined based on max fee params
        ...     "gas": 100000,
        ...     "maxFeePerGas": 2000000000,
        ...     "maxPriorityFeePerGas": 2000000000,
        ...     "data": "0x616263646566",
        ...     "nonce": 34,
        ...     "to": "0x09616C3d61b3331fc4109a9E41a8BDB7d9776609",
        ...     "value": "0x5af3107a4000",
        ...     "accessList": (  # optional
        ...         {
        ...             "address": "0x0000000000000000000000000000000000000001",
        ...             "storageKeys": (
        ...                 "0x0100000000000000000000000000000000000000000000000000000000000000",
        ...             ),
        ...         },
        ...     ),
        ...     "chainId": 1337,
        ... }
        >>> key = (
        ...     "0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318"
        ... )
        >>> signed_df_tx = Account.sign_transaction(dynamic_fee_transaction, key)
        >>> signed_df_tx
        SignedTransaction(raw_transaction=HexBytes('0x02f8b28205392284773594008477359400830186a09409616c3d61b3331fc4109a9e41a8bdb7d9776609865af3107...d58b85d5'),
         hash=HexBytes('0x2721b2ac99d878695e410af9e8968859b6f6e94f544840be0eb2935bead7deba'),
         r=48949965662841329840326477994465373664672499148507933176648302825256944281697,
         s=1123041608316060268133200864147951676126406077675157976022772782796802590165,
         v=1)
        >>> w3.eth.send_raw_transaction(
        ...     signed_df_tx.raw_transaction
        ... )

        >>> # legacy transaction (less efficient than EIP-1559 dynamic fee txn)
        >>> from eth_account import Account
        >>> legacy_transaction = {
        ...     # Note that the address must be in checksum format or native bytes:
        ...     "to": "0xF0109fC8DF283027b6285cc889F5aA624EaC1F55",
        ...     "value": 1000000000,
        ...     "gas": 2000000,
        ...     "gasPrice": 234567897654321,
        ...     "nonce": 0,
        ...     "chainId": 1337,
        ... }
        >>> key = (
        ...     "0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318"
        ... )
        >>> signed_legacy_tx = Account.sign_transaction(legacy_transaction, key)
        >>> signed_legacy_tx
        SignedTransaction(raw_transaction=HexBytes('0xf86c8086d55698372431831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080820a95a01a7...c0bfdb52'),
         hash=HexBytes('0xd0a3e5dc7439f260c64cb0220139ec5dc7e016f82ce272a25a0f0b38fe751673'),
         r=11971260903864915610009019893820767192081275151191539081612245320300335068143,
         s=35365272040292958794699923036506252105590820339897221552886630515981233937234,
         v=2709)
        >>> w3.eth.send_raw_transaction(
        ...     signed_legacy_tx.raw_transaction
        ... )

        >>> from eth_account import Account
        >>> access_list_transaction = {
        ...     "type": 1,  # optional - can be implicitly determined based on 'accessList' and 'gasPrice' params
        ...     "gas": 100000,
        ...     "gasPrice": 1000000000,
        ...     "data": "0x616263646566",
        ...     "nonce": 34,
        ...     "to": "0x09616C3d61b3331fc4109a9E41a8BDB7d9776609",
        ...     "value": "0x5af3107a4000",
        ...     "accessList": (
        ...         {
        ...             "address": "0x0000000000000000000000000000000000000001",
        ...             "storageKeys": (
        ...                 "0x0100000000000000000000000000000000000000000000000000000000000000",
        ...             ),
        ...         },
        ...     ),
        ...     "chainId": 1337,
        ... }
        >>> key = (
        ...     "0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318"
        ... )
        >>> signed_al_tx = Account.sign_transaction(access_list_transaction, key)
        >>> signed_al_tx
        SignedTransaction(raw_transaction=HexBytes('0x01f8ad82053922843b9aca00830186a09409616c3d61b3331fc4109a9e41a8bdb7d9776609865af3107a400086616...2b5043ea'),
         hash=HexBytes('0xca9af2ef41691e06eb07e02125938fd9bb5a311e8daf330b264e77d6cdf3d17e'),
         r=107355854401379915513092408112372039746594668141865279802319959599514133709188,
         s=6729502936685237038651223791038758905953302464070244934323623239104475448298,
         v=1)
        >>> w3.eth.send_raw_transaction(
        ...     signed_al_tx.raw_transaction
        ... )

        >>> from eth_account import Account
        >>> blob_transaction = {
        ...     "type": 3,  # optional - can be implicitly determined based on `maxFeePerBlobGas` param
        ...     "gas": 100000,
        ...     "maxFeePerGas": 2000000000,
        ...     "maxPriorityFeePerGas": 2000000000,
        ...     "maxFeePerBlobGas": 2000000000,
        ...     "data": "0x616263646566",
        ...     "nonce": 34,
        ...     "to": "0x09616C3d61b3331fc4109a9E41a8BDB7d9776609",
        ...     "value": "0x5af3107a4000",
        ...     "accessList": (  # optional
        ...         {
        ...             "address": "0x0000000000000000000000000000000000000001",
        ...             "storageKeys": (
        ...                 "0x0100000000000000000000000000000000000000000000000000000000000000",
        ...             ),
        ...         },
        ...     ),
        ...     "chainId": 1337,
        ... }
        >>> empty_blob = b"\x00" * 32 * 4096  # 4096 empty 32-byte field elements
        >>> key = (
        ...     "0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318"
        ... )
        >>> # The `blobVersionedHashes` transaction field is calculated from the `blobs` kwarg
        >>> signed_blob_tx = Account.sign_transaction(
        ...     blob_transaction, key, blobs=[empty_blob]
        ... )
        >>> signed_blob_tx
        SignedTransaction(raw_transaction=HexBytes('0x03fa021999f8d98205392284773594008477359400830186a09409616c3d61b3331fc4109a9e41a8bdb7d97766098...00000000'),
         hash=HexBytes('0x9b997e49d596e6f9ca50a47f35da508f575cd23cb822885872fca9444bc8739c'),
         r=14319949980593194209648175507603206696573324965145502821772573913457715875718,
         s=9129184742597516615341309773045281461399831333162885393648678700392065987233,
         v=1)
        >>> w3.eth.send_raw_transaction(
        ...     signed_blob_tx.raw_transaction
        ... )

sign_typed_data(private_key: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | int <https://docs.python.org/3.10/library/functions.html#int> | HexStr | PrivateKey, domain_data: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>] | None <https://docs.python.org/3.10/library/constants.html#None> = None, message_types: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>] | None <https://docs.python.org/3.10/library/constants.html#None> = None, message_data: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>] | None <https://docs.python.org/3.10/library/constants.html#None> = None, full_message: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>] | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> SignedMessage <#eth_account.datastructures.SignedMessage>
    Sign the provided EIP-712 message with the provided key.

Parameters

•   private_key (hex str, bytes, int or eth_keys.datatypes.PrivateKey) -- the key to sign the message with

•   domain_data (dict <https://docs.python.org/3.10/library/stdtypes.html#dict>) -- EIP712 domain data

•   message_types (dict <https://docs.python.org/3.10/library/stdtypes.html#dict>) -- custom types used by the value data

•   message_data (dict <https://docs.python.org/3.10/library/stdtypes.html#dict>) -- data to be signed

•   full_message (dict <https://docs.python.org/3.10/library/stdtypes.html#dict>) -- a dict containing all data and types

Returns
    Various details about the signature - most importantly the fields: v, r, and s

Return type
    SignedMessage <#eth_account.datastructures.SignedMessage>

    You may supply the information to be encoded in one of two ways:

    As exactly three arguments:

•   domain_data, a dict of the EIP-712 domain data

•   message_types, a dict of custom types (do not include a EIP712Domain key)

•   message_data, a dict of the data to be signed

    Or as a single argument:

•

full_message, a dict containing the following keys:

•   types, a dict of custom types (may include a EIP712Domain key)

•   primaryType, (optional) a string of the primary type of the message

•   domain, a dict of the EIP-712 domain data

•   message, a dict of the data to be signed

    Warning: Note that this code has not gone through an external audit, and the test cases are incomplete.

    See documentation for encode_typed_data() for usage details

    See the EIP-712 spec <https://eips.ethereum.org/EIPS/eip-712> for more information.

        >>> # examples of basic usage
        >>> from eth_account import Account
        >>> # 3-argument usage
        >>> # all domain properties are optional
        >>> domain_data = {
        ...     "name": "Ether Mail",
        ...     "version": "1",
        ...     "chainId": 1,
        ...     "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
        ...     "salt": b"decafbeef",
        ... }
        >>> # custom types
        >>> message_types = {
        ...     "Person": [
        ...         {"name": "name", "type": "string"},
        ...         {"name": "wallet", "type": "address"},
        ...     ],
        ...     "Mail": [
        ...         {"name": "from", "type": "Person"},
        ...         {"name": "to", "type": "Person"},
        ...         {"name": "contents", "type": "string"},
        ...     ],
        ... }
        >>> # the data to be signed
        >>> message_data = {
        ...     "from": {
        ...         "name": "Cow",
        ...         "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",
        ...     },
        ...     "to": {
        ...         "name": "Bob",
        ...         "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB",
        ...     },
        ...     "contents": "Hello, Bob!",
        ... }
        >>> key = (
        ...     "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        ... )
        >>> signed_message = Account.sign_typed_data(
        ...     key, domain_data, message_types, message_data
        ... )
        >>> signed_message.message_hash
        HexBytes('0xc5bb16ccc59ae9a3ad1cb8343d4e3351f057c994a97656e1aff8c134e56f7530')
        >>> # 1-argument usage
        >>> # all domain properties are optional
        >>> full_message = {
        ...     "types": {
        ...         "EIP712Domain": [
        ...             {"name": "name", "type": "string"},
        ...             {"name": "version", "type": "string"},
        ...             {"name": "chainId", "type": "uint256"},
        ...             {"name": "verifyingContract", "type": "address"},
        ...             {"name": "salt", "type": "bytes32"},
        ...         ],
        ...         "Person": [
        ...             {"name": "name", "type": "string"},
        ...             {"name": "wallet", "type": "address"},
        ...         ],
        ...         "Mail": [
        ...             {"name": "from", "type": "Person"},
        ...             {"name": "to", "type": "Person"},
        ...             {"name": "contents", "type": "string"},
        ...         ],
        ...     },
        ...     "primaryType": "Mail",
        ...     "domain": {
        ...         "name": "Ether Mail",
        ...         "version": "1",
        ...         "chainId": 1,
        ...         "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
        ...         "salt": b"decafbeef",
        ...     },
        ...     "message": {
        ...         "from": {
        ...             "name": "Cow",
        ...             "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",
        ...         },
        ...         "to": {
        ...             "name": "Bob",
        ...             "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB",
        ...         },
        ...         "contents": "Hello, Bob!",
        ...     },
        ... }
        >>> signed_message_2 = Account.sign_typed_data(
        ...     key, full_message=full_message
        ... )
        >>> signed_message_2.message_hash
        HexBytes('0xc5bb16ccc59ae9a3ad1cb8343d4e3351f057c994a97656e1aff8c134e56f7530')
        >>> signed_message_2 == signed_message
        True

unsafe_sign_hash(message_hash: HexStr | bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | int <https://docs.python.org/3.10/library/functions.html#int>, private_key: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | int <https://docs.python.org/3.10/library/functions.html#int> | HexStr | PrivateKey) -> SignedMessage <#eth_account.datastructures.SignedMessage>
    Sign the provided hash.

    Warning: Never sign a hash that you didn't generate, it can be an arbitrary transaction. For example, it might send all of your account's ether to an attacker. Instead, prefer sign_message(), which cannot accidentally sign a transaction.

Parameters

•   message_hash (hex str, bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> or int <https://docs.python.org/3.10/library/functions.html#int>) -- the 32-byte message hash to be signed

•   private_key (hex str, bytes, int or eth_keys.datatypes.PrivateKey) -- the key to sign the message with

Returns
    Various details about the signature - most importantly the fields: v, r, and s

Return type
    SignedMessage <#eth_account.datastructures.SignedMessage>

    See Signers <> for alternative signers.

  SignedTransaction & SignedMessage

class eth_account.datastructures.SignedMessage(message_hash: HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>, r: int <https://docs.python.org/3.10/library/functions.html#int>, s: int <https://docs.python.org/3.10/library/functions.html#int>, v: int <https://docs.python.org/3.10/library/functions.html#int>, signature: HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>)
    Bases: SignedMessage

class eth_account.datastructures.SignedSetCodeAuthorization(*, chainId: int <https://docs.python.org/3.10/library/functions.html#int>, address: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>, nonce: int <https://docs.python.org/3.10/library/functions.html#int>, yParity: int <https://docs.python.org/3.10/library/functions.html#int>, r: int <https://docs.python.org/3.10/library/functions.html#int>, s: int <https://docs.python.org/3.10/library/functions.html#int>, signature: Signature, authorizationHash: HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>)
    Bases: CamelModel

address: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>

property authority: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Return the address of the authority that signed the authorization.

    In order to prevent any potential confusion or mal-intent, the authority is always derived from the signature and the authorization hash, rather than statically assigned. This value should be verified against the expected authority for a signed authorization.

authorization_hash: HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>

chain_id: int <https://docs.python.org/3.10/library/functions.html#int>

model_config = {'alias_generator': <function to_camel>, 'arbitrary_types_allowed': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True, 'validate_default': True}
    Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

nonce: int <https://docs.python.org/3.10/library/functions.html#int>

r: int <https://docs.python.org/3.10/library/functions.html#int>

s: int <https://docs.python.org/3.10/library/functions.html#int>

classmethod serialize_address(value: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>) -> ChecksumAddress

signature: Signature

y_parity: int <https://docs.python.org/3.10/library/functions.html#int>

class eth_account.datastructures.SignedTransaction(raw_transaction: HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>, hash: HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>, r: int <https://docs.python.org/3.10/library/functions.html#int>, s: int <https://docs.python.org/3.10/library/functions.html#int>, v: int <https://docs.python.org/3.10/library/functions.html#int>)
    Bases: SignedTransaction

  Messages

class eth_account.messages.SignableMessage(version: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>, header: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>, body: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>)
    Bases: NamedTuple <https://docs.python.org/3.10/library/typing.html#typing.NamedTuple>

    A message compatible with EIP-191 <https://eips.ethereum.org/EIPS/eip-191> that is ready to be signed.

    The properties are components of an EIP-191 <https://eips.ethereum.org/EIPS/eip-191> signable message. Other message formats can be encoded into this format for easy signing. This data structure doesn't need to know about the original message format. For example, you can think of EIP-712 as compiling down to an EIP-191 message.

    In typical usage, you should never need to create these by hand. Instead, use one of the available encode_* methods in this module, like:

•   encode_intended_validator()

•   encode_defunct()

•   encode_typed_data()

body: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Alias for field number 2

header: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Alias for field number 1

version: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Alias for field number 0

eth_account.messages.defunct_hash_message(primitive: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | None <https://docs.python.org/3.10/library/constants.html#None> = None, *, hexstr: str <https://docs.python.org/3.10/library/stdtypes.html#str> | None <https://docs.python.org/3.10/library/constants.html#None> = None, text: str <https://docs.python.org/3.10/library/stdtypes.html#str> | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>
    Convert the provided message into a message hash, to be signed.

    Caution: Intended for use with eth_account.account.Account.unsafe_sign_hash(). This is for backwards compatibility only. All new implementations should use encode_defunct() instead.

Parameters

•   primitive (bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> or int <https://docs.python.org/3.10/library/functions.html#int>) -- the binary message to be signed

•   hexstr (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- the message encoded as hex

•   text (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- the message as a series of unicode characters (a normal Py3 str)

Returns
    The hash of the message, after adding the prefix

eth_account.messages.encode_defunct(primitive: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | None <https://docs.python.org/3.10/library/constants.html#None> = None, *, hexstr: str <https://docs.python.org/3.10/library/stdtypes.html#str> | None <https://docs.python.org/3.10/library/constants.html#None> = None, text: str <https://docs.python.org/3.10/library/stdtypes.html#str> | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> SignableMessage <#eth_account.messages.SignableMessage>
    Encode a message for signing, using an old, unrecommended approach.

    Only use this method if you must have compatibility with w3.eth.sign() <https://web3py.readthedocs.io/en/latest/web3.eth.html#web3.eth.Eth.sign>.

    EIP-191 defines this as "version E".

    Supply exactly one of the three arguments: bytes, a hex string, or a unicode string.

Parameters

•   primitive (bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> or int <https://docs.python.org/3.10/library/functions.html#int>) -- the binary message to be signed

•   hexstr (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- the message encoded as hex

•   text (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- the message as a series of unicode characters (a normal Py3 str)

Returns
    The EIP-191 encoded message, ready for signing

        >>> from eth_account.messages import encode_defunct
        >>> from eth_utils.curried import to_hex, to_bytes
        >>> message_text = "I♥SF"
        >>> encode_defunct(text=message_text)
        SignableMessage(version=b'E',
                        header=b'thereum Signed Message:\n6',
                        body=b'I\xe2\x99\xa5SF')
        These four also produce the same hash:
        >>> encode_defunct(to_bytes(text=message_text))
        SignableMessage(version=b'E',
                        header=b'thereum Signed Message:\n6',
                        body=b'I\xe2\x99\xa5SF')
        >>> encode_defunct(bytes(message_text, encoding="utf-8"))
        SignableMessage(version=b'E',
                        header=b'thereum Signed Message:\n6',
                        body=b'I\xe2\x99\xa5SF')
        >>> to_hex(text=message_text)
        '0x49e299a55346'
        >>> encode_defunct(hexstr="0x49e299a55346")
        SignableMessage(version=b'E',
                        header=b'thereum Signed Message:\n6',
                        body=b'I\xe2\x99\xa5SF')
        >>> encode_defunct(0x49E299A55346)
        SignableMessage(version=b'E',
                        header=b'thereum Signed Message:\n6',
                        body=b'I\xe2\x99\xa5SF')

eth_account.messages.encode_intended_validator(validator_address: Address | str <https://docs.python.org/3.10/library/stdtypes.html#str>, primitive: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | None <https://docs.python.org/3.10/library/constants.html#None> = None, *, hexstr: str <https://docs.python.org/3.10/library/stdtypes.html#str> | None <https://docs.python.org/3.10/library/constants.html#None> = None, text: str <https://docs.python.org/3.10/library/stdtypes.html#str> | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> SignableMessage <#eth_account.messages.SignableMessage>
    Encode a message using the "intended validator" approach (ie~ version 0) defined in EIP-191 <https://eips.ethereum.org/EIPS/eip-191>.

    Supply the message as exactly one of these three arguments: bytes as a primitive, a hex string, or a unicode string.

    Warning: Note that this code has not gone through an external audit.

Parameters

•   validator_address -- which on-chain contract is capable of validating this message, provided as a checksummed address or in native bytes.

•   primitive (bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> or int <https://docs.python.org/3.10/library/functions.html#int>) -- the binary message to be signed

•   hexstr (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- the message encoded as hex

•   text (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- the message as a series of unicode characters (a normal Py3 str)

Returns
    The EIP-191 encoded message, ready for signing

eth_account.messages.encode_typed_data(domain_data: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>] | None <https://docs.python.org/3.10/library/constants.html#None> = None, message_types: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>] | None <https://docs.python.org/3.10/library/constants.html#None> = None, message_data: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>] | None <https://docs.python.org/3.10/library/constants.html#None> = None, full_message: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>] | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> SignableMessage <#eth_account.messages.SignableMessage>
    Encode an EIP-712 <https://eips.ethereum.org/EIPS/eip-712> message in a manner compatible with other implementations in use, such as the Metamask and Ethers signTypedData functions.

    See the EIP-712 spec <https://eips.ethereum.org/EIPS/eip-712> for more information.

    You may supply the information to be encoded in one of two ways:

    As exactly three arguments:

•   domain_data, a dict of the EIP-712 domain data

•   message_types, a dict of custom types (do not include a EIP712Domain key)

•   message_data, a dict of the data to be signed

    Or as a single argument:

•

full_message, a dict containing the following keys:

•   types, a dict of custom types (may include a EIP712Domain key)

•   primaryType, (optional) a string of the primary type of the message

•   domain, a dict of the EIP-712 domain data

•   message, a dict of the data to be signed

    Warning: Note that this code has not gone through an external audit, and the test cases are incomplete.

Type Coercion:

•   For fixed-size bytes types, smaller values will be padded to fit in larger types, but values larger than the type will raise ValueOutOfBounds. e.g., an 8-byte value will be padded to fit a bytes16 type, but 16-byte value provided for a bytes8 type will raise an error.

•   Fixed-size and dynamic bytes types will accept int``s. Any negative values will be converted to ``0 before being converted to bytes

•   int and uint types will also accept strings. If prefixed with "0x" , the string will be interpreted as hex. Otherwise, it will be interpreted as decimal.

•   Any value for a bool type that Python considers "falsy" will be interpreted as False. The strings "False", "false", and "0" will be also interpreted as False. All other values will be interpreted as True.

Noteable differences from signTypedData:

•   Custom types that are not alphanumeric will encode differently.

•   Custom types that are used but not defined in types will not encode.

Parameters

•   domain_data -- EIP712 domain data

•   message_types -- custom types used by the value data

•   message_data -- data to be signed

•   full_message -- a dict containing all data and types

Returns
    a SignableMessage, an encoded message ready to be signed

        >>> # examples of basic usage
        >>> from eth_account import Account
        >>> from eth_account.messages import encode_typed_data
        >>> # 3-argument usage
        >>> # all domain properties are optional
        >>> domain_data = {
        ...     "name": "Ether Mail",
        ...     "version": "1",
        ...     "chainId": 1,
        ...     "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
        ...     "salt": b"decafbeef",
        ... }
        >>> # custom types
        >>> message_types = {
        ...     "Person": [
        ...         {"name": "name", "type": "string"},
        ...         {"name": "wallet", "type": "address"},
        ...     ],
        ...     "Mail": [
        ...         {"name": "from", "type": "Person"},
        ...         {"name": "to", "type": "Person"},
        ...         {"name": "contents", "type": "string"},
        ...     ],
        ... }
        >>> # the data to be signed
        >>> message_data = {
        ...     "from": {
        ...         "name": "Cow",
        ...         "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",
        ...     },
        ...     "to": {
        ...         "name": "Bob",
        ...         "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB",
        ...     },
        ...     "contents": "Hello, Bob!",
        ... }
        >>> key = "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        >>> signable_message = encode_typed_data(
        ...     domain_data, message_types, message_data
        ... )
        >>> signed_message = Account.sign_message(signable_message, key)
        >>> signed_message.message_hash
        HexBytes('0xc5bb16ccc59ae9a3ad1cb8343d4e3351f057c994a97656e1aff8c134e56f7530')
        >>> # the message can be signed in one step using Account.sign_typed_data
        >>> signed_typed_data = Account.sign_typed_data(
        ...     key, domain_data, message_types, message_data
        ... )
        >>> signed_typed_data == signed_message
        True
        >>> # 1-argument usage
        >>> # all domain properties are optional
        >>> full_message = {
        ...     "types": {
        ...         "EIP712Domain": [
        ...             {"name": "name", "type": "string"},
        ...             {"name": "version", "type": "string"},
        ...             {"name": "chainId", "type": "uint256"},
        ...             {"name": "verifyingContract", "type": "address"},
        ...             {"name": "salt", "type": "bytes32"},
        ...         ],
        ...         "Person": [
        ...             {"name": "name", "type": "string"},
        ...             {"name": "wallet", "type": "address"},
        ...         ],
        ...         "Mail": [
        ...             {"name": "from", "type": "Person"},
        ...             {"name": "to", "type": "Person"},
        ...             {"name": "contents", "type": "string"},
        ...         ],
        ...     },
        ...     "primaryType": "Mail",
        ...     "domain": {
        ...         "name": "Ether Mail",
        ...         "version": "1",
        ...         "chainId": 1,
        ...         "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
        ...         "salt": b"decafbeef",
        ...     },
        ...     "message": {
        ...         "from": {
        ...             "name": "Cow",
        ...             "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",
        ...         },
        ...         "to": {
        ...             "name": "Bob",
        ...             "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB",
        ...         },
        ...         "contents": "Hello, Bob!",
        ...     },
        ... }
        >>> signable_message_2 = encode_typed_data(full_message=full_message)
        >>> signed_message_2 = Account.sign_message(signable_message_2, key)
        >>> signed_message_2.message_hash
        HexBytes('0xc5bb16ccc59ae9a3ad1cb8343d4e3351f057c994a97656e1aff8c134e56f7530')
        >>> signed_message_2 == signed_message
        True
        >>> # the full_message can be signed in one step using Account.sign_typed_data
        >>> signed_typed_data_2 = Account.sign_typed_data(
        ...     key, domain_data, message_types, message_data
        ... )
        >>> signed_typed_data_2 == signed_message_2
        True

  Signers

These classes abstract away the private key, as opposed to eth_account.account.Account <#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: PrivateKey, account: AccountLocalActions)
    Bases: BaseAccount

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

Variables
    key (bytes <https://docs.python.org/3.10/library/stdtypes.html#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 <https://docs.python.org/3.10/library/stdtypes.html#bytes>:

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

property address: ChecksumAddress
    The checksummed public address for this account.

        >>> my_account.address
        "0xF0109fC8DF283027b6285cc889F5aA624EaC1F55"

encrypt(password: str <https://docs.python.org/3.10/library/stdtypes.html#str>, kdf: Literal <https://docs.python.org/3.10/library/typing.html#typing.Literal>['pbkdf2', 'scrypt'] | None <https://docs.python.org/3.10/library/constants.html#None> = None, iterations: int <https://docs.python.org/3.10/library/functions.html#int> | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]
    Generate a string with the encrypted key.

    This uses the same structure as in encrypt() <#eth_account.account.Account.encrypt>, but without a private key argument.

property key: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Get the private key.

sign_authorization(authorization: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]) -> SignedMessage <#eth_account.datastructures.SignedMessage>

sign_message(signable_message: SignableMessage <#eth_account.messages.SignableMessage>) -> SignedMessage <#eth_account.datastructures.SignedMessage>
    Generate a string with the encrypted key.

    This uses the same structure as in sign_message() <#eth_account.account.Account.sign_message>, but without a private key argument.

sign_transaction(transaction_dict: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Sequence <https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sequence>[AccessListEntry] | bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | HexStr | int <https://docs.python.org/3.10/library/functions.html#int>], blobs: Sequence <https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sequence>[bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>] | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> SignedTransaction <#eth_account.datastructures.SignedTransaction>
    Sign a transaction dict.

    This uses the same structure as in sign_transaction() <#eth_account.account.Account.sign_transaction> but without specifying the private key.

Parameters
    transaction_dict (dict <https://docs.python.org/3.10/library/stdtypes.html#dict>) -- transaction with all fields specified

sign_typed_data(domain_data: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>] | None <https://docs.python.org/3.10/library/constants.html#None> = None, message_types: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>] | None <https://docs.python.org/3.10/library/constants.html#None> = None, message_data: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>] | None <https://docs.python.org/3.10/library/constants.html#None> = None, full_message: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>] | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> SignedMessage <#eth_account.datastructures.SignedMessage>
    Sign the provided EIP-712 message with the local private key.

    This uses the same structure as in sign_typed_data() <#eth_account.account.Account.sign_typed_data>, but without a private key argument.

unsafe_sign_hash(message_hash: Hash32) -> SignedMessage <#eth_account.datastructures.SignedMessage>
    Sign the hash of a message.

    Warning: Never sign a hash that you didn't generate, it can be an arbitrary transaction. For example, it might send all of your account's ether to an attacker. Instead, prefer sign_message() <#eth_account.account.Account.sign_message>, which cannot accidentally sign a transaction.

    This uses the same structure as in unsafe_sign_hash() <#eth_account.account.Account.unsafe_sign_hash> but without specifying the private key.

Parameters
    message_hash (bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>) -- 32 byte hash of the message to sign

  Abstract Signer

class eth_account.signers.base.BaseAccount
    Bases: ABC <https://docs.python.org/3.10/library/abc.html#abc.ABC>

    Specify convenience methods to sign transactions and message hashes.

abstract property address: ChecksumAddress
    The checksummed public address for this account.

        >>> my_account.address
        "0xF0109fC8DF283027b6285cc889F5aA624EaC1F55"

abstractmethod sign_message(signable_message: SignableMessage <#eth_account.messages.SignableMessage>) -> SignedMessage <#eth_account.datastructures.SignedMessage>
    Sign the EIP-191 <https://eips.ethereum.org/EIPS/eip-191> message.

    This uses the same structure as in sign_message() <#eth_account.account.Account.sign_message> but without specifying the private key.

Parameters
    signable_message -- The encoded message, ready for signing

abstractmethod sign_transaction(transaction_dict: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Sequence <https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sequence>[AccessListEntry] | bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | HexStr | int <https://docs.python.org/3.10/library/functions.html#int>]) -> SignedTransaction <#eth_account.datastructures.SignedTransaction>
    Sign a transaction dict.

    This uses the same structure as in sign_transaction() <#eth_account.account.Account.sign_transaction> but without specifying the private key.

Parameters
    transaction_dict (dict <https://docs.python.org/3.10/library/stdtypes.html#dict>) -- transaction with all fields specified

abstractmethod unsafe_sign_hash(message_hash: Hash32) -> SignedMessage <#eth_account.datastructures.SignedMessage>
    Sign the hash of a message.

    Warning: Never sign a hash that you didn't generate, it can be an arbitrary transaction. For example, it might send all of your account's ether to an attacker. Instead, prefer sign_message() <#eth_account.account.Account.sign_message>, which cannot accidentally sign a transaction.

    This uses the same structure as in unsafe_sign_hash() <#eth_account.account.Account.unsafe_sign_hash> but without specifying the private key.

Parameters
    message_hash (bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>) -- 32 byte hash of the message to sign

  Typed Transactions

  Typed Transaction Base

class eth_account.typed_transactions.typed_transaction.TypedTransaction(transaction_type: int <https://docs.python.org/3.10/library/functions.html#int>, transaction: _TypedTransactionImplementation)
    Bases: object <https://docs.python.org/3.10/library/functions.html#object>

    Represents a Typed Transaction as per EIP-2718. The currently supported Transaction Types are:

•   EIP-2930's AccessListTransaction

•   EIP-1559's DynamicFeeTransaction

•   EIP-4844's BlobTransaction

•   EIP-7702's SetCodeTransaction

as_dict() -> dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]
    Returns this transaction as a dictionary.

property blob_data: BlobPooledTransactionData | None <https://docs.python.org/3.10/library/constants.html#None>
    Returns the blobs associated with this transaction.

encode() -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Encodes this TypedTransaction and returns it as bytes.

    The transaction format follows EIP-2718's typed transaction format (TransactionType || TransactionPayload). Note that we delegate to a transaction type's payload() method as the EIP-2718 does not prescribe a TransactionPayload format, leaving types free to implement their own encoding.

classmethod from_bytes(encoded_transaction: HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>) -> TypedTransaction <#eth_account.typed_transactions.typed_transaction.TypedTransaction>
    Builds a TypedTransaction from a signed encoded transaction.

classmethod from_dict(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>], blobs: Sequence <https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sequence>[bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>] | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> TypedTransaction <#eth_account.typed_transactions.typed_transaction.TypedTransaction>
    Builds a TypedTransaction from a dictionary. Verifies the dictionary is well formed.

hash() -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Hashes this TypedTransaction to prepare it for signing.

    As per the EIP-2718 specifications, the hashing format is dictated by the transaction type itself, and so we delegate the call. Note that the return type will be bytes.

vrs() -> tuple <https://docs.python.org/3.10/library/stdtypes.html#tuple>[int <https://docs.python.org/3.10/library/functions.html#int>, int <https://docs.python.org/3.10/library/functions.html#int>, int <https://docs.python.org/3.10/library/functions.html#int>]
    Returns (v, r, s) if they exist.

  Access List Transaction

class eth_account.typed_transactions.access_list_transaction.AccessListTransaction(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>])
    Bases: _TypedTransactionImplementation

    Represents an access list transaction per EIP-2930.

as_dict() -> dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]
    Returns this transaction as a dictionary.

classmethod assert_valid_fields(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]) -> None <https://docs.python.org/3.10/library/constants.html#None>

classmethod from_bytes(encoded_transaction: HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>) -> AccessListTransaction <#eth_account.typed_transactions.access_list_transaction.AccessListTransaction>
    Builds an AccessListTransaction from a signed encoded transaction.

classmethod from_dict(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>], blobs: Sequence <https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sequence>[bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>] | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> AccessListTransaction <#eth_account.typed_transactions.access_list_transaction.AccessListTransaction>
    Builds an AccessListTransaction from a dictionary. Verifies that the dictionary is well formed.

hash() -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Hashes this AccessListTransaction to prepare it for signing. As per the EIP-2930 specifications, the signature is a secp256k1 signature over keccak256(0x01 || rlp([chainId, nonce, gasPrice, gasLimit, to, value, data, accessList])).

payload() -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Returns this transaction's payload as bytes.

    Here, the transaction payload is: TransactionPayload = rlp([chainId, nonce, gasPrice, gasLimit, to, value, data, accessList, signatureYParity, signatureR, signatureS])

signature_fields = (('v', <rlp.sedes.big_endian_int.BigEndianInt object>), ('r', <rlp.sedes.big_endian_int.BigEndianInt object>), ('s', <rlp.sedes.big_endian_int.BigEndianInt object>))

transaction_field_defaults = {'accessList': [], 'chainId': 0, 'data': b'', 'to': b'', 'type': b'0x1', 'value': 0}

transaction_type = 1

unsigned_transaction_fields = (('chainId', <rlp.sedes.big_endian_int.BigEndianInt object>), ('nonce', <rlp.sedes.big_endian_int.BigEndianInt object>), ('gasPrice', <rlp.sedes.big_endian_int.BigEndianInt object>), ('gas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('to', <rlp.sedes.binary.Binary object>), ('value', <rlp.sedes.big_endian_int.BigEndianInt object>), ('data', <rlp.sedes.binary.Binary object>), ('accessList', <rlp.sedes.lists.CountableList object>))

vrs() -> tuple <https://docs.python.org/3.10/library/stdtypes.html#tuple>[int <https://docs.python.org/3.10/library/functions.html#int>, int <https://docs.python.org/3.10/library/functions.html#int>, int <https://docs.python.org/3.10/library/functions.html#int>]
    Returns (v, r, s) if they exist.

  Dynamic Fee Transaction

class eth_account.typed_transactions.dynamic_fee_transaction.DynamicFeeTransaction(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>])
    Bases: _TypedTransactionImplementation

    Represents a dynamic fee transaction access per EIP-1559.

as_dict() -> dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]
    Returns this transaction as a dictionary.

classmethod assert_valid_fields(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]) -> None <https://docs.python.org/3.10/library/constants.html#None>

classmethod from_bytes(encoded_transaction: HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>) -> DynamicFeeTransaction <#eth_account.typed_transactions.dynamic_fee_transaction.DynamicFeeTransaction>
    Builds a DynamicFeeTransaction from a signed encoded transaction.

classmethod from_dict(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>], blobs: Sequence <https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sequence>[bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>] | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> DynamicFeeTransaction <#eth_account.typed_transactions.dynamic_fee_transaction.DynamicFeeTransaction>
    Builds a DynamicFeeTransaction from a dictionary. Verifies that the dictionary is well formed.

hash() -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Hashes this DynamicFeeTransaction to prepare it for signing. As per the EIP-1559 specifications, the signature is a secp256k1 signature over keccak256(0x02 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList]))

payload() -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Returns this transaction's payload as bytes.

    Here, the transaction payload is: TransactionPayload = rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, signatureYParity, signatureR, signatureS])

signature_fields = (('v', <rlp.sedes.big_endian_int.BigEndianInt object>), ('r', <rlp.sedes.big_endian_int.BigEndianInt object>), ('s', <rlp.sedes.big_endian_int.BigEndianInt object>))

transaction_field_defaults = {'accessList': [], 'chainId': 0, 'data': b'', 'to': b'', 'type': b'0x2', 'value': 0}

transaction_type = 2

unsigned_transaction_fields = (('chainId', <rlp.sedes.big_endian_int.BigEndianInt object>), ('nonce', <rlp.sedes.big_endian_int.BigEndianInt object>), ('maxPriorityFeePerGas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('maxFeePerGas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('gas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('to', <rlp.sedes.binary.Binary object>), ('value', <rlp.sedes.big_endian_int.BigEndianInt object>), ('data', <rlp.sedes.binary.Binary object>), ('accessList', <rlp.sedes.lists.CountableList object>))

vrs() -> tuple <https://docs.python.org/3.10/library/stdtypes.html#tuple>[int <https://docs.python.org/3.10/library/functions.html#int>, int <https://docs.python.org/3.10/library/functions.html#int>, int <https://docs.python.org/3.10/library/functions.html#int>]
    Returns (v, r, s) if they exist.

  Blob Transaction

class eth_account.typed_transactions.blob_transactions.blob_transaction.BlobTransaction(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>], blobs: Sequence <https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sequence>[bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>] | None <https://docs.python.org/3.10/library/constants.html#None> = None)
    Bases: _TypedTransactionImplementation

    Represents a blob transaction as per EIP-4844.

as_dict() -> dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]
    Returns this transaction as a dictionary.

classmethod assert_valid_fields(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>], has_blobs: bool <https://docs.python.org/3.10/library/functions.html#bool> = False) -> None <https://docs.python.org/3.10/library/constants.html#None>

blob_data: BlobPooledTransactionData | None <https://docs.python.org/3.10/library/constants.html#None> = None

classmethod from_bytes(encoded_transaction: HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>) -> BlobTransaction <#eth_account.typed_transactions.blob_transactions.blob_transaction.BlobTransaction>
    Builds a BlobTransaction from a signed encoded transaction.

    Supports both: - EIP-7594 format: [tx_payload_body, wrapper_version, blobs, commitments, cell_proofs] - Legacy EIP-4844 format: [tx_payload_body, blobs, commitments, proofs]

classmethod from_dict(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>], blobs: Sequence <https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sequence>[bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>] | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> BlobTransaction <#eth_account.typed_transactions.blob_transactions.blob_transaction.BlobTransaction>
    Builds a BlobTransaction from a dictionary. Verifies that the dictionary is well-formed.

hash() -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Keccak256 hash of the BlobTransaction to prepare it for signing. As per the EIP-4844 specifications, the signature is a secp256k1 signature over keccak256(0x03 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, maxFeePerBlobGas, blobVersionedHashes])).

payload() -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Returns this transaction's payload as bytes.

    Here, the transaction payload is: TransactionPayload = rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, maxFeePerBlobGas, blobVersionedHashes, signatureYParity, signatureR, signatureS])

signature_fields = (('v', <rlp.sedes.big_endian_int.BigEndianInt object>), ('r', <rlp.sedes.big_endian_int.BigEndianInt object>), ('s', <rlp.sedes.big_endian_int.BigEndianInt object>))

transaction_field_defaults = {'accessList': [], 'chainId': 0, 'data': b'', 'to': b'', 'type': b'0x3', 'value': 0}

transaction_type = 3

unsigned_transaction_fields = (('chainId', <rlp.sedes.big_endian_int.BigEndianInt object>), ('nonce', <rlp.sedes.big_endian_int.BigEndianInt object>), ('maxPriorityFeePerGas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('maxFeePerGas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('gas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('to', <rlp.sedes.binary.Binary object>), ('value', <rlp.sedes.big_endian_int.BigEndianInt object>), ('data', <rlp.sedes.binary.Binary object>), ('accessList', <rlp.sedes.lists.CountableList object>), ('maxFeePerBlobGas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('blobVersionedHashes', <rlp.sedes.lists.CountableList object>))

vrs() -> tuple <https://docs.python.org/3.10/library/stdtypes.html#tuple>[int <https://docs.python.org/3.10/library/functions.html#int>, int <https://docs.python.org/3.10/library/functions.html#int>, int <https://docs.python.org/3.10/library/functions.html#int>]
    Returns (v, r, s) if they exist.

wrapper_version = 1

  Set Code Transaction

class eth_account.typed_transactions.set_code_transaction.Authorization(*args, **kwargs)
    Bases: HashableRLP

property address

property chainId

hash() -> HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>

Returns
    the hash of the encoded bytestring

Return type
    HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>

magic = 5

property nonce

class eth_account.typed_transactions.set_code_transaction.SetCodeTransaction(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>])
    Bases: _TypedTransactionImplementation

    Represents a set code transaction as per EIP-7702.

as_dict() -> dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]
    Returns this transaction as a dictionary.

classmethod assert_valid_fields(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]) -> None <https://docs.python.org/3.10/library/constants.html#None>

classmethod from_bytes(encoded_transaction: HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>) -> SetCodeTransaction <#eth_account.typed_transactions.set_code_transaction.SetCodeTransaction>
    Builds an SetCodeTransaction from a signed encoded transaction.

classmethod from_dict(dictionary: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>], blobs: Sequence <https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sequence>[bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>] | None <https://docs.python.org/3.10/library/constants.html#None> = None) -> SetCodeTransaction <#eth_account.typed_transactions.set_code_transaction.SetCodeTransaction>
    Builds a SetCodeTransaction from a dictionary. Verifies that the dictionary is well-formed.

hash() -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Hashes this SetCodeTransaction to prepare it for signing. As per the EIP-7702 specifications, the signature is a secp256k1 signature over keccak256(0x04 || rlp([chainId, nonce, max_priority_fee_per_gas, max_fee_per_gas, gasLimit, to, value, data, accessList, authorizationList])).

payload() -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>
    Returns this transaction's payload as bytes.

    Here, the transaction payload is: TransactionPayload = rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, authorizationsList, signatureYParity, signatureR, signatureS])

signature_fields = (('v', <rlp.sedes.big_endian_int.BigEndianInt object>), ('r', <rlp.sedes.big_endian_int.BigEndianInt object>), ('s', <rlp.sedes.big_endian_int.BigEndianInt object>))

transaction_field_defaults = {'accessList': [], 'authorizationList': [], 'chainId': 0, 'data': b'', 'nonce': 0, 'to': b'', 'type': b'0x4', 'value': 0}

transaction_type = 4

unsigned_transaction_fields = (('chainId', <rlp.sedes.big_endian_int.BigEndianInt object>), ('nonce', <rlp.sedes.big_endian_int.BigEndianInt object>), ('maxPriorityFeePerGas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('maxFeePerGas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('gas', <rlp.sedes.big_endian_int.BigEndianInt object>), ('to', <rlp.sedes.binary.Binary object>), ('value', <rlp.sedes.big_endian_int.BigEndianInt object>), ('data', <rlp.sedes.binary.Binary object>), ('accessList', <rlp.sedes.lists.CountableList object>), ('authorizationList', <rlp.sedes.lists.CountableList object>))

vrs() -> tuple <https://docs.python.org/3.10/library/stdtypes.html#tuple>[int <https://docs.python.org/3.10/library/functions.html#int>, int <https://docs.python.org/3.10/library/functions.html#int>, int <https://docs.python.org/3.10/library/functions.html#int>]
    Returns (v, r, s) if they exist.

class eth_account.typed_transactions.set_code_transaction.SignedAuthorization(*args, **kwargs)
    Bases: HashableRLP

property address

property chainId

property nonce

property r

property s

property yParity

  HD Account

Caution: These features are experimental and unaudited

  HD Mnemonic module

class eth_account.hdaccount.mnemonic.Mnemonic(raw_language: Language = Language.ENGLISH)
    Bases: object <https://docs.python.org/3.10/library/functions.html#object>

    Creates and validates BIP39 mnemonics.

        >>> from eth_account.hdaccount import Language, Mnemonic
        >>> # Create a new Mnemonic instance with Czech language
        >>> cz_mnemonic = Mnemonic(Language.CZECH)
        >>> # English is the default language
        >>> en_mnemonic = Mnemonic()
        >>> # List available languages
        >>> available_languages = Mnemonic.list_languages()
        >>> print(available_languages)
        ['chinese_simplified', 'chinese_traditional', 'czech', 'english', 'french', 'italian', 'japanese', 'korean', 'spanish']
        >>> # List available enumerated languages
        >>> available_languages = Mnemonic.list_languages_enum()
        >>> print(available_languages)
        [<Language.CHINESE_SIMPLIFIED: 'chinese_simplified'>, <Language.CHINESE_TRADITIONAL: 'chinese_traditional'>, <Language.CZECH: 'czech'>, <Language.ENGLISH: 'english'>, <Language.FRENCH: 'french'>, <Language.ITALIAN: 'italian'>, <Language.JAPANESE: 'japanese'>, <Language.KOREAN: 'korean'>, <Language.SPANISH: 'spanish'>]
        >>> # Generate a new mnemonic phrase
        >>> mnemonic_phrase = en_mnemonic.generate()
        >>> print(mnemonic_phrase)
        'cabin raise oven oven knock fantasy flock letter click empty skate volcano'
        >>> # Validate a mnemonic phrase
        >>> is_valid = en_mnemonic.is_mnemonic_valid(mnemonic_phrase)
        >>> print(is_valid)
        True
        >>> # Convert mnemonic phrase to seed
        >>> seed = en_mnemonic.to_seed(
        ...     mnemonic_phrase, passphrase="optional passphrase"
        ... )
        >>> print(seed)
        b'\x97ii\x07\x12\xf0$\x81\x98\xb6?\x07\x08t7\x18d\x87\xe1\x7f\xbe\xbaL\xb4i%\xeb\x12\xce\xe2h\x1c\xb2\x19\x13\xfb9wtoV\x9c\xb8\xdf;5\xba4X\xa3\xd6b`|\xdc\xb1\x10\xb0\xeeS\x86\x95\xd75'

generate(num_words: int <https://docs.python.org/3.10/library/functions.html#int> = 12) -> str <https://docs.python.org/3.10/library/stdtypes.html#str>
    Generate a new mnemonic with the specified number of words.

is_mnemonic_valid(mnemonic: str <https://docs.python.org/3.10/library/stdtypes.html#str>) -> bool <https://docs.python.org/3.10/library/functions.html#bool>
    Checks if mnemonic is valid

Parameters
    mnemonic (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- Mnemonic string

static list_languages() -> list <https://docs.python.org/3.10/library/stdtypes.html#list>[str <https://docs.python.org/3.10/library/stdtypes.html#str>]
    Returns a list of languages available for the seed phrase

static list_languages_enum() -> list <https://docs.python.org/3.10/library/stdtypes.html#list>[Language]
    Returns a list of Language objects available for the seed phrase

classmethod to_seed(checked_mnemonic: str <https://docs.python.org/3.10/library/stdtypes.html#str>, passphrase: str <https://docs.python.org/3.10/library/stdtypes.html#str> = '') -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>

Parameters

•   checked_mnemonic (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- Must be a correct, fully-expanded BIP39 seed phrase

•   passphrase (str <https://docs.python.org/3.10/library/stdtypes.html#str>) -- Encryption passphrase used to secure the mnemonic

Returns bytes
    64 bytes of raw seed material from PRNG

  Module contents

eth_account.hdaccount.generate_mnemonic(num_words: int <https://docs.python.org/3.10/library/functions.html#int>, lang: Language) -> str <https://docs.python.org/3.10/library/stdtypes.html#str>

eth_account.hdaccount.key_from_seed(seed: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>, account_path: str <https://docs.python.org/3.10/library/stdtypes.html#str>) -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>

eth_account.hdaccount.seed_from_mnemonic(words: str <https://docs.python.org/3.10/library/stdtypes.html#str>, passphrase: str <https://docs.python.org/3.10/library/stdtypes.html#str>) -> bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>

  Release Notes

  eth-account v0.14.0-beta.1 (2025-12-18)

  Breaking Changes

•   Drop support for Python 3.8 and 3.9 (#328 <https://github.com/ethereum/eth-account/issues/328>)

•   Bump eth-utils requirement to >=5.3.0 to allow for CamelModel usage (#329 <https://github.com/ethereum/eth-account/issues/329>)

  Features

•   Add support for Python 3.14 (#328 <https://github.com/ethereum/eth-account/issues/328>)

  Internal Changes - for eth-account Contributors

•   Fix mypy errors with BaseModel.model_json_schema introduced with Pydantic 2.12 (#326 <https://github.com/ethereum/eth-account/issues/326>)

  eth-account v0.13.7 (2025-04-21)

  Bugfixes

•   Fix issues with the json schema generation for Pydantic models (SignedSetCodeAuthorization) and simplify the serialization by moving a misplaced @field_validator decorator above @classmethod (not below it). (#318 <https://github.com/ethereum/eth-account/issues/318>)

•   Remove doc warnings and unwanted generated docs (#321 <https://github.com/ethereum/eth-account/issues/321>)

  Improved Documentation

•   Update and clarify documentation for authorization signing. (#319 <https://github.com/ethereum/eth-account/issues/319>)

  eth-account v0.13.6 (2025-03-26)

  Bugfixes

•   Adds logic to interpret the string values "False", "false", and "0" as False when encoding EIP712 messages. (#303 <https://github.com/ethereum/eth-account/issues/303>)

  Features

•   Implement EIP-7702 SetCodeTransaction. (#315 <https://github.com/ethereum/eth-account/issues/315>)

  eth-account v0.13.5 (2025-02-04)

  Features

•   Make sign_typed_data available in the LocalAccount class. (#304 <https://github.com/ethereum/eth-account/issues/304>)

•   Merge template, adding py313 support, replacing bumpversion with bump-my-version and bumping hypothesis test dep to >=6.22.0,<6.108.7. (#311 <https://github.com/ethereum/eth-account/issues/311>)

  Internal Changes - for eth-account Contributors

•   deepcopy EIP712 messages used in test to avoid unintended mutation. (#308 <https://github.com/ethereum/eth-account/issues/308>)

•   Update node.js version used in tests from 20 to 22. (#309 <https://github.com/ethereum/eth-account/issues/309>)

  eth-account v0.13.4 (2024-09-25)

  Deprecations

•   Change language arg to enum in Mnemonic (#291 <https://github.com/ethereum/eth-account/issues/291>)

  Features

•   Add new list_languages_enum method to HDAccount class (#302 <https://github.com/ethereum/eth-account/issues/302>)

  Internal Changes - for eth-account Contributors

•   Pin eth-keyfile <0.9.0 due to breaking changes to typing (#299 <https://github.com/ethereum/eth-account/issues/299>)

  eth-account v0.13.3 (2024-08-28)

  Bugfixes

•   Raise lower pin on eth-keyfile to >=0.7.0 where a bug was fixed in the default values for scrypt generated keyfiles. (#297 <https://github.com/ethereum/eth-account/issues/297>)

  eth-account v0.13.2 (2024-08-21)

  Bugfixes

•   Pin ckzg to >=2.0; update the the trusted setup and how it is loaded. (#293 <https://github.com/ethereum/eth-account/issues/293>)

  eth-account v0.13.1 (2024-07-24)

  Internal Changes - for eth-account Contributors

•   Update mypy checks to run with all dev dependencies installed (#280 <https://github.com/ethereum/eth-account/issues/280>)

•   Enforce mypy strict_optional rule (#281 <https://github.com/ethereum/eth-account/issues/281>)

•   Updated mypy types setting disallow_untyped_defs and disallow_untyped_calls to true (#283 <https://github.com/ethereum/eth-account/issues/283>)

•   Set mypy rules disallow_any_generics, disallow_subclassing_any, and disallow_untyped_decorators to true (#285 <https://github.com/ethereum/eth-account/issues/285>)

  eth-account v0.13.0 (2024-05-20)

  Bugfixes

•   Open up Pydantic dependency (#271 <https://github.com/ethereum/eth-account/issues/271>)

  Features

•   Expose TypedTransactions for public use (#276 <https://github.com/ethereum/eth-account/issues/276>)

  Internal Changes - for eth-account Contributors

•   Merge template updates, notably adding python 3.12 support (#274 <https://github.com/ethereum/eth-account/issues/274>)

  Miscellaneous Changes

•   #275 <https://github.com/ethereum/eth-account/issues/275>

  Removals

•   Remove signHash in favor of unsafe_sign_hash (#260 <https://github.com/ethereum/eth-account/issues/260>)

•   Remove messageHash in favor of message_hash (#265 <https://github.com/ethereum/eth-account/issues/265>)

•   Moved private _parsePrivateKey method to _parse_private_key (#267 <https://github.com/ethereum/eth-account/issues/267>)

•   Remove SignedTransaction's rawTransaction attribute in favor of raw_transaction (#268 <https://github.com/ethereum/eth-account/issues/268>)

•   Remove encode_structured_data in favor of encode_typed_data (#269 <https://github.com/ethereum/eth-account/issues/269>)

  eth-account v0.12.1 (2024-04-02)

  Improved Documentation

•   Update documentation to include blob transaction signing example. (#258 <https://github.com/ethereum/eth-account/issues/258>)

  eth-account v0.12.0 (2024-04-01)

  Bugfixes

•   Import cytoolz methods via eth_utils instead of cytoolz directly (#251 <https://github.com/ethereum/eth-account/issues/251>)

  Improved Documentation

•   Add encode_typed_data to list of functions that return a SignableMessage (#247 <https://github.com/ethereum/eth-account/issues/247>)

  Features

•   Add support for type 3, BlobTransaction, introduced by the Cancun network upgrade. (#253 <https://github.com/ethereum/eth-account/issues/253>)

  Internal Changes - for eth-account Contributors

•   Bump deps to hexbytes>=1.2.0 and eth-rlp>=2.1.0 (#254 <https://github.com/ethereum/eth-account/issues/254>)

  eth-account v0.11.0 (2024-02-05)

  Breaking Changes

•   Drop support for python 3.7 (#248 <https://github.com/ethereum/eth-account/issues/248>)

  Internal Changes - for eth-account Contributors

•   Change older % and .format strings to use f-strings (#245 <https://github.com/ethereum/eth-account/issues/245>)

•   Merge template updates, notably use pre-commit for linting and change the name of the master branch to main (#248 <https://github.com/ethereum/eth-account/issues/248>)

  Removals

•   Remove deprecated signTransaction, it has been replaced by sign_transaction (#244 <https://github.com/ethereum/eth-account/issues/244>)

  eth-account v0.10.0 (2023-10-30)

  Deprecations

•   Deprecate encode_structured_data in favor of new encode_typed_data (#235 <https://github.com/ethereum/eth-account/issues/235>)

  Improved Documentation

•   Added usage notes and example for encode_structured_data (#233 <https://github.com/ethereum/eth-account/issues/233>)

  Features

•   Add new encode_typed_data to better handle EIP712 message signing (#235 <https://github.com/ethereum/eth-account/issues/235>)

•   Added option to call encode_typed_data with a single dict arg in addition to the existing 3-dict style (#238 <https://github.com/ethereum/eth-account/issues/238>)

•   Add sign_typed_data as a method of the Account class (#239 <https://github.com/ethereum/eth-account/issues/239>)

  Internal Changes - for eth-account Contributors

•   Added tests for encode_structured_data for easier comparison with Metamask's SignTypedData (#233 <https://github.com/ethereum/eth-account/issues/233>)

•   Bump version for node and ethers.js in integration tests, update ethers usage to match (#236 <https://github.com/ethereum/eth-account/issues/236>)

•   Add build.os to readthedocs settings (#237 <https://github.com/ethereum/eth-account/issues/237>)

•   Add upper pin to hexbytes dependency to due incoming breaking change (#240 <https://github.com/ethereum/eth-account/issues/240>)

•   Add tests comparing output of signed EIP712 messages with metamask and ethers (#241 <https://github.com/ethereum/eth-account/issues/241>)

  eth-account v0.9.0 (2023-06-07)

  Breaking Changes

•   drop python3.6 support from setup (#228 <https://github.com/ethereum/eth-account/issues/228>)

  Improved Documentation

•   remove notices of Draft status for eips 712 and 191 (#222 <https://github.com/ethereum/eth-account/issues/222>)

  Features

•   Add support for Python 3.11 (#212 <https://github.com/ethereum/eth-account/issues/212>)

  Internal Changes - for eth-account Contributors

•   Upgrade Node from v12.x to v18.x in tests (#217 <https://github.com/ethereum/eth-account/issues/217>)

•   pulled full new node_v18 install script (#223 <https://github.com/ethereum/eth-account/issues/223>)

•   bump versions for docs dependencies (#224 <https://github.com/ethereum/eth-account/issues/224>)

•   add sphinx_rtd_theme to docs/conf.py extensions list (#225 <https://github.com/ethereum/eth-account/issues/225>)

•   merge in updates from python project template (#288 <https://github.com/ethereum/eth-account/issues/288>)

  eth-account v0.8.0 (2022-12-15)

  Features

•   update all references to deprecated eth_abi.encode_abi to eth_abi.encode (#200 <https://github.com/ethereum/eth-account/issues/200>)

  Performance improvements

•   Reduce the number of pbkdf2 iterations to speed up tests (#77 <https://github.com/ethereum/eth-account/issues/77>)

  Deprecations and Removals

•   remove deprecated methods that were noted to go in v0.5 (#195 <https://github.com/ethereum/eth-account/issues/195>)

  Internal Changes - for eth-account Contributors

•   add coverage reporting to pytest (#192 <https://github.com/ethereum/eth-account/issues/192>)

•   Use updated circleci Python images, fix Sphinx warning (#194 <https://github.com/ethereum/eth-account/issues/194>)

  Miscellaneous changes

•   #197 <https://github.com/ethereum/eth-account/issues/197>, #198 <https://github.com/ethereum/eth-account/issues/198>, #199 <https://github.com/ethereum/eth-account/issues/199>, #202 <https://github.com/ethereum/eth-account/issues/202>, #203 <https://github.com/ethereum/eth-account/issues/203>, #204 <https://github.com/ethereum/eth-account/issues/204>, #206 <https://github.com/ethereum/eth-account/issues/206>

  eth-account v0.7.0 (2022-08-17)

  Bugfixes

•   bump ansi-regex to 5.0.1 to fix minor ReDos vulnerability (#129 <https://github.com/ethereum/eth-account/issues/129>)

•   Enable lint runs again on CI (#166 <https://github.com/ethereum/eth-account/issues/166>)

•   fix DoS-able regex pattern (#178 <https://github.com/ethereum/eth-account/issues/178>)

•   Allow towncrier to build the release notes again (#185 <https://github.com/ethereum/eth-account/issues/185>)

  Improved Documentation

•   Add example to generate multiple accounts from a mnemonic (#153 <https://github.com/ethereum/eth-account/issues/153>)

•   Pin Jinja2 at >=3.0.0,<3.1.0; pin towncrier==18.5.0; open up Sphinx requirement to allow >=1.6.5,<5. (#156 <https://github.com/ethereum/eth-account/issues/156>)

•   added missing quotes to readme dev environment setup example (#172 <https://github.com/ethereum/eth-account/issues/172>)

  Miscellaneous changes

•   #79 <https://github.com/ethereum/eth-account/issues/79>, #155 <https://github.com/ethereum/eth-account/issues/155>, #162 <https://github.com/ethereum/eth-account/issues/162>, #164 <https://github.com/ethereum/eth-account/issues/164>, #165 <https://github.com/ethereum/eth-account/issues/165>

  Breaking changes

•   Change bitarray dependency requirement to be >=2.4,<3 since 2.4 has wheels for all platform types. (#154 <https://github.com/ethereum/eth-account/issues/154>)

•   Fix errors in EIP-712 signing (#175 <https://github.com/ethereum/eth-account/issues/175>)

  eth-account v0.6.1 (2022-02-24)

  Bugfixes

•   Allow encoding of structured data containing bytes (#91 <https://github.com/ethereum/eth-account/issues/91>)

  Miscellaneous changes

•   #68 <https://github.com/ethereum/eth-account/issues/68>, #144 <https://github.com/ethereum/eth-account/issues/144>

  eth-account v0.6.0 (2022-01-20)

  Features

•   Update dependencies: - eth-abi - eth-keyfile - eth-keys - eth-rlp - pyrlp - eth-utils (#138 <https://github.com/ethereum/eth-account/issues/138>)

•   Add support for Python 3.9 and 3.10 (#139 <https://github.com/ethereum/eth-account/issues/139>)

  Deprecations and Removals

•   Drop support for Python 3.6 (#139 <https://github.com/ethereum/eth-account/issues/139>)

  eth-account v0.5.9 (2022-08-04)

  Bugfixes

•   fix DoS-able regex pattern (#178 <https://github.com/ethereum/eth-account/issues/178>)

  Miscellaneous changes

•   #183 <https://github.com/ethereum/eth-account/issues/183>, #184 <https://github.com/ethereum/eth-account/issues/184>

  eth-account v0.5.8 (2022-06-06)

  Miscellaneous changes

•   #163 <https://github.com/ethereum/eth-account/issues/163>, #168 <https://github.com/ethereum/eth-account/issues/168>

  eth-account v0.5.7 (2022-01-27)

  Features

•   Add support for Python 3.9 and 3.10 (#139 <https://github.com/ethereum/eth-account/issues/139>)

  Bugfixes

•   recover_message now raises an eth_keys.exceptions.BadSignature error if the v, r, and s points are invalid (#142 <https://github.com/ethereum/eth-account/issues/142>)

  eth-account v0.5.6 (2021-09-22)

  Features

•   An explicit transaction type is no longer required for signing a transaction if we can implicitly determine the transaction type from the transaction parameters (#125 <https://github.com/ethereum/eth-account/issues/125>)

  Bugfixes

•   When signing a transaction, the regular JSON-RPC structure is now expected as input and is converted to the appropriate rlp transaction structure when signing (#125 <https://github.com/ethereum/eth-account/issues/125>)

•   Fix string interpolation in ValidationError message of _hash_eip_191_message (#128 <https://github.com/ethereum/eth-account/issues/128>)

  Improved Documentation

•   Updated docs for sign_transaction to show that transaction type can be implicitly determined based on transaction parameters if one is not provided (#126 <https://github.com/ethereum/eth-account/issues/126>)

•   Add encode_defunct to list of example message encoders (#127 <https://github.com/ethereum/eth-account/issues/127>)

  eth-account v0.5.5 (2021-07-21)

  Features

•   Added support for EIP-2718 (Typed Transaction) and EIP-2939 (Access List Transaction) (#115 <https://github.com/ethereum/eth-account/issues/115>)

•   Added support for EIP-1559 (Dynamic Fee Transaction) (#117 <https://github.com/ethereum/eth-account/issues/117>)

  Bugfixes

•   Structured messages (EIP-712) new permit leaving some (but not all) domain fields undefined. (#72 <https://github.com/ethereum/eth-account/issues/72>)

  Internal Changes - for eth-account Contributors

•   Upgrade project template, of note: a new mypy & pydocstyle, and types being exported correctly. (#121 <https://github.com/ethereum/eth-account/issues/121>)

  Miscellaneous changes

•   #116 <https://github.com/ethereum/eth-account/issues/116>

  v0.5.3 (2020-08-31)

  Performance improvements

•   RLP encoding/decoding speedup by using rlp v2alpha1, which has a rust implementation. (#104 <https://github.com/ethereum/eth-account/issues/104>)

  v0.5.2 (2020-04-30)

  Bugfixes

•   Makes sure that the raw txt files needed for Mnemonics get packaged with the release. (#99 <https://github.com/ethereum/eth-account/issues/99>)

  v0.5.1

Released 2020-04-23

•   Fix a crash in signing typed messages with arrays #97 <https://github.com/ethereum/eth-account/pull/97>

•   Replace attrdict with NamedTuple to silence a deprecation warning #76 <https://github.com/ethereum/eth-account/pull/76>

•   Run more doctests & improve docs #94 <https://github.com/ethereum/eth-account/pull/94>

  v0.5.0

Released 2020-03-30

•   Add Python 3.8 support #86 <https://github.com/ethereum/eth-account/pull/86>

•   Add opt-in support for Mnemonic seed phrases #87 <https://github.com/ethereum/eth-account/pull/87> (NOTE: This API is unaudited and likely to change)

•   Dependency change: support eth-keys v0.3.* #69 <https://github.com/ethereum/eth-account/pull/69>

  v0.4.0

Released 2019-05-06

•   BREAKING CHANGE: drop python 3.5 (and therefore pypy3 support). #60 <https://github.com/ethereum/eth-account/pull/60> (includes other housekeeping)

•   New message signing API: sign_message() <#eth_account.account.Account.sign_message> and recover_message. #61 <https://github.com/ethereum/eth-account/pull/61>

•   New eth_account.messages.encode_intended_validator() <#eth_account.messages.encode_intended_validator> for EIP-191's Intended Validator message-signing format. #56 <https://github.com/ethereum/eth-account/pull/56>

•   New eth_account.messages.encode_structured_data() for EIP-712's Structured Data message-signing format. #57 <https://github.com/ethereum/eth-account/pull/57>

•   Add optional param iterations to encrypt() <#eth_account.account.Account.encrypt> #52 <https://github.com/ethereum/eth-account/pull/52>

•   Add optional param kdf to encrypt() <#eth_account.account.Account.encrypt>, plus env var ETH_ACCOUNT_KDF. Default kdf switched from hmac-sha256 to scrypt. #38 <https://github.com/ethereum/eth-account/pull/38>

•   Accept "to" addresses formatted as bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> in addition to checksummed, hex-encoded. #36 <https://github.com/ethereum/eth-account/pull/36>

  v0.3.0

Released July 24, 2018

•   Support eth_keys.datatypes.PrivateKey in params that accept a private key.

•   New docs for Signers <>

•   Under the hood: add a new BaseAccount <#eth_account.signers.base.BaseAccount> abstract class, so that upcoming signing classes can implement it (be on the lookout for upcoming hardware wallet support)

  v0.2.3

Released May 27, 2018

•   Implement __eq__ and __hash__ for LocalAccount <#eth_account.signers.local.LocalAccount>, so that accounts can be used in set <https://docs.python.org/3.10/library/stdtypes.html#set>, or as keys in dict <https://docs.python.org/3.10/library/stdtypes.html#dict>, etc.

  v0.2.2

Released Apr 25, 2018

•   Compatibility with pyrlp v0 and v1

  v0.2.1

Released Apr 23, 2018

•   Accept 'from' in signTransaction, if it matches the sending private key's address

  v0.2.0 (stable)

Released Apr 19, 2018

•   Audit cleanup is complete

•   Stopped requiring chainId, until tooling to automatically derive it gets better (Not that transactions without chainId are potentially replayable on fork chains)

  v0.2.0-alpha.0

Released Apr 6, 2018

•   Ability to sign an already-hashed message

•   Moved eth_sign-style message hashing to eth_account.messages.defunct_hash_message() <#eth_account.messages.defunct_hash_message>

•   Stricter transaction input validation, and better error messages. Including: to field must be checksummed.

•   PyPy3 support & tests

•   Upgrade dependencies

•   Moved non-public interfaces to internal module

•   Documentation

•   use getpass instead of typing in password manually

•   eth_account.signers.local.LocalAccount <#eth_account.signers.local.LocalAccount> attributes

•   readme improvements

•   more

  v0.1.0-alpha.2

•   Imported the local signing code from web3.py's w3.eth.account

•   Imported documentation and added more

•   Imported tests and pass them

  v0.1.0-alpha.1

•   Launched repository, claimed names for pip, RTD, github, etc

  Contributing

Thank you for your interest in contributing! We welcome all contributions no matter their size. Please read along to learn how to get started. If you get stuck, feel free to ask for help in Ethereum Python Discord server <https://discord.gg/GHryRvPB84>.

  Setting the stage

To get started, fork the repository to your own github account, then clone it to your development machine:

    git clone git@github.com:your-github-username/eth-account.git

Next, install the development dependencies with uv <https://docs.astral.sh/uv/>. The dev dependency group is installed by default, so uv sync is enough for a local development environment.

    cd eth-account
    uv sync
    uv run prek install

  Running the tests

A great way to explore the code base is to run the tests.

We can then run the core tests with:

    pytest tests/core

To run the integration test cases, we need to install node and the custom cli tool as follows:

    # on Ubuntu
    chmod +x ./tests/integration/js-scripts/setup_node_v22.sh
    ./tests/integration/js-scripts/setup_node_v22.sh  # As sudo
    apt-get install -y nodejs  # As sudo
    cd tests/integration/js-scripts
    npm install

We can then run all tests with:

    pytest tests

  Code Style

We use prek <https://prek.j178.dev> to enforce a consistent code style across the library. This tool runs automatically with every commit, but you can also run it manually with:

    make lint

If you need to make a commit that skips the prek checks, you can do so with git commit --no-verify.

This library uses type hints, which are enforced by the mypy tool (part of the prek checks). All new code is required to land with type hints, with the exception of code within the tests directory.

  Documentation

Good documentation will lead to quicker adoption and happier users. Please check out our guide on how to create documentation for the Python Ethereum ecosystem <https://github.com/ethereum/snake-charmers-tactical-manual/blob/main/documentation.md>.

  Pull Requests

It's a good idea to make pull requests early on. A pull request represents the start of a discussion, and doesn't necessarily need to be the final, finished submission.

GitHub's documentation for working on pull requests is available here <https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests>.

Once you've made a pull request, take a look at the Circle CI build status in the GitHub interface and make sure all tests are passing. In general pull requests that do not pass the CI build yet won't get reviewed unless explicitly requested.

If the pull request introduces changes that should be reflected in the release notes, please add a newsfragment file as explained here <https://github.com/ethereum/eth-account/blob/main/newsfragments/README.md>.

If possible, the change to the release notes file should be included in the commit that introduces the feature or bugfix.

  Releasing

Releases are typically done from the main branch, except when releasing a beta (in which case the beta is released from main, and the previous stable branch is released from said branch).

  Final review before each release

Before releasing a new version, run the test suite from the release branch:

    git checkout main && git pull
    uv run --group test pytest tests/core

Review the documentation that will get published:

    uv run --group docs sphinx-apidoc -o docs/ . "conftest*" "tests" "tests/*"
    uv run --group docs sphinx-build -W -b html docs docs/_build/html
    uv run --group docs sphinx-build -W -b doctest docs docs/_build/doctest

  Publish a release

After confirming that the release package looks okay, create a GitHub Release for the version being published. The release tag is the canonical version source: setuptools-scm derives the package version from that tag, and the release workflow builds and publishes the package to PyPI using trusted publishing.

Release notes are maintained through GitHub Releases.

  Code of Conduct

  Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

  Our Standards

Examples of behavior that contributes to creating a positive environment include:

•   Using welcoming and inclusive language

•   Being respectful of differing viewpoints and experiences

•   Gracefully accepting constructive criticism

•   Focusing on what is best for the community

•   Showing empathy towards other community members

    Examples of unacceptable behavior by participants include:

•   The use of sexualized language or imagery and unwelcome sexual attention or advances

•   Trolling, insulting/derogatory comments, and personal or political attacks

•   Public or private harassment

•   Publishing others' private information, such as a physical or electronic address, without explicit permission

•   Other conduct which could reasonably be considered inappropriate in a professional setting

  Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

  Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

  Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at <snakecharmers@ethereum.org>. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

  Attribution

This Code of Conduct is adapted from the Contributor Covenant <https://www.contributor-covenant.org>, version 1.4, available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>

Author
The Ethereum Foundation

Copyright
2018-2025, The Ethereum Foundation