Overview
The Host module provides an interface for EVM opcodes to access external blockchain state. It abstracts account storage, balances, code, and nonces behind a unified API that instruction handlers call during execution. This is the boundary between the EVM execution engine and the state layer - whether that’s an in-memory mock, a database, or a live Ethereum node.Architecture Note
This module provides low-level EVM primitives (opcode handlers, frame management). For full EVM execution with nested calls, use:- guillotine: Production EVM with async state access, tracing, and full EIP support
- guillotine-mini: Lightweight synchronous EVM for testing and simple use cases
call and create methods enable nested execution. When not provided, system opcodes (CALL, CREATE, etc.) return NotImplemented error.
Type Definition
API
Host(impl)
Create a Host from an implementation object.Host.from(impl)
Alias forHost(impl). Creates a branded Host from implementation.
Host.createMemoryHost()
Create an in-memory Host for testing. All state stored in Maps.Methods
Account State
| Method | Description | Used By |
|---|---|---|
getBalance(address) | Get ETH balance in wei | BALANCE (0x31) |
setBalance(address, balance) | Set ETH balance | Transaction processing |
getCode(address) | Get contract bytecode | EXTCODESIZE, EXTCODECOPY, EXTCODEHASH |
setCode(address, code) | Deploy contract code | CREATE, CREATE2 |
getNonce(address) | Get account nonce | Transaction validation |
setNonce(address, nonce) | Increment nonce | Transaction processing |
Persistent Storage
| Method | Description | Used By |
|---|---|---|
getStorage(address, slot) | Read storage slot | SLOAD (0x54) |
setStorage(address, slot, value) | Write storage slot | SSTORE (0x55) |
Transient Storage (EIP-1153)
Transaction-scoped storage cleared at end of transaction.| Method | Description | Used By |
|---|---|---|
getTransientStorage(address, slot) | Read transient slot | TLOAD (0x5c) |
setTransientStorage(address, slot, value) | Write transient slot | TSTORE (0x5d) |
Nested Execution (Optional)
| Method | Description | Used By |
|---|---|---|
call(params) | Execute nested call | CALL, STATICCALL, DELEGATECALL, CALLCODE |
create(params) | Deploy new contract | CREATE, CREATE2 |
Examples
Custom Host with Logging
Using with SLOAD Instruction
Multiple Account Management
Transient Storage (EIP-1153)
Transient storage provides transaction-scoped data that is:- Isolated per contract address
- Cleared at end of transaction
- Cheaper than persistent storage (no disk writes)
- Useful for reentrancy locks, callbacks, flash loans
Edge Cases
Uninitialized Values
Max Uint256 Values
Large Code (EIP-170: 24KB limit)
References
- EIP-1153: Transient Storage Opcodes
- EIP-170: Contract code size limit
- EIP-2929: Gas cost increases for state access
- Yellow Paper - Section 9.3 (Account Storage)

