Overview
AccountState represents the four fields of an Ethereum account as defined in the Yellow Paper (section 4.1). Every account has a nonce, balance, storage root, and code hash.Type Definition
nonce- Transaction count (EOA) or contract creations (contract)balance- Account balance in WeistorageRoot- Merkle Patricia Trie root of storage slotscodeHash- Keccak256 hash of EVM bytecode
Creating AccountState
from
Universal constructor from object with required fields.createEmpty
Creates an empty EOA (Externally Owned Account) with zero balance and nonce.Account Type Detection
isEOA
Checks if account is an Externally Owned Account (has no bytecode).isContract
Checks if account is a contract (has bytecode).Comparing AccountStates
equals
Compares all four fields for equality.Constants
EOA vs Contract Accounts
| Field | EOA | Contract |
|---|---|---|
| nonce | Transaction count | Contract creations |
| balance | ETH owned | ETH owned |
| storageRoot | EMPTY_TRIE_HASH | Storage trie root |
| codeHash | EMPTY_CODE_HASH | Bytecode hash |
See Also
- State - Global state management
- Hash - Keccak256 hashing
- Denomination - Wei/Ether conversion

