Accessing On-chain Data
RPC queries, indexers, and hosted data APIs for exchange integrations.
Exchanges need on-chain data to detect deposits, track withdrawals, and reconcile balances. RPC provides queries for specific blocks, accounts, and transactions; indexers process blockchain data continuously and make it searchable across accounts and blocks.
| Approach | Exchange use cases |
|---|---|
| RPC | Check balances at a finalized block, submit withdrawals, and query transaction outcomes |
| Indexer | Track incoming transfers, process receipt outcomes and token events, and maintain a history for reconciliation |
| Hosted data API | Look up an account's assets, retrieve transfer history, and investigate transactions without operating an indexer |
RPC Queries
Use RPC to query native NEAR balances with view_account, token balances through ft_balance_of, and transaction execution through status queries. For reconciliation, query balances at the same finalized block. Access to older blocks and state depends on the provider's retained history.
Resources:
Indexers
An indexer processes blocks, receipts, execution outcomes, and contract events, and can store relevant movements in a database. For an exchange, this supports continuous deposit monitoring and queries across many blocks, such as all transfers into a customer's account.
Process finalized outcomes across all shards, including receipts generated by contract calls. Save a processing checkpoint so monitoring can resume after an interruption, and deduplicate movements when replaying data. For fungible tokens, identify transfers using events emitted by the supported token contract.
Resources:
Hosted Data APIs
Hosted APIs expose indexed data through HTTP endpoints, allowing an integration to query account assets and history without running its own indexing infrastructure.
| Service | Available data |
|---|---|
| FastNEAR API | Account assets, staking pools, and public-key-to-account lookups |
| Pikespeak API | Account balances, NEAR and token transfers, contract events, and analytics |
| NearBlocks API | Account information, transactions, receipts, and token transfer history |
Check the selected API's network coverage, indexing delay, pagination, and how far back its data extends. Before crediting a deposit, establish finality and successful receipt execution; see Receiving Deposits. Use a finalized block checkpoint when reconciling balances.
For additional examples, see Data APIs.