Create a block context
ChainState(chain_id, block_id)
Returns a
ChainState object. For consistent multiple reads, first resolve a block ID and then reuse the same object.
Block queries
These are class methods, called directly onChainState.
Block dictionaries include
id, height, and timestamp. timestamp is Unix time in seconds. Additional fields may vary by chain.
Account state
get_address_nonce() uses the latest block, so it does not return a historical nonce from the chain object’s context. The other three instance methods use that object’s block context.
Single contract call
chain.call(contract, method, payload, from_addr=None)
Returns decoded values. Multiple outputs can be unpacked; integers are Python
int values.
Batch contract calls
['USDC', 6].
For example, replace
.values() with .dict('symbol', 'decimals') to get {'symbol': 'USDC', 'decimals': 6}.
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 simulated reads without changing on-chain state. See the Leafage source for field definitions and full examples.