Multicall3
Batched reads through one Multicall3 aggregate3 call.
The EvmRpc is injected and the constructor performs no I/O, so
a cassette or a mock transport plugs in unchanged.
__init__
__init__(self, rpc: EvmRpc, address: str = 0xca11bde05977b3631167028862be2a173976ca11) -> None
Bind the transport and the Multicall3 deployment. No I/O.
address defaults to MULTICALL3_ADDRESS and is
lowercased, so a checksummed override still reaches the wire in
the one casing the rest of the EVM source uses.
Raises:
ValidationError: on an address that is not a 0x-prefixed
40-hex string. It is CONSUMED here, being lowercased and
stored, so it is refused here: the rule rpc.py states
for its own to.
Parameters
rpcrequired, EvmRpcnone
addressoptional, str, default '0xca11bde05977b3631167028862be2a173976ca11'none
Raises
aggregate3
aggregate3(self, calls: Sequence[Call], block_number: int | None = None) -> tuple[CallResult, ...]
Run calls as one aggregate3; the answers, in REQUEST order.
Exactly ONE eth_call is issued for the whole batch, to the
bound Multicall3 address, at block_tag(block_number). An
empty calls issues ZERO requests and returns ().
A call that reverts with allow_failure True is a declared
CallResult failure and does NOT raise; the other
answers are unaffected.
Raises:
ValidationError: on a calls that is not a sequence of
Call, refused on entry and before any HTTP,
since a batch the caller got wrong is caller input.
SourceError: when the decoded result count differs from
len(calls) (both counts are named), when the node
answers the whole eth_call with a JSON-RPC error,
which is what a revert under allow_failure False
produces, when the result is not a 0x-prefixed hex
string, and when the returned bytes do not decode, in
which case the abi ValidationError is the __cause__.
Parameters
callsrequired, Sequence[Call]The batch. One eth_call covers all of them, and an empty list issues no request at all.
block_numberoptional, int | None, default NoneThe block the whole batch reads at. None means latest.