read_contract
Table function
Invokes eth_call with ABI-aware argument encoding and decodes the returned values into structured columns.
Overloads
read_contract(TRANSPORT, ADDRESS, JSON, VARCHAR, ANY[])
Invokes eth_call using ABI encoding; defaults to the latest block context.
Result columns
| Name | Type |
|---|---|
| ... | ABI-dependent column(s) |
1
-- Read WETH balance of Vitalik's address on the provided transport
2
SELECT *
3
FROM read_contract(
4
$transport,
5
'0x4200000000000000000000000000000000000006'::ADDRESS,
6
'[
7
{
8
"type": "function",
9
"name": "balanceOf",
10
"stateMutability": "view",
11
"inputs": [{ "name": "account", "type": "address" }],
12
"outputs": [{ "name": "", "type": "uint256" }]
13
}
14
]'::JSON,
15
'balanceOf',
16
['0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'::ADDRESS]
17
);
Notebook ready in readonly mode.
read_contract(TRANSPORT, ADDRESS, JSON, VARCHAR, ANY[], STRUCT(block_tag VARCHAR, block_number BLOCK_NUMBER))
Adds a block_tag/block_number override for deterministic historical calls.
Parameters
Result columns
| Name | Type |
|---|---|
| ... | ABI-dependent column(s) |
1
-- Pin the call to a specific tag or height
2
SELECT *
3
FROM read_contract(
4
$transport,
5
'0x4200000000000000000000000000000000000006'::ADDRESS,
6
'[
7
{
8
"type": "function",
9
"name": "balanceOf",
10
"stateMutability": "view",
11
"inputs": [{ "name": "account", "type": "address" }],
12
"outputs": [{ "name": "", "type": "uint256" }]
13
}
14
]'::JSON,
15
'balanceOf',
16
['0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'::ADDRESS],
17
STRUCT_PACK(
18
block_tag := 'finalized',
19
block_number := 36760640::BLOCK_NUMBER
20
)
21
);
Notebook ready in readonly mode.