ethereum.shanghai.fork_typesethereum.cancun.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 |
---|
VersionedHash
30 | VersionedHash = Hash32 |
---|
Bloom
32 | Bloom = Bytes256 |
---|
Account
State associated with an address.
35 | @slotted_freezable |
---|
36 | @dataclass |
---|
class Account:
nonce
42 | nonce: Uint |
---|
balance
43 | balance: U256 |
---|
code
44 | code: bytes |
---|
EMPTY_ACCOUNT
47 | EMPTY_ACCOUNT = Account( |
---|---|
48 | nonce=Uint(0), |
49 | balance=U256(0), |
50 | code=bytearray(), |
51 | ) |
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:
55 | """ |
---|---|
56 | Encode `Account` dataclass. |
57 |
|
58 | Storage is not stored in the `Account` dataclass, so `Accounts` cannot be |
59 | encoded without providing a storage root. |
60 | """ |
61 | return rlp.encode( |
62 | ( |
63 | raw_account_data.nonce, |
64 | raw_account_data.balance, |
65 | storage_root, |
66 | keccak256(raw_account_data.code), |
67 | ) |
68 | ) |