Onchain Data
Building a Stellar wallet means more than just sending and receiving payments, you must know what data is needed, how to get it, and how to keep it in sync. This guide explains the types of data Stellar wallets may require, how to access it, and best practices for working with it.
Core Wallet Data
As wallets implement their internal functionality, they may need to access data stored on and off-chain. A few examples of data a wallet may need to access are:
-
Account state: Token balances, signers, thresholds, and subentries.
-
Token information: Trustlines, asset codes, icon.
-
Transaction history: Payments, trades, offers, and smart contract calls.
-
Contract state: If using smart contracts.
How to Access Wallet Data
The Stellar network is open and public, meaning anyone can access the data stored on the network. However, accessing this data can be complex and time-consuming. To make this easier, there are a few tools available to help you get the data you need.
RPC
Stellar RPC is an interface that provides direct access to the Stellar network's ledger state and smart contract functionality. Unlike Horizon's REST API, which focuses on indexed, human-readable history and account data, Stellar RPC is designed for developers who need to interact with the network at the protocol level, especially for building on Soroban, Stellar's smart contracts platform. Through RPC, you can read raw ledger entries, query and stream recent contract events, simulate transactions before submission, and retrieve contract code or state. It is the preferred interface for dApps, indexers, and infrastructure services that require precise, real-time access to on-chain data beyond what Horizon exposes.
📖 Learn more about RPC in the RPC documentation.
Indexers
Indexers on Stellar are specialized services that collect, process, and organize raw blockchain data, often going beyond what Horizon or RPC provide out of the box. While Horizon indexes core network data like accounts, transactions, payments, and contract events, external indexers can ingest the entire ledger stream to create highly customized, query-optimized datasets. Popular indexer architectures often involve a streaming ingestion layer, a transformation pipeline, and a queryable database, allowing developers and businesses to access deep, application-specific insights from the Stellar network.
📖 Check out the available indexers in the Indexers documentation.
Horizon
Horizon provides a REST API for the Stellar network. It can be used to get account data, transaction history, and more. It has been broadly used by the Stellar ecosystem for years to fetch on-chain data for Classic wallets. With the introduction of Smart Contracts on Stellar, new projects usually adopt RPCs combined with indexers since they provide a more complete solution to interact with smart contracts and fetch the data they need.
📖 Learn more about Horizon in the Horizon documentation.
On August 1, 2024, the publicly accessible SDF-hosted Horizon had its historical data truncated to one year. That update optimized the performance of the publicly accessible Horizon and ensured a streamlined experience for all users. Consider third-party ecosystem providers of Horizon.
Check out Horizon Providers for a list of third-party providers.