Table description

This table contains flattened out details for records in the actions table of the FUNCTION_CALL type.

Column Descriptions

ColumnDescriptionType
block_dateThe date of the block where the function call occurred.date
block_timeThe time when the block containing the function call was produced.timestamp(3) with time zone
block_heightThe block height at the time of the function call.bigint
block_hashThe unique hash of the block containing the function call.varchar
chunk_hashThe hash of the chunk where the function call is recorded.varchar
shard_idShard ID where the function call was executed.bigint
tx_hashThe transaction hash containing the function call.varchar
tx_fromThe account that initiated the function call.varchar
tx_toThe account receiving the function call.varchar
tx_statusStatus of the function call (success or failure).varchar
call_method_nameThe method being called in the function call.varchar
args_parsedParsed (decoded) arguments for the function call.varchar
call_gasGas attached to the function call.bigint
call_depositAmount of NEAR tokens attached to the function call.varchar
call_args_base64Base64 encoded arguments of the function call.varchar
index_in_action_receiptThe index of the function call within the receipt.integer
receipt_idThe receipt ID associated with the function call.varchar
gas_priceThe gas price paid for executing the function call.bigint
receipt_predecessor_account_idThe ID of the predecessor account for the receipt.varchar
receipt_receiver_account_idThe ID of the receiver account for the receipt.varchar
receipt_conversion_gas_burntThe gas burnt during the conversion of the receipt.bigint
receipt_conversion_tokens_burntThe amount of raw NEAR burnt during the conversion of the receipt.uint256
execution_gas_burntAmount of gas burnt during the execution of the function call.bigint
execution_tokens_burntAmount of raw NEAR token burnt during the execution of the function call.uint256
execution_statusThe status of the execution outcome of the function call.varchar
execution_outcome_receipt_idsArray of receipt IDs created as a result of the function call.array(varchar)
updated_atThe time when this function call record was last updated.timestamp(3) with time zone
ingested_atThe time when this function call data was ingested into Dune.timestamp(3) with time zone
processed_timeThe time when the function call was processed.timestamp(3) with time zone

Table Sample

Data Manipulation Tips

The actions data in NEAR can be complicated and nested, causing it hard to analyze sometimes. So here we give two examples on how to work array and json data to make it easier to analyze.

Explode array of rows into separate rows with defined fields

When the action type is “DELEGATE_ACTION”, the action_delegate_delegate_action_actions becomes an array of size n with rows of fields. We can utilize CROSS JOIN UNNEST to first explode the array, then use . directly to access the fields in the row.

Reference query can be found here.

with exploded as (
    select block_date
        , block_height as block_height_executed
        , tx_hash
        , receipt_id -- receipt for this action (there are many actions included in one txn)
        , execution_status
        
        , cardinality(action_delegate_delegate_action_actions) as delegated_action_size -- how many function calls are being delegated
        
        , action_delegate_delegate_action_sender_id as action_from 
        , action_delegate_delegate_action_receiver_id as action_to 
        
    
        -- Explode the array into rows
        , actions.value as action_data
        , actions.index as delegated_action_index
        , action_delegate_delegate_action_actions as raw_delegated_actions -- raw nested list of delegated actions
        
    /* explode by doing cross join unnest here*/    
    from near.actions CROSS JOIN UNNEST(action_delegate_delegate_action_actions) WITH ORDINALITY as actions(value, index)
    where action_kind = 'DELEGATE_ACTION'
        and cardinality(action_delegate_delegate_action_actions) >= 2
        and receipt_id = '6DB2AzkLXzoU9CMj9GKSZi7y8dGxVrqrbtBsfpLVQCQ8'
        and block_date = date('2024-09-17')
        and block_height = 128251854
)

select block_date
    , block_height_executed
    , tx_hash
    , receipt_id 
    , execution_status
    , delegated_action_size -- how many function calls are being delegated
    
    , action_from 
    , action_to 
    
    -- , typeof(action_data) -- row(args varchar, deposit varchar, gas bigint, method_name varchar)
    
    /* below is how you can access the delegated function call info */
    , action_data.args as function_call_args
    , action_data.deposit as function_call_deposit
    , action_data.gas as function_call_gas
    , action_data.method_name as function_call_method_name
    , delegated_action_index
    
    , raw_delegated_actions -- raw nested list of delegated actions
from exploded 

Extract fields from JSON string

When the action type is “FUNCTION_CALL”, the action_function_call_args_parsed becomes a JSON string. We can utilize json_extract with $.<field_name> syntax to extract the fields from the JSON string.

Reference query can be found here.

select block_date
    , block_height as block_height_executed
    , tx_hash
    , receipt_id -- receipt for this action (there are many actions included in one txn)
    , execution_status
    
    , receipt_predecessor_account_id as action_from
    , receipt_receiver_account_id as action_to
    
    -- , typeof(args_parsed) as data_type 
    /* This is how you can get fields within each parsed function call args 
        - first examine the fields in the args_parsed for the tye of method `call_method_name`
        - then parse accordingly
    */
    , json_extract(args_parsed, '$.receiver_id') AS receiver_id
    , json_extract(args_parsed, '$.amount') AS amount
    , json_extract(args_parsed, '$.memo') AS memo
    
    , call_method_name as call_method_name
    , args_parsed as raw_call_args
    , call_gas as call_gas
    , call_deposit as call_deposit
    , call_args_base64
    
    , *
from near.function_call -- near.actions
where 1=1
    and block_date = date('2023-09-15')
    and call_method_name = 'ft_transfer'
limit 10