ethereum.byzantium.fork_types

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

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

Introduction

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

Address

24
Address = Bytes20

Root

25
Root = Hash32

Bloom

26
Bloom = Bytes256

Account

State associated with an address.

29
@slotted_freezable
30
@dataclass
class Account:

nonce

36
    nonce: Uint

balance

37
    balance: U256

code

38
    code: bytes

EMPTY_ACCOUNT

41
EMPTY_ACCOUNT = Account(
42
    nonce=Uint(0),
43
    balance=U256(0),
44
    code=bytearray(),
45
)

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