@switchboard-xyz/common
TypeScript icon, indicating that this package has built-in type declarations

2.3.18 • Public • Published

@switchboard-xyz/common

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

NPM Badge

Discord Twitter

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);

/@switchboard-xyz/common/

    Package Sidebar

    Install

    npm i @switchboard-xyz/common

    Weekly Downloads

    2,828

    Version

    2.3.18

    License

    MIT

    Unpacked Size

    3.81 MB

    Total Files

    164

    Last publish

    Collaborators

    • eldios
    • herm
    • mgild
    • jessupjn