Why On-Chain Token Data Now Belongs in Web2 Fintech
Prediction markets, on-chain tokens, and DeFi are no longer niche.
Pew reports that monthly trading volume on Kalshi and Polymarket jumped from under $5B in September 2025 to about $24B by April 2026. At the same time, consumer apps and brokerages are racing to add crypto and prediction market exposure next to stocks and ETFs.
If you run a Web2-style fintech stack—portfolios, P&L, charts, or risk—you now need:
- Reliable, normalized token data across 80+ networks
- Trading-grade prices and charts for long-tail assets
- A way to map on-chain assets to your existing off-chain identifiers and models
This guide walks through concrete best practices for integrating on-chain token data into existing fintech systems, using Codex as the reference data API.
Principle 1: Use Canonical IDs, Not Symbols
Token symbols are ambiguous. Canonical IDs are not.
There are many USDTs and PEPEs across chains and even on the same chain. If you key assets purely by symbol, your portfolio and risk models will eventually misattribute balances or prices.
Reliable pattern for token identity:
- Use chain + contract address as the canonical ID
- Codex uses
address:networkIdfor token IDs - Standards like CAIP‑2/CAIP‑19 define chain-agnostic blockchain and asset identifiers you can adopt or map to
Practical recommendations:
- In your core data model, represent tokens as:
token_id(internal surrogate key)network_id(or CAIP‑2chain_id)contract_address(or mint address)- Optional:
caip19_idfor future interoperability
- Treat symbol and name as metadata, not as primary keys
Using Codex as the source of truth:
- Use the
tokenand token-listing endpoints to fetch:addressnetworkIddecimalssymbol,name(best-effort metadata)isScamto filter bad assets early
- Persist
address + networkIdas your canonical foreign key from:- Positions and balances
- Trades and fills
- Chart and OHLC caches
This single decision avoids most of the “wrong asset” bugs that show up when a new meme coin launches.
Principle 2: Store Raw Units and Display Units Separately
On-chain token balances are stored as integers in base units, not human-readable amounts.
The ERC‑20 spec explicitly says decimals() is optional, and many tokens don’t implement it correctly. If you only store “display” amounts, you lose the ability to recompute or adjust if metadata changes.
Best-practice pattern:
For every on-chain amount (balance, transfer, trade size), store two fields:
amount_raw– integer as seen on-chain (e.g.,1000000)amount– human-readable decimal (e.g.,1.0for a 6-decimal token)
Codex’s approach you can mirror:
- Codex always ingests raw on-chain amounts and then exposes normalized values using the token’s
decimals - Key fields like balances, pair stats, and
getBarschart data are already decimals-adjusted
Implementation steps:
-
Land raw events as-is
- From Codex webhooks or subscriptions, capture payloads into a raw store (e.g., BigQuery JSON or Snowflake
VARIANT) - Do not coerce numeric strings prematurely
- From Codex webhooks or subscriptions, capture payloads into a raw store (e.g., BigQuery JSON or Snowflake
-
Join token metadata
- Use Codex
tokenquery keyed byaddress + networkId - Persist
decimalsalongside the token
- Use Codex
-
Derive normalized amounts in a curated layer
amount = amount_raw / POWER(10, decimals)- In SQL marts, materialize both
amount_rawandamountcolumns
This allows you to fix decimals if a token’s metadata is corrected, without re-ingesting chain logs.
Principle 3: Treat Price Types as Separate Concepts
In Web2 fintech, you already separate:
- Last traded price
- VWAP
- Reference price for risk/P&L
On-chain token data needs a similar separation. Codex’s API design reflects this.
Key price concepts and which Codex endpoints to use:
- Portfolio/reference price (what you show in balances):
- Use
getTokenPricesfor fast, aggregated quotes - Prices are aggregated across valid pools
- Use
- Venue-specific price (per DEX or pair):
- Use
pairMetadataand pair-level endpoints - Preserve which pool/venue provided the price
- Use
- Chart/analytics price (OHLC, candles):
- Use
getBarswith appropriate resolution andcurrencyCode(USD vs native) - Note Codex caps responses at 1,500 datapoints per request; sub-1m resolutions only go back 24 hours
- Use
How to model this in your data warehouse:
-
Define three separate data sets:
token_reference_prices– output ofgetTokenPricesfor portfolio valuationvenue_prices– pair-level prices keyed bypair_idor venuetoken_ohlc– candles fromgetBars, keyed by token + resolution
-
Persist a
price_typedimension (e.g.,REFERENCE,VENUE,CHART), instead of trying to funnel everything into a singlepricecolumn.
This makes it much easier to:
- Explain P&L vs execution slippage
- Offer users a toggle between “global price” and “DEX price”
- Backtest strategies using historical pair-level data
Principle 4: Design for Push-First, Not Poll-First, Real-Time
Polling APIs is simple but expensive and brittle at scale.
Most fintech UIs—trading terminals, live portfolios, alerting—are sensitive to latency and staleness. Spamming REST endpoints every second does not scale.
Codex is built with push-first real-time delivery:
- GraphQL queries for on-demand reads
- Subscriptions for continuously changing data
- Webhooks for events with full payloads, deduplication, and hash verification
Recommended pattern:
- Use webhooks and subscriptions to:
- Capture trades, transfers, position changes, and prediction market events
- Trigger enrichment jobs in your backend
- Use REST/GraphQL queries for:
- Backfills and historical syncs
- On-demand analytics and drill-down
System design checklist:
- Implement idempotent consumers using Codex webhook IDs or hashes
- Buffer incoming events into a streaming platform or queue (e.g., Kafka, Pub/Sub, SQS)
- Land events into your raw storage (BigQuery/Snowflake) before transforming
This approach minimizes API traffic, while keeping user-facing data fresh and consistent.
Principle 5: Map On-Chain Assets to Off-Chain Identifiers
To make crypto “feel native” in a Web2 fintech product, you must connect on-chain tokens to your existing entities:
- Users and KYC records
- Portfolios and accounts
- Instruments, tickers, and risk buckets
Core mapping patterns:
-
User ↔ Wallet mapping
- Maintain a
user_walletstable with:user_idwallet_addressnetwork_id- Status (self-custodied, managed wallet, testnet)
- Use Codex wallet endpoints to aggregate balances across chains
- Maintain a
-
Internal instrument IDs ↔ On-chain tokens
- Extend your
instrumentstable with:token_idnetwork_idcontract_address- Optional:
caip19_id
- For synthetic products (e.g., a token basket), map multiple on-chain tokens to a single instrument
- Extend your
-
Prediction markets ↔ Asset universe
- For trading or analytics frontends, treat each market as a first-class instrument:
market_id(internal)venue(e.g.,POLYMARKET,KALSHI)codex_market_id(if using Codex prediction market endpoints)- Event metadata (question, resolution date, underlying category)
- For trading or analytics frontends, treat each market as a first-class instrument:
Codex’s prediction market endpoints (filterPredictionEvents, filterPredictionMarkets, trader stats) help you normalize data from venues that otherwise expose incompatible APIs.
Principle 6: Integrate Codex with BigQuery and Snowflake the Right Way
Most fintech stacks already centralize analytics in BigQuery or Snowflake.
The simplest pattern is:
- Land raw Codex payloads in a semi-structured column
- Build curated, typed marts for pricing, positions, markets, and analytics
BigQuery + Codex
BigQuery’s native JSON support is essentially schema-on-read:
- JSON columns cannot be partitioned or clustered directly
- Nesting depth is limited to 500 levels
- Ingestion via batch loads or Storage Write API
Recommended architecture:
-
Raw layer
- Table:
raw_codex_events - Columns:
event_time,source(e.g.,webhook,subscription),payload(JSON) - Partition by
event_datederived fromevent_time
- Table:
-
Transform layer (using SQL or Dataflow):
- Extract fields like
networkId,address,amount_raw,event_type - Join to
tokensandwalletsdimension tables
- Extract fields like
-
Curated marts:
token_balances(per user/wallet/token)token_trades(per trade with price, venue, slippage)prediction_positions(per event/market/outcome)
This pattern lets you evolve schemas without constant migrations.
Snowflake + Codex
Snowflake’s guidance on semi-structured data maps cleanly to on-chain payloads:
- Use
VARIANTwhile query needs are evolving - Flatten into typed columns when you need better pruning and lower costs
VARIANThas a max size of 128 MB uncompressed (not usually an issue for Codex payloads)
Recommended architecture:
-
Landing table
raw_codex_events(payload VARIANT, event_time TIMESTAMP, source STRING)
-
Staging views
- Access nested fields using
payload:<field>
- Access nested fields using
-
Typed tables when patterns stabilize:
trades_factwith numeric columns foramount_raw,amount,price,feetokens_dimwith canonical IDs and metadata
This approach gives your data and quant teams fast, SQL-native access to on-chain data without losing the flexibility of semi-structured landing zones.
Here’s how the overall flow looks from Codex to your warehouse.

Principle 7: Build Around Reliability, Latency, and Coverage
For trading-adjacent fintech apps, data quality is not negotiable.
When choosing an on-chain data provider, optimize for:
- Reliability & correctness – consistent prices and balances, especially for long-tail tokens
- Low latency – Codex targets sub‑1 second freshness on paid plans
- Coverage – Codex indexes 70M+ tokens, 700M+ wallets, 80+ networks, and 27B+ historical events
Codex positions itself as the fastest and most reliable blockchain data API for token and prediction market data, and it already powers apps like Coinbase, TradingView, Uniswap, Magic Eden, Rainbow, MoonPay, and others.
When benchmarking Codex (or any provider), measure:
- Time-to-first-byte for critical endpoints (
getTokenPrices,getBars) - Freshness of prices vs major CEX quotes
- Coverage for:
- Newly launched tokens
- Launchpad-linked assets
- Less common networks your users might hold
Putting It All Together: Reference Architecture
A pragmatic reference architecture for Web2 fintech teams adding on-chain data:
-
Token & wallet model
- Canonical IDs:
networkId + address - Store
decimals,symbol,name,isScam
- Canonical IDs:
-
Real-time ingestion
- Subscribe to Codex webhooks for transfers, trades, prediction events
- Push into a queue or streaming system
-
Raw data landing
- BigQuery JSON or Snowflake
VARIANTtables for raw payloads
- BigQuery JSON or Snowflake
-
Curated marts
tokens_dim,wallets_dim,markets_dim- Facts for balances, trades, prices, prediction positions
- Separate
REFERENCE,VENUE,CHARTprice types
-
APIs & UI layer
- Portfolio and P&L views backed by reference prices
- Trading views and charts backed by
getBarsand pair stats - Prediction market frontends powered by Codex prediction endpoints
Follow these patterns and you can add “crypto-native” features without rebuilding your entire stack.
FAQ: On-Chain Token Data in Web2 Fintech
1. How should we key on-chain assets in our existing instruments table?
Use a canonical combination of chain + contract address (e.g., networkId + address) rather than symbol. Optionally add a CAIP‑19 ID. Symbols and names should be treated as metadata, not keys.
2. Do we really need to store both raw and normalized token amounts?
Yes. Store amount_raw as the on-chain integer and amount as the decimals-adjusted value. ERC‑20 decimals() is optional and sometimes wrong; keeping raw units lets you fix and re-derive display amounts without re-ingesting data.
3. Which Codex endpoints should we use for portfolio valuation vs charts?
For portfolio valuation, use getTokenPrices to fetch aggregated reference prices. For venue-specific analytics, use pair-level endpoints like pairMetadata. For charts and OHLC, use getBars, respecting its 1,500-datapoint per-request limit and resolution constraints.
4. How do we integrate Codex data into BigQuery or Snowflake?
Land Codex responses as semi-structured data first—JSON in BigQuery, VARIANT in Snowflake. Then build curated SQL tables for tokens, balances, trades, prices, and prediction markets, flattening only the fields you query regularly for better performance.
5. Why use Codex instead of building our own indexers and RPC-based ETL?
Indexing 80+ networks, normalizing 70M+ tokens and 700M+ wallets, and maintaining trading-grade prices is a multi-year infrastructure project. Codex exposes all of this via a unified GraphQL-style API with sub-second latencies, letting your engineers focus on product instead of chain plumbing.
