try_read_contract_at
Calls a contract function at an explicit block number like read_contract_at; a revert, an address without code or an undecodable return gives NULL instead of an error. A transport, rate-limit or archive failure raises.
Example
Live RPC
API reference
try_read_contract_at(CLIENT, ADDRESS, JSON, VARCHAR, BIGINT, ...args) #
As read_contract_at. A revert, empty return data or a decode failure gives NULL; RPC transport failures, encoding and argument errors still raise.
Inputs
| Name | Type | Use |
|---|---|---|
client | CLIENT Live, pinned, or retained execution CLIENT. Pinned and execution state require the resolved block selector to be latest and reject other selectors. | required positional |
to | ADDRESS Contract address to call. | required positional |
abi | JSON Literal or foldable JSON ABI used for argument encoding and output types. | required positional |
function_name | VARCHAR Literal or foldable ABI function name. | required positional |
block_number | BIGINT Non-negative BIGINT block number. NULL produces NULL without issuing an RPC call. | required positional |
...args dynamic | ANY Pass one SQL value per ABI input. The ABI determines how many values are accepted and how each value is cast. The ABI and function name must be literal or foldable so the return type can be inferred during planning. | positional |
Returns
| Name | Type |
|---|---|
result dynamic | ABI-derived scalar or STRUCT The ABI-decoded value, or NULL when the call reverts, returns no data or does not decode. |