Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@switchboard-xyz/common

mgild43.9kMIT3.4.1TypeScript support: included

common type definitions and utils for interacting with switchboard

readme

@switchboard-xyz/common

Contains the OracleJob protobufs and other types and utilities shared across chains.

NPM Badge

Discord Twitter

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

Typedocs: docs.switchboard.xyz/api/@switchboard-xyz/common

Install

npm i --save @switchboard-xyz/common

Usage

Create an OracleJob

import { OracleJob, serializeOracleJob } from "@switchboard-xyz/common";

const oracleJob: OracleJob = serializeOracleJob({
  tasks: [
    {
      httpTask: {
        url: "https://www.binance.com/api/v3/ticker/price?symbol=BTCUSDT",
      },
    },
    {
      jsonParseTask: {
        path: "$.price",
      },
    },
    {
      multiplyTask: {
        /* Mainnet USDT/USD Feed */
        aggregatorPubkey: "ETAaeeuQBwsh9mC2gCov9WdhJENZuffRMXY2HgjCcSL9",
      },
    },
  ],
});

Simulate an OracleJob

import { simulateOracleJobs } from "@switchboard-xyz/common";

const result = await simulateOracleJobs([oracleJob]);
console.log(result);