ethereum.constantinople.fork_typesethereum.istanbul.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
27 | Bloom = Bytes256 |
---|
Account
State associated with an address.
30 | @slotted_freezable |
---|
31 | @dataclass |
---|
class Account:
nonce
37 | nonce: Uint |
---|
balance
38 | balance: U256 |
---|
code
39 | code: bytes |
---|
EMPTY_ACCOUNT
42 | EMPTY_ACCOUNT = Account( |
---|---|
43 | nonce=Uint(0), |
44 | balance=U256(0), |
45 | code=bytearray(), |
46 | ) |
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:
50 | """ |
---|---|
51 | Encode `Account` dataclass. |
52 |
|
53 | Storage is not stored in the `Account` dataclass, so `Accounts` cannot be |
54 | encoded without providing a storage root. |
55 | """ |
56 | return rlp.encode( |
57 | ( |
58 | raw_account_data.nonce, |
59 | raw_account_data.balance, |
60 | storage_root, |
61 | keccak256(raw_account_data.code), |
62 | ) |
63 | ) |