Flipside Docs
  • Welcome to Flipside!
    • Welcome to Flipside
    • Growth Services
    • Data
      • Choose your Flipside plan
        • Free
        • Builder
        • Pro
          • Get Started in Snowflake
          • Incremental Table Pattern
          • Copy Data from Snowflake to AWS
          • Copy Data from Snowflake to GCP
          • Copy Data from Snowflake to Azure
        • Snowflake Data Shares
          • Mounting a Snowflake Data Share
    • Earn
    • Community
  • Data
    • Flipside Data
      • Table Docs by Chain
      • Data Modeling Approach
      • Labels
        • Centralized Exchange Label Type
        • Decentralized Exchange Label Type
        • Operator Label Type
        • Chain Admin Label Type
        • Decentralized Finance Label Type
        • NonFungible Tokens Label Type
        • Games Label Type
        • Bridge Label Type
        • Decentralized Applications Label Type
        • Token Label Type
        • Flotsam Label Type
      • Tags
      • Table Freshness Targets
      • Contribute to Our Data
        • Contract Decoding & ABIs
        • How to Add Your Own Tags
        • Community Curation
          • Getting Started
            • Contribution Workflow
          • Model Standards
            • dbt Tips
          • PR Checklist
    • Data Products
      • Data Studio (SQL Analysts)
        • Get Started
          • Write/fork your first query
        • Flipside AI
        • Studio in Depth
          • Query Editor
            • Query Referencing
            • Pro Tips for Querying
            • Keyboard Shortcuts
            • Hex-to-Integer Function
          • Create a Chart
            • Advanced Visualization
          • Build a Dashboard
            • Markdown Reference
          • Team Accounts
        • Tutorials
          • How to Analyze Web3 Data
          • Video Tutorials
            • Overview of Schemas & Tables
            • Ethereum Tutorials
              • Getting Started with Decoded Ethereum Events
              • Getting Started with Ethereum Balances
              • Block Level and Daily Balances
              • Finding Centralized Exchange Flows
            • Solana Tutorials
              • Solana Schema & Tables: Video Walkthrough
              • Solana Specialty Tables: Video Walkthrough
              • Exploring Transactions in solana.events
            • THORChain Tutorials
              • THORChain Schema & Tables
              • Calculating IL for THORChain
          • More Tools & Resources
        • Get Inspired
      • LiveQuery
        • Get Started
        • LiveQuery in Depth
          • Functions
            • 🤝Partner Functions
            • 🧙‍♂️EVM Functions
              • 💡Seaport: Real-time Orders
              • 💡WETH Pool Balances
              • 💡General EVM Node Queries
            • 🤖API Functions
              • 💡Query TheGraph
              • 💡Query Defi Llama
            • ⚙️Utility Functions
              • 💡Hex Converters
              • 💡JSON RPC Request Builder
              • 💡EVM Logs Decoder
              • 💡Keccak256 Encoder
          • QuickNode Setup Guide
        • Secrets Manager
        • Get Inspired
      • Snowflake
      • API/SDK (Developers)
        • Get Started - Your first API call in < 2 min
        • SDK in Depth
          • JSON RPC methods
          • Run A Query
          • Query Results
          • Pagination
          • Sorting
          • Filtering
          • Query Seconds
          • Caching (maxAgeMinutes)
          • Rate Limits
          • Errors
          • More Examples
          • Archive
            • [ARCHIVED] JS/TS SDK
            • ShroomDK Migration Guide
            • [LEGACY] R
        • Tutorials
          • Have Questions?
        • Get Inspired
    • Insights and Tools
  • Earn
    • Flipside Earn
    • Onchain Rewards
      • Quests
    • Analyst Rewards
      • Top Dashboards
        • Top Dashboard Guidelines
        • Skill Tree
      • Ambassador Program
      • Direct to Analyst Commissions
    • Wallet Management
    • Tax Center
  • Support
    • General Support
    • Open a Ticket
      • That email doesn't look quite right
    • 🌟Product Special Releases
      • 2025
        • 2025-02-06 | EVM Blockchain Standardization
          • Table Change Overview
      • 2024
        • 2024-06-13 | Solana native and wrapped addresses
        • 2024-05-01 | Improvements to Pricing Data
          • Actions for Data Studio Users
          • Actions for API Users
          • Action for Data Share Users
    • 🗒️Release Notes
      • 2025
        • 2025-05-01 | Release Notes
        • 2025-04-17 | Release Notes
        • 2025-04-03 | Release Notes
        • 2025-03-20 | Release Notes
        • 2025-03-06 | Release Notes
        • 2025-02-20 | Release Notes
        • 2025-02-06 | Release Notes
        • 2025-01-23 | Release Notes
      • 2024
        • 2024-12-24 | Release Notes
        • 2024-12-12 | Release Notes
        • 2024-11-27 | Release Notes
        • 2024-11-14 | Release Notes
        • 2024-10-31 | Release Notes
        • 2024-10-03 | Release Notes
        • 2024-10-17 | Release Notes
        • 2024-09-19 | Release Notes
        • 2024-09-05 | Release Notes
        • 2024-08-22 | Release Notes
        • 2024-08-08 | Release Notes
        • 2024-07-25 | Release Notes
        • 2024-07-11 | Release Notes
        • 2024-06-27 | Release Notes
        • 2024-06-14 | Release Notes
        • 2024-05-30 | Release Notes
        • 2024-05-16 | Release Notes
        • 2024-05-02 | Release Notes
        • 2024-04-18 | Release Notes
        • 2024-04-05 | Release Notes
        • 2024-03-18 | Release Notes
        • 2024-03-05 | Release Notes
        • 2024-02-20 | Release Notes
        • 2024-02-05 | Release Notes
    • 📊Studio Change log
  • Flipside Community
    • Get Started
    • Ambassador Program
    • Join Our Discord
    • Join Our Guild
Powered by GitBook
On this page
  • UDF_EVM_DECODE_LOG()
  • Syntax
  • Arguments
  • Sample Queries
  • Other Notes

Was this helpful?

  1. Data
  2. Data Products
  3. LiveQuery
  4. LiveQuery in Depth
  5. Functions
  6. Utility Functions

EVM Logs Decoder

This function will decode EVM Logs given the appropriate ABI

UDF_EVM_DECODE_LOG()

Please note there are limitations on this function. It is not recommend to process more than 100,000 records at a time. Anything over that will likely cause timeouts. If you need large amounts of decoded data, please use the snowflake tables.

Syntax

utils.udf_evm_decode_log(
    abi, 
    data
)

Arguments

Required:

  • abi (array) - The ABI (application binary interface) for the smart contract

  • data (object) - The event data to decode

Sample Queries

-- This will decode logs for Seaport 1.5
SELECT 
    block_number,
    tx_hash,
    event_index,
    OBJECT_CONSTRUCT('topics', topics, 'data', data, 'address', contract_address) AS event_data,
    abi,
    utils.udf_evm_decode_log(abi, event_data) AS decoded_data,
    decoded_data[0]:name::string AS event_name
FROM 
    ethereum.core.fact_event_logs
JOIN 
    ethereum.core.dim_contract_abis
USING 
    (contract_address)
WHERE 
    block_timestamp > current_date - 2
    AND contract_address = LOWER('0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC') --seaport 1.5
    AND tx_status = 'SUCCESS'
LIMIT 
    10;


-- USDC (Proxy Contract) Example 
-- this query will decode transfer events for USDC using the latest proxy ABI
-- if you are decoding across large ranges, you may need to incorporate the start and end block

WITH contract_abi AS (
    SELECT
        abi,
        parent_contract_address AS contract_address,
        event_signature,
        start_block,
        end_block
    FROM
        crosschain.core.dim_evm_event_abis
    WHERE
        blockchain = 'ethereum'
        AND parent_contract_address = LOWER('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48') -- USDC
        AND event_name = 'Transfer' -- Transfer event
    QUALIFY ROW_NUMBER() OVER (ORDER BY end_block DESC) = 1 -- USDC has more than one proxy, we want the latest
)

SELECT
    block_number,
    tx_hash,
    event_index,
    topics,
    data,
    OBJECT_CONSTRUCT('topics', topics, 'data', data, 'address', a.contract_address) AS event_data,
    abi,
    utils.udf_evm_decode_log(abi, event_data) AS decoded_data,
    decoded_data[0]:name::string AS event_name
FROM
    ethereum.core.fact_event_logs l
JOIN
    contract_abi a
    ON a.contract_address = l.contract_address
    AND a.event_signature = l.topics[0]::string
WHERE
    block_timestamp > current_date - 2
    AND tx_status = 'SUCCESS'
LIMIT 10;

Other Notes

  • Contracts that use proxies can prove challenging. If contract A is emitting events, but it uses proxy contract B, you likely need to use the ABI from contract B to decode the emitted events from contract A.

  • If we do not have the ABI, and you do, but do not want to give it to us or wait for us to ingest it, you can input ABIs manually into this function. You will likely need to wrap your ABI text in a parse_json() function.

  • You can input ABIs at an individual event level if you choose, however if you are looking at more than one type of emitted event, you maybe need to add additional join keys on the topics / event signature. crosschain.core.dim_evm_event_signatures might be helpful for you here, along with the keccak256 function.

PreviousJSON RPC Request BuilderNextKeccak256 Encoder

Last updated 1 year ago

Was this helpful?

The Flipside tables contain millions of ABIs (dim_contract_abis). We likely have the one you are looking for. If we do not, please submit ABIs . Submitted ABIs will be available within 36 hours.

⚙️
💡
here