16 releases

0.1.15 Nov 16, 2023
0.1.14 Nov 4, 2023
0.1.13 Oct 31, 2023

#31 in #switchboard

Download history 20/week @ 2024-01-04 55/week @ 2024-01-11 56/week @ 2024-01-18 2/week @ 2024-01-25 11/week @ 2024-02-01 35/week @ 2024-02-08 73/week @ 2024-02-15 29/week @ 2024-02-22 59/week @ 2024-02-29 185/week @ 2024-03-07 35/week @ 2024-03-14 28/week @ 2024-03-21 33/week @ 2024-03-28 26/week @ 2024-04-04 27/week @ 2024-04-11

88 downloads per month
Used in switchboard-evm

MIT license

8KB
115 lines

Switchboard Logo

Switchboard x EVM

A collection of libraries and examples for interacting with Switchboard on EVM chains.

NPM Badge

Getting Started

To get started, clone the evm-sdk repository.

git clone https://github.com/switchboard-xyz/evm-sdk

Then install the dependencies

cd evm-sdk
pnpm install
pnpm build

Switchboard Functions

Switchboard V3 revolves around the concept of a Switchboard Function. Functions are the core building block of Switchboard. They are the unit of work that is performed by the Switchboard network. Functions can be user defined, and can be composed together to create more complex functions. Function calls can be initialized on-chain, or on a schedule.

Get started writing Switchboard Functions with our functions template repository.

Switchboard Feeds

Switchboard Data Feeds are powered by Switchboard Functions. You can find the source code (contracts and off-chain logic) for the Switchboard Function that powers the available feeds in the functions repository.

  • Receiver.sol) - The main entry point for the Switchboard Feed Function. This contract is deployed by the Switchboard, and is responsible for receiving data from the off-chain Switchboard Function, and making it available to other contracts.
  • Main.rs - The off-chain Switchboard Function that powers the Switchboard Feed. This function is responsible for fetching data from an external API, and submitting it to the Switchboard Receiver contract.

You can find existing Switchboard Feeds and their ID's for accessing in solidity at app.switchboard.xyz.

You can use this simple price function (which supplies 500+ feeds from top exchanges!) and build custom functionality on top of it

Clients

Lang Name Description
Solidity ISwitchboard A Solidity contract to read a Switchboard data feed.
Solidity ILegacyOracle A Solidity contract to read a Switchboard data feed with a legacy oracle adapter.
Javascript @switchboard-xyz/evm.js A Typescript client to interact with Switchboard on EVM chains.

Example Contracts

Lang Name Description
Solidity randomness-calllback An example Solidity contract demonstrating how to consume randomenss with Switchboard.
Solidity user-triggered-callback An example Solidity contract demonstrating how manually trigger a callback with Switchboard.

Troubleshooting

  1. File a GitHub Issue
  2. Ask a question in Discord #dev-support

Dependencies

~29–45MB
~840K SLoC