Using Data Feeds on Stellar
Stellar is a Layer 1 blockchain that uses Soroban smart contracts written in Rust. Chainlink Data Feeds on Stellar use a single proxy contract that serves every feed. Instead of a per-feed contract address, you select a feed by its 32-byte data_id.
A data_id is a 32-byte identifier for a feed, similar to how a contract address identifies a feed on EVM chains. It is the same value as the Feed ID shown in the Price Feed Contract Addresses table. You pass the data_id to the proxy contract to read that feed's data.
How Stellar Data Feeds work
Data Feeds on Stellar use a proxy contract that sits in front of a cache contract. Consumers read feeds from the proxy by passing a 32-byte data_id:
- Proxy contract: A single proxy contract serves every feed. Consumers read feed data from the proxy by passing the
data_idfor the feed they need. The proxy address stays stable, which lets the underlying cache be replaced without changing the address consumers use.
Consumers select a feed by passing its 32-byte data_id to the proxy. You can find the data_id for each feed on the Price Feed Contract Addresses page with Stellar selected.
Supported networks
Chainlink Data Feeds are available on the following Stellar networks:
Available data feeds on Stellar
The following table shows all available data feeds on Stellar. Each feed is identified by its data_id (the Feed ID), which you pass to the proxy contract to read that feed's data.
Networks
Stellar Mainnet
Unlike EVM chains, Stellar uses a single proxy contract for all feeds. Instead of a per-feed contract address, you select a feed by its feed ID (data_id) shown below. See the Using Data Feeds on Stellar guide to learn how to read these feeds.
- Data Feeds proxy contract on Stellar Mainnet: CDQBHEUGLDHMSUHG4IH33RJBUTMNCZOT4JIAQR4WZFRDZW6DR6S32ZLZ
Proxy contract addresses
The proxy contract address is the same for every feed on a given network. You only ever interact with the proxy.
- Stellar Testnet:
CBUF6IADAWPWIDWRTHJNINKXHG2UTIQ6TU2F2HRAXWAI7OT3KJPKK6O4 - Stellar Mainnet (Pubnet):
CDQBHEUGLDHMSUHG4IH33RJBUTMNCZOT4JIAQR4WZFRDZW6DR6S32ZLZ
Reader interface
Consumers call the following functions on the proxy contract. The interface is defined in the chainlink-stellar repository.
| Function | Returns |
|---|---|
latest_round(data_id, decimals) | The most recent round for that feed, at the requested decimals |
get_round(data_id, round_id, decimals) | A specific historical round, at the requested decimals |
decimals(data_id) | Decimal places for the answer |
description(data_id) | Human-readable pair name |
Round structure
A round returned by the proxy carries the following fields:
| Field | Description |
|---|---|
round_id | The unique identifier of the round |
answer | The answer for the feed, represented as an I256 |
timestamp | The Unix timestamp in seconds when the round was recorded |
Error handling
When you call the proxy, the contract can return a ProxyReadError. The following cases describe what each error means for a consumer:
| Error | Meaning |
|---|---|
NoDataPresent | No round is available for the requested data_id or round_id. This can happen if the feed has not been written yet or the round has expired. |
InvalidDecimals | The decimals you requested is outside the supported range for the feed. |
RoundsToZero | A non-zero answer would truncate to zero at the requested decimals. Request fewer decimal places. |
How long a round is available
A round is stored in the cache contract's temporary storage with a retention period of 3,110,400 ledgers. After this period, a round can no longer be read from the proxy.
Getting started
You can read Chainlink Data Feeds on Stellar either offchain or onchain. Both methods read the same data from the proxy contract, differing only in where the read happens.
-
Using Data Feeds Offchain: Read a feed via Soroban RPC simulation using
stellar-cliand the Stellar JavaScript SDK. This method is for applications that need to read feed data without deploying a contract. -
Using Data Feeds Onchain: Deploy a Soroban contract in Rust that calls the proxy and reads a price. This method is for applications that need to read feed data directly within a smart contract.
Each guide lists the tools and requirements you need to complete it.
Answer precision
All feeds are stored at 18 decimal places and are typically returned at 18 decimal places. In some instances, Chainlink approves the serving of a reduced precision for certain feeds. In this case, you can pass the precision as a parameter when requesting a feed from the proxy.
The precision is truncated, so if an 18-decimal feed is requested at 8 decimal places, the answer is truncated (rounded down). Factor this into your calculations. If you need to control the precision yourself, request the feed at 18 decimal places and override the precision in your application.