Skip to main content
Schema: crosschain.evm Table: dim_contract_abis Type: View

What

This table contains Application Binary Interfaces (ABIs) for smart contracts deployed on EVM blockchains. ABIs define the contract’s functions, events, and data structures, enabling the decoding of raw blockchain data into human-readable format. It contains a column for the blockchain the contract is deployed on, which is an important filter and join key. See evm.dim_chains for a list of all supported EVM chains.

Key Use Cases

  • Decoding raw event logs into human-readable format
  • Identifying contract functions and their parameters
  • Enabling interaction with smart contracts programmatically
  • Analyzing contract patterns and implementations across chains
  • Supporting automated contract verification and bytecode matching

Important Relationships

  • Powers evm__ez_decoded_event_logs: ABIs enable event decoding
  • Join with evm__dim_contracts: Use contract_address and blockchain for contract metadata
  • Enables fact_decoded_event_logs: Raw to decoded transformation

Commonly-used Fields

  • contract_address: The contract’s blockchain address
  • abi: The contract’s Application Binary Interface in JSON format
  • abi_source: The origin of the ABI data (explorer verified, user submitted, bytecode matched)
  • bytecode: The compiled contract code deployed on-chain
  • created_timestamp: When the ABI was added to the database
  • blockchain: The blockchain the contract is deployed on

Sample queries

Find Contracts Without ABIs
-- Identify popular contracts needing ABIs
WITH contract_activity AS (
    SELECT 
        contract_address,
        COUNT(*) AS event_count
    FROM crosschain.evm.fact_event_logs
    WHERE block_timestamp >= CURRENT_DATE - 7 AND blockchain = 'ethereum'
    GROUP BY 1
    HAVING COUNT(*) > 100
)
SELECT 
    ca.contract_address,
    c.name AS contract_name,
    ca.event_count,
    c.created_block_timestamp
FROM contract_activity ca
LEFT JOIN crosschain.evm.dim_contract_abis abi ON ca.contract_address = abi.contract_address
LEFT JOIN crosschain.evm.dim_contracts c ON ca.contract_address = c.address AND c.blockchain = 'ethereum'
WHERE abi.abi IS NULL
    OR abi.abi = '[]'
ORDER BY ca.event_count DESC
LIMIT 100;
Analyze ABI Functions and Events
-- Extract event signatures from ABIs
WITH abi_events AS (
    SELECT 
        contract_address,
        abi_source,
        f.value:name::string AS event_name,
        f.value:type::string AS entry_type
    FROM crosschain.evm.dim_contract_abis,
    LATERAL FLATTEN(input => PARSE_JSON(abi)) f
    WHERE f.value:type::string = 'event'
        AND abi IS NOT NULL
        AND blockchain = 'ethereum'
)
SELECT 
    event_name,
    COUNT(DISTINCT contract_address) AS contracts_with_event,
    ARRAY_AGG(DISTINCT abi_source) AS sources
FROM abi_events
GROUP BY 1
ORDER BY 2 DESC
LIMIT 50;
Bytecode Matching Effectiveness
-- Analyze bytecode matching success
SELECT 
    DATE_TRUNC('week', created_timestamp) AS week,
    COUNT(CASE WHEN abi_source = 'bytecode_matched' THEN 1 END) AS bytecode_matched,
    COUNT(CASE WHEN abi_source = 'user_submitted' THEN 1 END) AS user_submitted,
    COUNT(CASE WHEN abi_source LIKE '%explorer%' THEN 1 END) AS explorer_verified,
    COUNT(*) AS total_new_abis
FROM crosschain.evm.dim_contract_abis
WHERE created_timestamp >= CURRENT_DATE - 90
GROUP BY 1
ORDER BY 1 DESC;
Common Contract Patterns
-- Find contracts sharing bytecode (proxy patterns, clones)
WITH bytecode_groups AS (
    SELECT 
        bytecode,
        COUNT(DISTINCT contract_address) AS contract_count,
        ARRAY_AGG(DISTINCT contract_address) AS contracts,
        MAX(abi) AS sample_abi
    FROM crosschain.evm.dim_contract_abis
    WHERE bytecode IS NOT NULL
        AND LENGTH(bytecode) > 100  -- Exclude minimal contracts
    GROUP BY 1
    HAVING COUNT(DISTINCT contract_address) > 5
    AND blockchain = 'ethereum'
)
SELECT 
    contract_count,
    ARRAY_SIZE(contracts) AS unique_addresses,
    LEFT(bytecode, 20) || '...' AS bytecode_prefix,
    CASE 
        WHEN sample_abi LIKE '%proxy%' THEN 'Likely Proxy'
        WHEN sample_abi LIKE '%clone%' THEN 'Likely Clone'
        ELSE 'Standard Pattern'
    END AS pattern_type
FROM bytecode_groups
ORDER BY contract_count DESC
LIMIT 20;

Columns

Column NameData TypeDescription
BLOCKCHAINTEXTThe blockchain the record occurred on. See evm.dim_chains for a list of all EVM chains. Format: VARCHAR Example: ‘ethereum’ Usage: Filtering by blockchain Joining across tables Analyzing chain-specific patterns
CONTRACT_ADDRESSTEXTUnique identifier - the deployed contract’s blockchain address. Example: ‘0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48’
ABIVARIANTThe contract’s Application Binary Interface in JSON format, containing function and event definitions that enable interaction with the smart contract. Example: ‘[{"name":"transfer","type":"function","inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"}],“outputs”:[{"name":"","type":"bool"}]}]‘
ABI_SOURCETEXTThe origin of the ABI data, indicating trust level and collection method. Example: ‘etherscan’
BYTECODETEXTThe compiled contract code deployed on-chain, used for bytecode matching and identifying identical contracts. Example: ‘0x608060405234801561001057600080fd5b50…’
DIM_CONTRACT_ABIS_IDTEXTDIM_CONTRACT_ABIS_ID column
INSERTED_TIMESTAMPTIMESTAMP_NTZINSERTED_TIMESTAMP column
MODIFIED_TIMESTAMPTIMESTAMP_NTZMODIFIED_TIMESTAMP column