Skip to main content

Token Contract Table

Description

Network-specific token contract metadata. Join for names/symbols/decimals and for cross-chain asset mapping.

Schema

FieldTypeDescription
idSTRINGDeterministic ID (truncated MD5 of network_id, address).
slugSTRINGCanonical asset identifier (e.g., CoinGecko slug eth, usd-coin).
nameSTRINGToken name (e.g., Ethereum, USD Coin).
symbolSTRINGTicker (e.g., ETH, USDC).
network_idSTRINGFK → network.id.
decimalsINTEGERDecimal precision (e.g., 18 for ETH, 6 for USDC).
addressSTRINGChecksummed contract address (lowercase for joins).
ingested_atTIMESTAMPInsert time (UTC).

Example Queries

Lookup tokens on Ethereum by symbol

SELECT t.*
FROM `defi_prepared.token_contract` t
JOIN `defi_prepared.network` n ON t.network_id = n.id
WHERE n.slug = 'ethereum' AND t.symbol IN ('WETH','USDC');

Convert raw amounts to human units

SELECT
t.symbol,
CAST(1e21 AS NUMERIC) AS raw_amount,
CAST(1e21 AS NUMERIC) / POW(10, t.decimals) AS human_amount
FROM `defi_prepared.token_contract` t
WHERE t.symbol = 'USDC' LIMIT 1;