ethereum.forks.spurious_dragon.fork_typesethereum.forks.byzantium.fork_types

Ethereum Types.

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

Introduction

Types reused throughout the specification, which are specific to Ethereum.

Address

23
Address = Bytes20

Root

24
Root = Hash32

Bloom

25
Bloom = Bytes256

Account

State associated with an address.

28
@slotted_freezable
29
@dataclass
class Account:

nonce

35
    nonce: Uint

balance

36
    balance: U256

code

37
    code: Bytes

EMPTY_ACCOUNT

40
EMPTY_ACCOUNT = Account(
41
    nonce=Uint(0),
42
    balance=U256(0),
43
    code=b"",
44
)

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:
48
    """
49
    Encode `Account` dataclass.
50
51
    Storage is not stored in the `Account` dataclass, so `Accounts` cannot be
52
    encoded without providing a storage root.
53
    """
54
    return rlp.encode(
55
        (
56
            raw_account_data.nonce,
57
            raw_account_data.balance,
58
            storage_root,
59
            keccak256(raw_account_data.code),
60
        )
61
    )