Aptos

This guide covers the setup and use of Switchboard data feeds within your project, using the Aggregator module for updating feeds and integrating Switchboard in Move.

Active Deployments

Switchboard is currently deployed on the following networks:

Typescript-SDK Installation

To use Switchboard On-Demand, add the following dependencies to your project:

NPM

npm install @switchboard-xyz/aptos-sdk --save
npm install @aptos-labs/ts-sdk

Adding Switchboard to Move Code

To integrate Switchboard with Move, add the following dependencies to Move.toml:

[dependencies.Switchboard]
git = "https://github.com/switchboard-xyz/aptos.git" subdir = "on_demand/" rev = "mainnet" # testnet or mainnet

Example Move Code for Using Switchboard Values

In the example.move module, use the Aggregator and CurrentResult types to access the latest feed data.

Once dependencies are configured, updated aggregators can be referenced easily.

This implementation allows you to read and utilize Switchboard data feeds within Move. If you have any questions or need further assistance, please contact the Switchboard team.

Creating an Aggregator and Sending Transactions

Building a feed in Switchboard can be done using the Typescript SDK, or it can be done with the Switchboard Web App. Visit our docs for more on designing and creating feeds.

Building Feeds in Typescript [optional]

Updating Feeds

(optional) Migrating existing code to On-Demand from V2 without updating logic

1. Update Move.toml

You'll need to update your Move.toml to include the new switchboard_adapter module and address. Replace the switchboard named address with the new switchboard_adapter address.

2. Update your Move Modules

You'll need to update named address switchboard to switchboard_adapter in dependencies.

The aggregator addresses you use will have to be updated to new On-Demand Aggregators that can be created from your V2 Aggregators on the Switchboard On-Demand App. Update references in your application to on-demand aggregators accordingly.

3. Cranking

On-demand works on a pull-based mechanism, so you will have to crank feeds with your client-side code in order to get the latest data. This can be done using the Typescript SDK.

Last updated