Skip to main content

@switchboard-xyz/oracle

A Typescript wrapper for the Switchboard V2 oracle.

Test StatusNPM Badge

DiscordTwitter

Npm: npmjs.com/package/@switchboard-xyz/oracle

Sbv2 SDK: github.com/switchboard-xyz/sbv2-core

Install

npm i --save-dev @switchboard-xyz/oracle

Usage

NodeJS

import { NodeOracle } from "@switchboard-xyz/oracle";

const oracle = await NodeOracle.fromReleaseChannel({
releaseChannel: "testnet",
chain: "solana",
network: "localnet",
rpcUrl: "http://0.0.0.0:8899",
oracleKey: "FKFPBD5WUUL5bSNwBH3AKY58KuY8nz2zkMCYR271CcVA",
secretPath: "~/.config/solana/id.json",
});

try {
await oracle.startAndAwait();
console.log("oracle ready");
await sleep(10000);
} catch (error) {
console.error(error);
}

oracle.stop();

Docker

import { DockerOracle } from "@switchboard-xyz/oracle";

const oracle = await DockerOracle.fromReleaseChannel({
releaseChannel: "testnet",
chain: "solana",
network: "localnet",
rpcUrl: "http://0.0.0.0:8899",
oracleKey: "FKFPBD5WUUL5bSNwBH3AKY58KuY8nz2zkMCYR271CcVA",
secretPath: "~/.config/solana/id.json",
});

try {
await oracle.startAndAwait();
console.log("oracle ready");
await sleep(10000);
} catch (error) {
console.error(error);
}

oracle.stop();

Index

Type Aliases

Chain

Chain: aptos | coredao | near | solana | starknet | sui

IDockerOracleConfig

IDockerOracleConfig: IOracleConfig & IDockerConfig

IOracleConfig

IOracleConfig: { chain: Chain; envVariables?: Record<string, string>; network: Network; oracleKey: string; rpcUrl: string; secretPath: string; silent?: boolean; switchboardDirectory?: string; taskRunnerSolanaRpc?: string }

Type declaration

  • chain: Chain
  • optionalenvVariables?: Record<string, string>
  • network: Network
  • oracleKey: string
  • rpcUrl: string
  • secretPath: string
  • optionalsilent?: boolean
  • optionalswitchboardDirectory?: string
  • optionaltaskRunnerSolanaRpc?: string

Network

Network: localnet | devnet | testnet | mainnet | mainnet

OracleTagVersion

OracleTagVersion: { imageTag: string }

Type declaration

  • imageTag: string

ParsedRelease

ParsedRelease: { imageName: string; name: string; published: number; releaseChannel: mainnet | testnet | undefined; tag_name: string }

Type declaration

  • imageName: string
  • name: string
  • published: number
  • releaseChannel: mainnet | testnet | undefined
  • tag_name: string

RawRelease

RawRelease: { created_at: string; draft?: boolean; html_url: string; id: number; name: string; prerelease?: boolean; published_at: string; tag_name: string; url: string }

Type declaration

  • created_at: string
  • optionaldraft?: boolean
  • html_url: string
  • id: number
  • name: string
  • optionalprerelease?: boolean
  • published_at: string
  • tag_name: string
  • url: string

ReleaseChannel

ReleaseChannel: testnet | mainnet | latest

ReleaseChannelVersion

ReleaseChannelVersion: { releaseChannel: ReleaseChannel }

Type declaration

Version