Token Contract Table
Description
Network-specific token contract metadata. Join for names/symbols/decimals and for cross-chain asset mapping.
Schema
| Field | Type | Description |
|---|---|---|
| id | STRING | Deterministic ID (truncated MD5 of network_id, address). |
| slug | STRING | Canonical asset identifier (e.g., CoinGecko slug eth, usd-coin). |
| name | STRING | Token name (e.g., Ethereum, USD Coin). |
| symbol | STRING | Ticker (e.g., ETH, USDC). |
| network_id | STRING | FK → network.id. |
| decimals | INTEGER | Decimal precision (e.g., 18 for ETH, 6 for USDC). |
| address | STRING | Checksummed contract address (lowercase for joins). |
| ingested_at | TIMESTAMP | Insert 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;