# Best Onchain Data APIs for High‑Traffic Trading Apps: Reorgs, Finality, and Data Consistency

> How blockchain reorgs and finality affect trading app data: confirmation levels by chain, reorg-resilient webhook patterns, and how data APIs handle them.

Source: https://www.codex.io/blog/blockchain-reorgs-application-data
Published: 2026-07-26
Updated: 2026-10-26
Author: Codex

## Best real‑time crypto data API for trading (2024): Reorgs, finality, and data consistency for product teams

If you’re building high‑traffic trading apps, wallets, or prediction‑market frontends, you’re already thinking about **on‑chain data consistency guarantees**, **handling chain reorganizations in production**, and **dealing with reorgs in trading apps**.

This guide explains:

- What reorgs and finality really mean for product and data teams
- How different chains (Ethereum, Bitcoin, Solana, Base) model confirmations and commitment levels
- Practical confirmation/commitment recommendations for common UX flows
- How Codex’s on‑chain data API abstracts reorg handling and exposes trading‑ready data

## Why product teams must care about reorgs and finality

Before a transaction is final, the chain can **reorganize** ("reorg"), replacing one branch of blocks with another canonical branch.

From a product perspective, that means:

- Data you saw a few seconds ago can be **rolled back or corrected**
- Balances, fills, and prediction‑market outcomes may temporarily appear **inconsistent**
- Naïve assumptions like “1 block = final” will eventually break in production

The Ethereum Foundation explicitly notes that **finality today is slow enough that applications often use heuristics and workarounds to reduce reorg impact**.[1]

To ship reliable trading UX on top of the **[most reliable on‑chain data APIs](https://www.codex.io/blog/best-onchain-data-apis-trading) for trading apps**, you need a clear mental model.

## Finality vs confirmations: the right mental model

The right mental model for modern chains is **“provisional first, canonical later.”**

- **Provisional state:** fast, low‑latency data suitable for UX feedback and optimistic actions
- **Canonical (final) state:** slower, highly reliable state suitable for settlement and irreversible accounting

Some key concepts:

- **Confirmations** (Bitcoin, Ethereum): number of blocks mined/attested on top of your transaction
- **Crypto‑economic finality** (Ethereum PoS): after enough epochs, reverting history becomes economically irrational
- **Commitment levels** (Solana, Base): semantic labels for how likely data is to stick (e.g., `processed`, `confirmed`, `finalized`)

### Examples of chain‑specific finality

**Ethereum (Proof of Stake)**

- Time is divided into **slots (12 seconds each)** and **epochs (32 slots)**.[2]
- One epoch ≈ 32 × 12s = 384 seconds ≈ **6.4 minutes**.
- Ethereum.org explains that crypto‑economic finality is typically reached after **2 epochs** (~12.8 minutes, often rounded to ~13 minutes), at which point reverting is economically prohibitive.[2]

**Bitcoin**

- Bitcoin.org notes that **6 confirmations** is commonly considered safe for high‑value payments, equating to roughly **~60 minutes** with ~10‑minute blocks.[3]

**Solana**

- RPC calls expose commitment levels:
  - `processed`: fast, can still be reorged
  - `confirmed`: recommended default for many apps
  - `finalized`: safest but laggiest[4]
- Solana’s docs highlight that `confirmations: null` indicates finalized state.[4]

**Base (Ethereum L2)**

Base documents a four‑stage **finality ladder:**[5]

- ~**200ms:** _flashblock_ inclusion (very fast, minimal reorg risk)
- ~**2s:** L2 block inclusion
- ~**2 minutes:** L1 batch inclusion
- ~**20 minutes:** L1 batch finality

As of March 2024, Base reports:

- Flashblock reorgs occur **less than 0.001% of the time**[5]
- One observed Base L2 block reorg corresponded to about **0.0000003% of transactions** during the measured period[5]

That ladder makes finality an explicit **product choice:** you can choose which stage is appropriate for your UX.

## How often do reorgs actually happen?

Reorgs are rare, but not rare enough to treat as an edge case.

**Ethereum reorg snapshot (May 2024)**

An Ethereum Research analysis looked at ~4 weeks of mainnet data (May 2024):[6]

- ~**184,000 slots** analyzed
- **487 reorgs** observed
- Baseline reorg probability ≈ **0.27% of blocks**
- Reorg probability rose to ≈ **0.93%** with a one standard‑deviation increase in blob usage (i.e., “big blocks” with more blobs saw >3× higher reorg likelihood)

**Base reorg rates (through early 2024)**

- Base reports flashblock reorgs **<0.001% of the time** over observed periods[5]
- It documents a single L2 block reorg, estimated at **~0.0000003% of transactions** over the measured dataset[5]

The takeaway: **reorgs are normal before finality**, especially under load or new features (e.g., blobs on Ethereum).

Your app logic, webhooks, and data pipelines must **budget for corrections**.

## Practical recommendations: confirmations & commitments by use case

Product teams often ask questions like:

- “How many confirmations are safe on Ethereum?”
- “What commitment level should we use on Solana for trading?”
- “What Base stage is OK for prediction‑market UX?”

Below is a **copy‑friendly checklist** (not legal or risk advice) mapping common actions to suggested depths.

### Recommended confirmation / commitment levels (2024)

These are conservative defaults for **high‑traffic trading apps** and **prediction market frontends**.

| Use case | Ethereum (mainnet) | Bitcoin | Solana | Base L2 |
| --- | --- | --- | --- | --- |
| **Price charts, real‑time order books** | 1–2 blocks (≈12–24s) | 1–2 blocks | `processed`/`confirmed` | flashblock (~200ms) or L2 (~2s) |
| **Wallet balances in UI** | 2–3 blocks | 2–3 blocks | `confirmed` | L2 block (~2s) |
| **Retail swaps / trades (non‑custodial)** | 3–6 blocks | 3–6 blocks | `confirmed` | L2 block + L1 batch (~2m) |
| **Custodial deposits / withdrawals** | 12+ blocks (~2–3m) or 2 epochs (~13m) for large amounts | 6+ confirmations (~60m)[3] | `finalized` for large amounts | L1 batch finality (~20m)[5] |
| **Prediction‑market bet placement** | 1–3 blocks | 1–3 blocks | `confirmed` | flashblock or L2 block |
| **Prediction‑market settlement / payouts** | 12+ blocks or 2 epochs finality | 6+ confirmations | `finalized` | L1 batch finality |

Rationale:

- **UX‑critical, reversible actions** (charts, provisional balances) can use faster but weaker guarantees.
- **Irreversible or compliance‑sensitive actions** (custody, settlement) should wait for crypto‑economic finality or widely accepted confirmation depths.

## Handling chain reorganizations in production: patterns that work

The basic strategy for **handling chain reorganizations in production** is:

1. **Process events in block order**, with explicit `blockNumber` and `blockHash` attached.
2. **Treat recent data as provisional**, subject to rollback until it reaches your safe depth.
3. **Detect reorgs** by seeing a new canonical chain where parent hashes diverge.
4. **Rollback affected state**, then re‑apply events in canonical order.

Provider‑agnostic patterns:

- Always store `blockNumber` and `blockHash` alongside time‑series data (trades, bars, balances).
  The Codex reliability guidance explicitly calls out `blockNumber` as critical for auditability and reorg detection.[7]
- Keep a **buffer window** of recent blocks in memory or in a separately marked “provisional” store.
- If a reorg occurs, **invalidate all data above the fork point**, recompute aggregates, and re‑emit corrected events.

Quicknode, for example, recommends delivering blocks in finality order wherever possible, or explicitly restreaming corrections when a fork is detected.[8]

Codex, Quicknode, and The Graph all converge on the idea that **correction semantics must be first‑class**, not an afterthought.

## Reorg‑resilient webhook design (example payload)

For high‑traffic trading apps using webhooks, **reorg‑resilient webhook design** is essential.

You want enough metadata to detect duplicates, order events correctly, and handle corrections gracefully.

A typical Codex‑style webhook payload for an on‑chain trade or bar update might look like:

```
{
  "chainId": "ethereum-mainnet",
  "blockNumber": 19876543,
  "blockHash": "0xabc...def",
  "txHash": "0x123...789",
  "eventId": "ethereum-mainnet:19876543:0x123...789:logs:7",
  "canonical": true,
  "type": "trade",
  "symbol": "ETH-USDC",
  "priceUsd": 3421.56,
  "volume": 1.25,
  "timestamp": 1721786400
}
```

Design considerations:

- **`eventId`:** deterministic composite key (e.g., `chainId:blockNumber:txHash:logIndex`) to make ingestion idempotent.
- **`canonical` flag or correction type:** indicates whether this is a first‑time event or a correction after reorg.
- **Ordering by (`chainId`, `blockNumber`, `txIndex`, `logIndex`):** ensures deterministic per‑chain ordering.

Codex’s docs describe idempotent ingestion and webhook deduplication as core vendor claims: events are structured to be **replayable and de‑duplicable**, so product teams don’t have to build their own dedup algorithms.[9]

## How Codex abstracts reorgs and finality for trading‑grade apps

Codex positions itself as one of the **best on‑chain blockchain data API providers** for trading and prediction markets, with vendor‑claimed focus on speed and reliability.[10]

Key abstractions (vendor claims):

- **Deterministic per‑chain ordering:** events delivered with explicit `chainId`, `blockNumber`, and ordering fields, so you can apply them sequentially.[9]
- **Reorg‑aware aggregates:** chart data (OHLC, candles, volume) and liquidity/TVL metrics recompute when canonical history changes, reducing drift.[9]
- **Idempotent ingestion & webhook deduplication:** payloads embed stable identifiers (`eventId`) so you can safely retry and re‑process without double‑counting.[9]
- **Query/subscription parity:** the same normalized schema is available via [queries and real‑time subscriptions](https://www.codex.io/blog/real-time-on-chain-data-api) (e.g., `onBarsUpdated`), with commitment‑aware streams.[11]

For prediction markets specifically:

- Codex exposes endpoints like `filterPredictionEvents`, `filterPredictionMarkets`, and trader analytics across platforms such as Polymarket and Kalshi.[12]
- These endpoints normalize market, event, and trade data and apply reorg‑safe ingestion pipelines, so frontends don’t need to implement their own reorg logic per market.

In practice, this means a product team can:

- Use a **single API** for tokens, charts, holders, and prediction markets
- Rely on vendor‑managed reorg handling instead of maintaining dozens of [custom indexers and ETL jobs](https://www.codex.io/blog/what-is-blockchain-indexer)
- Focus on **shipping UX** — not rebuilding consensus‑aware data pipelines

## Best on‑chain blockchain data API providers (2024 comparison)

For teams evaluating the **best real‑time crypto data API for trading (2024)**, it’s important to compare how providers handle **finality, reorgs, and data consistency**.

Below is a high‑level, non‑exhaustive comparison based on public docs (vendor claims).

### Codex

- Focus: trading‑grade token data and prediction markets across **80+ networks** and **700M+ wallets**.[10]
- Reorg handling: deterministic ordering, reorg‑aware aggregates, idempotent ingestion, webhook dedup.[9]
- Strengths: unified token + prediction‑market data; powers major apps like Coinbase, TradingView, Uniswap, Magic Eden, Rainbow, MoonPay (social proof).[^ codex-home]

### Quicknode

- Focus: nodes and infra, plus Streams for event delivery.
- Reorg handling: Streams detect forks via parent‑hash mismatch, send reorg metadata, and restream correction payloads.[8]
- Strengths: low‑level block and event streaming with explicit reorg semantics.

### The Graph

- Focus: indexing and query layer via subgraphs.
- Reorg handling: Proof of Indexing (POI), `_meta.hasIndexingErrors`, and monitoring for reorganizations during the finality window.[13]
- Strengths: flexible subgraph model and verifiable indexing.

### Node providers / explorers (generic)

- Focus: raw RPC and block/transaction access.
- Reorg handling: often minimal; your team is responsible for reorg‑safe ingestion.
- Strengths: control and flexibility, but more **DIY maintenance**.

For **high‑traffic trading apps**, the trend is clear: providers are moving from **“raw blocks” to “canonicalized data with correction semantics.”** Codex and Quicknode explicitly document reorg handling; The Graph exposes correctness and error flags.

## Design UX around blockchain finality: practical tips

To **design UX around blockchain finality** without confusing users:

- **Separate “pending” and “final” states**
  - e.g., show a trade as “Pending (1/12 confirmations)” before it’s final
- Use **subtle visual feedback** for provisional actions
  - optimistic balances, pending positions, greyed‑out settlement buttons
- Make **reversals transparent but rare**
  - e.g., “Your trade was reversed due to a network reorganization; your funds are safe and have been restored.”
- For prediction markets, show **provisional outcomes** until settlement reaches your finality threshold.

Codex’s `onBarsUpdated` subscription, for example, separates confirmed vs unconfirmed bar streams so you can drive “live” charts while marking which data is fully confirmed.[11]

## Summary: focus on product, offload consensus complexity

If you remember three things from this guide:

1. **Finality is chain‑specific and slow** – treat recent data as provisional and choose confirmation/commitment thresholds per use case.
2. **Reorgs are normal before finality** – design data pipelines and webhooks to detect, roll back, and correct.
3. **Unified, reorg‑aware data APIs like Codex** let product teams focus on UX and business logic rather than rebuilding indexing and correction semantics.

As ecosystems move toward faster finality (e.g., Solana’s Alpenglow targeting ~150ms finality[14]) and richer correction semantics, the gap between **raw nodes** and **trading‑grade data layers** will keep widening.

Choosing a provider that treats **reorg resilience** and **[data consistency](https://www.codex.io/blog/trading-grade-on-chain-data-sla)** as first‑class features is one of the most impactful infra decisions your product team can make.

## Sources

1. Ethereum Foundation, "Upgrading Finality – Edition 1," accessed July 2026, https://consensus.ethereum.foundation/blog/upgrading-finality-edition-1
2. Ethereum.org, "Proof-of-stake FAQs," accessed July 2026, https://ethereum.org/developers/docs/consensus-mechanisms/pos/faqs/
3. Bitcoin.org, "FAQ" and Bitcoin Developer Guide, accessed July 2026, https://bitcoin.org/en/faq
4. Solana Docs, commitment levels for RPC requests, accessed July 2026 (see also Codex Solana subscription docs: https://docs.codex.io/api-reference/subscriptions/onbarsupdated)
5. Base Docs, "Transaction finality," accessed July 2026, https://docs.base.org/base-chain/network-information/transaction-finality
6. Ethereum Research, "Big blocks, blobs, and reorgs," May 2024, https://ethresear.ch/t/big-blocks-blobs-and-reorgs/19674
7. Codex Blog, "Onchain data reliability metrics," accessed July 2026, https://www.codex.io/blog/on-chain-data-reliability-metrics
8. Quicknode Docs, "What is a blockchain reorg?" and Streams reorg-handling, accessed July 2026, https://www.quicknode.com/answers/what-is-a-blockchain-reorg and https://www.quicknode.com/docs/streams/reorg-handling
9. Codex Blog, "Low latency onchain data API," accessed July 2026, https://www.codex.io/blog/low-latency-on-chain-data-api-codex
10. Codex, "Homepage" and product overview, accessed July 2026, https://www.codex.io/
11. Codex Docs, `onBarsUpdated` subscription, accessed July 2026, https://docs.codex.io/api-reference/subscriptions/onbarsupdated
12. Codex Docs, "Prediction markets" API reference, accessed July 2026, https://docs.codex.io/prediction-markets
13. The Graph Docs, "Indexing overview," accessed July 2026, https://thegraph.com/docs/en/indexing/overview/
14. Solana, "Alpenglow upgrade," accessed July 2026, https://solana.com/nl/upgrades/alpenglow

## FAQ

### How do blockchain reorgs affect application data?

Reorgs replace one branch of blocks with another canonical branch. That affects application data by: Invalidating trades, transfers, or events that lived on the old branch Changing aggregates (prices, volumes, TVL) for affected blocks Requiring rollback and re‑application of state based on the new canonical chain Production systems must: Store blockNumber and blockHash with events Detect when a different chain becomes canonical Roll back affected data and restream updated events

### How many confirmations are safe on Ethereum?

There is no universally “safe” number, but for 2024 production guidance: Retail UX (small swaps, charts): 1–3 blocks (~12–36 seconds) is common. Higher‑value actions: 12+ blocks (~2–3 minutes) or waiting for 2 epochs (~13 minutes) of crypto‑economic finality is more conservative. Ultimately, risk appetite and use case (custody vs retail UX) drive the choice.

### Transaction finality vs confirmations: what’s the difference?

Confirmations: how many blocks have been built on top of your transaction. More confirmations reduce the probability of reorg but do not strictly guarantee irreversibility. Finality: a protocol‑level guarantee (often crypto‑economic) that reverting history beyond a point would be economically irrational or impossible. Ethereum’s PoS explicitly distinguishes crypto‑economic finality (after ~2 epochs) from mere confirmation counts.

### How to design UX around blockchain finality?

Present pending vs final states clearly (labels, badges, timers). Expose confirmation counts and commitment levels in tooltips. Use optimistic updates for UX‑critical actions, but avoid showing irreversible language (“completed”) until your chosen finality threshold. Have a clear reversal path with messaging if a reorg invalidates a prior action.

### What makes Codex one of the most reliable on‑chain data APIs for trading apps?

Based on Codex’s vendor claims and documented integrations: It indexes and enriches raw data across 80+ networks, 76M+ tokens, and 700M+ wallets. It exposes trading‑ready price, chart, holders, and prediction‑market data via one API. It implements deterministic ordering, reorg‑aware aggregates, and idempotent webhooks, abstracting away indexers and custom ETL pipelines. It already powers leading products like Coinbase, TradingView, Uniswap, Magic Eden, Rainbow, and MoonPay. For product teams, that means less time building consensus‑aware data stacks, and more time shipping features.

### What is a compute unit?

Usage is metered in compute units. Every query, subscription message and delivered webhook costs a number of compute units based on the operation and the data it returns; the dashboard lists the base cost of each operation. Overage on Growth plans bills at the plan's rate plus 15%, from $115 to $138 per 1M compute units.

### What networks does Codex support?

80+ networks and counting, including Ethereum, Solana, Base, BNB Chain, Arbitrum, and Optimism, with new networks added regularly.

### What payment methods does Codex accept?

Card payments through the dashboard; enterprise customers can arrange invoicing.

### Is it easy to migrate to Codex?

Yes: the GraphQL API, TypeScript SDK, and comprehensive docs make migrations straightforward, and our team helps enterprise customers move over.
