Skip to main content

Read a Data Feed On-Chain

An example contract reading the price of a Switchboard data feed on-chain.

Clone the example:

https://github.com/switchboard-xyz/aptos-sdk switchboard-aptos-sdk
cd switchboard-aptos-sdk
cd programs/feed-parser

Then build the example program

aptos move compile --named-addresses switchboard=default

Add the following to your Move.toml.

[addresses]
switchboard = "0x34e2eead0aefbc3d0af13c0522be94b002658f4bef8e0740a21086d22236ad77"

[dependencies]
MoveStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/move-stdlib/", rev = "devnet" }
AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-framework/", rev = "devnet" }
AptosStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-stdlib/", rev = "devnet" }
Switchboard = { git = "https://github.com/switchboard-xyz/aptos-sdk.git", subdir = "move/switchboard/", rev = "main" }