Loading

call

Scalar function

Invokes eth_call using the provided transport, target address, and calldata, returning the raw bytes.

call(TRANSPORT, ADDRESS, BLOB)

Parameters

NameType
transportTRANSPORT
toADDRESS
dataBLOB

Returns

NameType
resultBLOB
1
-- Check the WETH balance of Vitalik's address via balanceOf
2
WITH transport AS (
3
SELECT http_transport('https://mainnet.optimism.io') AS transport
4
),
5
abi AS (
6
SELECT '[
7
{
8
"type": "function",
9
"name": "balanceOf",
10
"stateMutability": "view",
11
"inputs": [{ "name": "account", "type": "address" }],
12
"outputs": [{ "type": "uint256" }]
13
}
14
]'::JSON AS abi_json
15
),
16
calldata AS (
17
SELECT encode_function_data(abi.abi_json, 'balanceOf', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'::ADDRESS) AS data
18
FROM abi
19
)
20
SELECT call(transport.transport,
21
'0x4200000000000000000000000000000000000006'::ADDRESS,
22
calldata.data)::UINT256 AS balance
23
FROM transport, calldata;
Notebook ready in readonly mode.

call(TRANSPORT, ADDRESS, BLOB, BIGINT)

Adds an explicit block height (or alias like 'latest') for deterministic historical calls.

Parameters

NameType
transportTRANSPORT
toADDRESS
dataBLOB
block_numberBIGINT

Returns

NameType
resultBLOB
1
-- Pin Vitalik's balance check to block 36,760,640
2
WITH transport AS (
3
SELECT http_transport('https://mainnet.optimism.io') AS transport
4
),
5
abi AS (
6
SELECT '[
7
{
8
"type": "function",
9
"name": "balanceOf",
10
"stateMutability": "view",
11
"inputs": [{ "name": "account", "type": "address" }],
12
"outputs": [{ "type": "uint256" }]
13
}
14
]'::JSON AS abi_json
15
),
16
calldata AS (
17
SELECT encode_function_data(abi.abi_json, 'balanceOf', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'::ADDRESS) AS data
18
FROM abi
19
)
20
SELECT call(transport.transport,
21
'0x4200000000000000000000000000000000000006'::ADDRESS,
22
calldata.data,
23
36760640)::UINT256 AS balance
24
FROM transport, calldata;
Notebook ready in readonly mode.