ethereum.paris.fork_types

Ethereum Types ^^^^^^^^^^^^^^

.. contents:: Table of Contents :backlinks: none :local:

Introduction

Types re-used throughout the specification, which are specific to Ethereum.

Address

28
Address = Bytes20

Root

29
Root = Hash32

Bloom

31
Bloom = Bytes256

Account

State associated with an address.

34
@slotted_freezable
35
@dataclass
class Account:

nonce

41
    nonce: Uint

balance

42
    balance: U256

code

43
    code: bytes

EMPTY_ACCOUNT

46
EMPTY_ACCOUNT = Account(
47
    nonce=Uint(0),
48
    balance=U256(0),
49
    code=bytearray(),
50
)

encode_account

Encode Account dataclass.

Storage is not stored in the Account dataclass, so Accounts cannot be encoded without providing a storage root.

def encode_account(raw_account_data: Account, ​​storage_root: Bytes) -> Bytes:
54
    """
55
    Encode `Account` dataclass.
56
57
    Storage is not stored in the `Account` dataclass, so `Accounts` cannot be
58
    encoded without providing a storage root.
59
    """
60
    return rlp.encode(
61
        (
62
            raw_account_data.nonce,
63
            raw_account_data.balance,
64
            storage_root,
65
            keccak256(raw_account_data.code),
66
        )
67
    )