call_decode
Table function
Decodes ABI-encoded function return data into structured columns using the provided ABI definition.
Overloads
call_decode(JSON, VARCHAR, BLOB)
Parameters
| Name | Type |
|---|---|
| abi | JSON |
| function_name | VARCHAR |
| data | BLOB |
Result columns
No result details documented.
1
-- Decode the balanceOf response produced by eth_call for Vitalik's address
2
WITH transport AS (
3
SELECT http_transport('https://mainnet.optimism.io') AS transport
4
),
5
call_result AS (
6
SELECT call(
7
transport.transport,
8
'0x4200000000000000000000000000000000000006'::ADDRESS,
9
encode_function_data(
10
'[
11
{
12
"type": "function",
13
"name": "balanceOf",
14
"stateMutability": "view",
15
"inputs": [{ "name": "account", "type": "address" }],
16
"outputs": [{ "type": "uint256" }]
17
}
18
]'::JSON,
19
'balanceOf',
20
'0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'::ADDRESS
21
)
22
) AS response
23
FROM transport
24
)
25
SELECT *
26
FROM call_decode(
27
'[{ "type": "function", "name": "balanceOf", "outputs": [{ "type": "uint256" }] }]'::JSON,
28
'balanceOf',
29
call_result.response
30
);
Notebook ready in readonly mode.