Skip to main content
Leafage reads on-chain state at a specified chain and block. Run these examples in a Chaintable Notebook; they also work in Functions. For Function usage, see Data access. The source contains the full implementation.

Create a block context

EVM(chain_id, block_id='latest')

Account state and contract calls are read at this block. For consistent multiple reads, first resolve a block ID and then reuse the same object.

Block queries

Block dictionaries include id, height, and timestamp. timestamp is Unix time in seconds. Additional fields may vary by chain. Querying another block does not change the object’s own block.

Account state

Contract calls

evm.call(contract, method, args=None, *, from_addr=None)

A single output is returned directly, multiple outputs as a tuple, and no outputs as (); integers are Python int values. Failures raise exceptions.
This reads or simulates a contract call. It does not send a transaction to the chain.

Batch contract calls

The output is USDC 6.

Call(contract, method, args=None, *, from_addr=None)

Describes one call, with the same parameters as evm.call(). Construction validates the address, signature, and arguments locally and raises ContractCallInvalidInputError for invalid input without sending a request. The same Call can run against different EVM objects.

evm.call_many(calls, *, raise_on_error=True)

Returns a list of results in input order, each shaped like an evm.call() result; an empty list returns []. By default, any call that fails to execute or decode raises an exception whose call_index identifies the call. With raise_on_error=False, failed calls return None at their positions and other results are unchanged; invalid input, missing blocks, and service errors still raise.

State overrides

set_block_overrides(value) and set_state_overrides(value) set block and account-state overrides for simulated calls. The corresponding get_*_overrides() methods return current settings. Overrides affect contract calls only, not balance, nonce, code, or storage queries, and they do not change on-chain state. See the Leafage source for field definitions and full examples.