Functions to decode raw EVM events and function calls in DuneSQL.
decode_evm_event(abi: varchar, input: table [, topics: descriptor [, data: descriptor [, null_on_error: boolean]]])
→ table
Decodes EVM events according to the provided ABI; returns each decoded parameter as a separate column as defined in the inputs’ name and type.
abi
(required, type: varchar): This is the event specification in JSON format. The passed value must be constant at analysis time. Each input specified in the ABI results in one output column.input
(required, type: table): This is the table or query providing the topics and data for event decoding. The passed table or query must be preceded with the TABLE
keyword.topics
(optional, type: descriptor, default: DESCRIPTOR(topic0, topic1, topic2, topic3)): Specifies which columns of the input contain the topics. Null topics are ignored by the function.data
(optional, type: descriptor, default: DESCRIPTOR(data)): Specifies which column of the input contains the data.null_on_error
(optional, type: boolean, default: true): Specifies the function behavior if a decoding error occurs. By default, the error is suppressed, and null values are produced._arg0
, _arg1
, etc., if not named in the ABI. Columns are ordered by the indexed
property in the ABI, with indexed
inputs first.
decode_evm_event
function outputs all columns from the input table, i.e. the returned table will have one column for each ABI argument, followed by all columns of the INPUT table.decode_evm_function_call(abi: varchar, data: table [, input: descriptor [, output: descriptor [, null_on_error: boolean]]])
→ table
Decodes EVM function calls according to the provided ABI; returns each decoded input and output parameter as separate columns as defined in the ABI.
abi
(required, type: varchar): This is the function call specification in JSON format. The passed value must be constant at analysis time. The query engine uses this argument to determine the names and types of the result columns. Each input and output specified in the ABI results in one output column.data
(required, type: table): This is the table or query providing the input and output columns for function call decoding. The passed table or query must be preceded with the TABLE
keyword.input
(optional, type: descriptor, default: DESCRIPTOR(input)): Specifies which columns of the data table contain the input varbinary for the function call. By default, the function will use the column named input
.output
(optional, type: descriptor, default: DESCRIPTOR(output)): Specifies which columns of the data table contain the output varbinary for the function call. By default, the function will use the column named output
.null_on_error
(optional, type: boolean, default: true): Specifies the function behavior if a decoding error occurs. By default, the error is suppressed, and null values are produced._input0
, _input1
, etc., and _output0
, _output1
, etc., if not named in the ABI. If two arguments (either input or output) have the same name in the ABI, the last declared argument will take precedence.
decode_evm_function_call
function outputs all columns from the input table, i.e. the returned table will have one column for each ABI argument, followed by all columns of the DATA table.topic0
and filter for the event emittedtopic0
by going to a block explorer. We recommend finding an example transaction. Then, go to the “Logs” tab, identify the event you want, and grab the topic0
from there.topic0
is a keccak256 hash of the event’s name concatenated with the types of its indexed parameters, without any spaces.input
and filter for the function calledinput
by going to a block explorer. We recommend finding an example transaction. In the “Overview” tab, scroll down and click on “click to show more”. Then grab the MethodId in the Input Data filed.starts_with(input, <MethodID>)
to filter for the function call now.