NEW

CCIP is now live for all developers. See what's new.

Back

Using Data Feeds on Starknet

Starknet is a permissionless decentralized ZK-Rollup operating as an L2 network over Ethereum. Unlike other Ethereum L2 networks, Starknet is not EVM-compatible and uses Cairo as its smart contract language. Chainlink Data Feeds are available on Starknet Sepolia as Cairo smart contracts.

Offchain examples

You can read Chainlink Data Feeds offchain without a Starknet account. Complete these steps using only the Starkli CLI or the Starknet Foundry toolkit.

Onchain examples

You can read Chainlink Data Feeds on Starknet Sepolia using an onchain contract that you compile, declare, and deploy using Starknet Foundry.

Devnet examples

Experiment with Chainlink Data Feeds on Starknet using Starknet Devnet RS, a local Docker-based testnet environment implemented using Rust. The Starknet Devnet RS guide provides code examples and scripts that enable you to compile, declare, and deploy your own aggregator and consumer contracts. You can use a set of pre-funded accounts to interact with Chainlink Data Feeds on Starknet without deploying to a live network.

Getting Started (Starkli CLI)

Starkli is a Starknet standalone CLI similar to cairo-lang but written in Rust. It enables interaction with a Starknet network without the need for extra tools or dependencies.

In this example, you'll utilize the starkli call command to read data from a Chainlink Price Feed on Starknet Sepolia. This command requires the proxy aggregator address, the function selector, and an RPC endpoint for Starknet Sepolia.

Requirements

Make sure you have the Starkli CLI installed. You can check your current version by running starkli --version in your terminal. Expect an output similar to the following:

starkli --version
0.2.8 (f59724e)

Follow the official installation guide if necessary.

Use the following command to call the latest_round_data function on the ETH / USD Chainlink Price Feed aggregator proxy:

starkli call \
0x228128e84cdfc51003505dd5733729e57f7d1f7e54da679474e73db4ecaad44 \
latest_round_data \
--rpc https://starknet-sepolia.public.blastapi.io/rpc/v0_7

Expect an output similar to the following:

[
    "0x000000000000000000000000000000010000000000000000000000000000320c",
    "0x0000000000000000000000000000000000000000000000000000005293770eb1",
    "0x000000000000000000000000000000000000000000000000000000000000d44d",
    "0x000000000000000000000000000000000000000000000000000000006606b8cc",
    "0x000000000000000000000000000000000000000000000000000000006606b8a2"
]

The example output contains an array with the hex-encoded latest round data for the ETH / USD Chainlink Price Feed on Starknet Sepolia. The array contains the following values:

Value nameHex-encoded valueDecoded valueDescription
round_id0x000000000000000000000000000000010000000000000000000000000000320c340282366920938463463374607431768224268The unique identifier of the data round
answer0x0000000000000000000000000000000000000000000000000000005293770eb1354661371569The actual data provided by the data feed, representing the latest price of an asset in the case of a price feed
block_num0x000000000000000000000000000000000000000000000000000000000000d44d54349The block number at which the data was recorded on the blockchain
started_at0x000000000000000000000000000000000000000000000000000000006606b8cc1711716556The Unix timestamp indicating when the data round started
updated_at0x000000000000000000000000000000000000000000000000000000006606b8a21711716514The Unix timestamp indicating when the data was last updated

For a complete list of Chainlink Price Feeds available on Starknet, see the Price Feed Contract Addresses page.

Note: This example utilizes a Blast API RPC endpoint. You can interact with the network using any other Starknet Sepolia RPC provider, such as Alchemy or Infura.

What's next

Stay updated on the latest Chainlink news