Skip to main content

Switchboard Logo

@switchboard-xyz/evm.js

A Typescript client to interact with Switchboard on EVM based chains.

NPM Badge

Install

npm i --save @switchboard-xyz/evm.js

Usage

Directory

Load Switchboard Contract and Switchboard Push Receiver Contract Functions

import ethers from "ethers";
import {
getSwitchboard,
getSwitchboardPushReceiver,
getSwitchboardPushReceiverFeeds,
} from "@switchboard-xyz/evm.js";

const signer = new ethers.Wallet(privateKey);

// get switchboard contract functions
const switchboardProgram = await getSwitchboard(
process.env.SWITCHBOARD_ADDRESS, // Switchboard contract address (from environment)
signer // Signer instance
);

// get switchboard feeds contract functions
const switchboardPushReceiver = await getSwitchboardPushReceiver(
process.env.SWITCHBOARD_PUSH_ADDRESS,
signer
);

// log all feeds
const allFeeds = await getSwitchboardPushReceiverFeeds(switchboardPushReceiver);
console.log(allFeeds); // Feed[];

Index

Classes

Functions

Interfaces

Properties

References

Type Aliases

Variables

Properties

SwitchboardPushReceiver

SwitchboardPushReceiver: any

References

EvmChainConfigs

Renames and re-exports SwitchboardPushReceiver

EvmChainIds

Renames and re-exports SwitchboardPushReceiver

EvmChainType

Renames and re-exports SwitchboardPushReceiver

IEvmNetworkConfig

Renames and re-exports SwitchboardPushReceiver

SUPPORTED_EVM_CHAIN_IDS

Renames and re-exports SwitchboardPushReceiver

SWITCHBOARD_ARBITRUM_MAINNET_CONFIG

Renames and re-exports SwitchboardPushReceiver

SWITCHBOARD_ARBITRUM_TESTNET_CONFIG

Renames and re-exports SwitchboardPushReceiver

SWITCHBOARD_COREDAO_MAINNET_CONFIG

Renames and re-exports SwitchboardPushReceiver

SWITCHBOARD_COREDAO_TESTNET_CONFIG

Renames and re-exports SwitchboardPushReceiver

SWITCHBOARD_EVM_CHAINS

Renames and re-exports SwitchboardPushReceiver

Switchboard

Renames and re-exports SwitchboardPushReceiver

SwitchboardPushReceiver__factory

Renames and re-exports SwitchboardPushReceiver

Switchboard__factory

Renames and re-exports SwitchboardPushReceiver

arbitrum

Renames and re-exports SwitchboardPushReceiver

coredao

Renames and re-exports SwitchboardPushReceiver

getSupportedEvmChain

Renames and re-exports SwitchboardPushReceiver

getSupportedEvmChainId

Renames and re-exports SwitchboardPushReceiver

isSupportedChainId

Renames and re-exports SwitchboardPushReceiver

isSupportedEvmChain

Renames and re-exports SwitchboardPushReceiver

Type Aliases

Aggregator

Aggregator: AggregatorData & { address: string }

AggregatorData

AggregatorData: Awaited<ReturnType<Switchboard[aggregators]>>

AggregatorData is a type that represents the data for an AggregatorAccount.

[
'switchboard_feed',
'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
[
BigNumber { value: "0" },
BigNumber { value: "0" },
'0x0000000000000000000000000000000000000000',
value: BigNumber { value: "0" },
timestamp: BigNumber { value: "0" },
oracleAddress: '0x0000000000000000000000000000000000000000'
],
BigNumber { value: "1" },
BigNumber { value: "0" },
BigNumber { value: "1" },
'',
'0xfF5C1DD2A7cA6a4d76a902DaC6B0Fc99BcD54563',
BigNumber { value: "0" },
BigNumber { value: "1685024425" },
BigNumber { value: "0" },
BigNumber { value: "0" },
name: 'switchboard_feed',
authority: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
latestResult: [
BigNumber { value: "0" },
BigNumber { value: "0" },
'0x0000000000000000000000000000000000000000',
value: BigNumber { value: "0" },
timestamp: BigNumber { value: "0" },
oracleAddress: '0x0000000000000000000000000000000000000000'
],
batchSize: BigNumber { value: "1" },
minUpdateDelaySeconds: BigNumber { value: "0" },
minOracleResults: BigNumber { value: "1" },
jobsHash: '',
queueAddress: '0xfF5C1DD2A7cA6a4d76a902DaC6B0Fc99BcD54563',
balanceLeftForInterval: BigNumber { value: "0" },
nextIntervalRefreshTime: BigNumber { value: "1685024425" },
intervalId: BigNumber { value: "0" },
balance: BigNumber { value: "0" }
]

AttestationQueueData

AttestationQueueData: Awaited<ReturnType<Switchboard[attestationQueues]>>

AttestationQueueData is a type that represents the data for an AttestationQueueAccount.

[
'0x70997970C51812dc3A010C7d01b50e0d17dc79C8',
BigNumber { value: "180" },
BigNumber { value: "0" },
BigNumber { value: "0" },
BigNumber { value: "604800" },
BigNumber { value: "1" },
false,
false,
BigNumber { value: "3000000" },
BigNumber { value: "0" },
BigNumber { value: "0" },
authority: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',
maxSize: BigNumber { value: "180" },
reward: BigNumber { value: "0" },
lastHeartbeat: BigNumber { value: "0" },
maxEnclaveVerificationAge: BigNumber { value: "604800" },
allowAuthorityOverrideAfter: BigNumber { value: "1" },
requireAuthorityHeartbeatPermission: false,
requireUsagePermissions: false,
enclaveTimeout: BigNumber { value: "3000000" },
gcIdx: BigNumber { value: "0" },
currIdx: BigNumber { value: "0" }
]

Authority

Authority: { authority: OptionalSigner }

Authority is a type that represents an authority, which can be a string or a Signer.


Type declaration

CallStaticMethodNames

CallStaticMethodNames<T>: { [ K in keyof T[callStatic] ]: T[callStatic][K] extends (...args: Parameters<T[callStatic][K]>) => ReturnType<T[callStatic][K]> ? K : never }[keyof T[callStatic]]

CallStaticMethodNames is a utility type for mapping a contract’s function names to their respective function types. It includes only methods that return the expected ReturnType.


Type parameters

CreateAggregator

CreateAggregator: Exclude<AggregatorInitParams, authority> & Authority

CreateAggregator is a type that represents parameters to create an Aggregator with an Authority.

CreateEnclave

CreateEnclave: Exclude<EnclaveInitParams, authority> & Authority

CreateEnclave is a type that represents parameters to create a Enclave with an Authority and owner.

CreateFunction

CreateFunction: Exclude<FunctionInitParams, authority> & Authority

CreateFunction is a type that represents parameters to create a Function with an Authority.

CreateOracle

CreateOracle: Exclude<OracleInitParams, authority> & Authority

CreateOracle is a type that represents parameters to create an Oracle with an Authority.

EnablePermissions

EnablePermissions: boolean | { queueAuthority: Signer }

EnablePermissions is a type that can be a boolean or a queueAuthority as a Signer.

EnclaveData

EnclaveData: Awaited<ReturnType<Switchboard[enclaves]>>

EnclaveData is a type that represents the data for a EnclaveAccount.

[
'0x90F79bf6EB2c4f870365E785982E1f101E93b906',
'0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
'0x19ef1517eEFE5A6278e8290455D6d530Ee82Dcb9',
'0x',
1,
BigNumber { value: "0" },
BigNumber { value: "0" },
'0x0000000000000000000000000000000000000000000000000000000000000000',
false,
BigNumber { value: "0" },
authority: '0x90F79bf6EB2c4f870365E785982E1f101E93b906',
owner: '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
queueAddress: '0x19ef1517eEFE5A6278e8290455D6d530Ee82Dcb9',
cid: '0x',
verificationStatus: 1,
verificationTimestamp: BigNumber { value: "0" },
validUntil: BigNumber { value: "0" },
mrEnclave: '0x0000000000000000000000000000000000000000000000000000000000000000',
isOnQueue: false,
lastHeartbeat: BigNumber { value: "0" }
]

EstimateGasMethodNames

EstimateGasMethodNames<T>: { [ K in keyof T[estimateGas] ]: T[estimateGas][K] extends (...args: Parameters<T[estimateGas][K]>) => Promise<BigNumber> ? K : never }[keyof T[estimateGas]]

EstimateGasMethodNames is a utility type for mapping a contract’s function names to their respective function types. It includes only methods that return a Promise of BigNumber.


Type parameters

EventCallback

EventCallback: (e: any) => Promise<void>

Type declaration

    • (e: any): Promise<void>
    • EventCallback is a type that represents a function to be called when an event occurs.


      Parameters

      • e: any

      Returns Promise<void>

FunctionData

FunctionData: Awaited<ReturnType<Switchboard[funcs]>>

FunctionData is a type that represents the data for a FunctionAccount.

FunctionMethodNames

FunctionMethodNames<T>: { [ K in keyof T[functions] ]: T[functions][K] extends (...args: Parameters<T[functions][K]>) => Promise<ContractTransaction> ? K : never }[keyof T[functions]]

FunctionMethodNames is a utility type for mapping a contract’s function names to their respective function types. It includes only methods that return a Promise of ContractTransaction.


Type parameters

FunctionStatusType

FunctionStatusType: keyof typeof FunctionStatus

LatestRawValue

LatestRawValue: [BigNumber, BigNumber] & { timestamp: BigNumber; value: BigNumber }

LatestResult

LatestResult: { result: Big; timestamp: number }

Type declaration

  • result: Big
  • timestamp: number

LatestResults

LatestResults: (LatestResult & { oracleId: string })[]

MethodNames

MethodNames<T>: Extract<Extract<FunctionMethodNames<T>, EstimateGasMethodNames<T>>, CallStaticMethodNames<T>>

MethodNames is a utility type for extracting the common methods from FunctionMethodNames, EstimateGasMethodNames, and CallStaticMethodNames.


Type parameters

OptionalSigner

OptionalSigner: string | Signer

Represents an account that will optionally sign the tx.

OracleData

OracleData: Awaited<ReturnType<Switchboard[oracles]>>

OracleData is a type that represents the data for an OracleAccount.

[
'',
'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
0,
BigNumber { value: "0" },
'0xF688A2F2828f0F8E6E2214f462892a3cd3ceC8a3',
name: '',
authority: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
numRows: 0,
lastHeartbeat: BigNumber { value: "0" },
queueAddress: '0xF688A2F2828f0F8E6E2214f462892a3cd3ceC8a3'
]

OracleQueueAttestationConfig

OracleQueueAttestationConfig: Awaited<ReturnType<Switchboard[queueAttestationConfigs]>>

OracleQueueAttestationConfig is a type that represents the attestation config for an OracleQueueAccount.

OracleQueueData

OracleQueueData: Awaited<ReturnType<Switchboard[oracleQueues]>>

OracleQueueData is a type that represents the data for an OracleQueueAccount.

[
'Queue1',
'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
true,
BigNumber { value: "32" },
BigNumber { value: "0" },
BigNumber { value: "180" },
BigNumber { value: "0" },
BigNumber { value: "0" },
name: 'Queue1',
authority: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
unpermissionedFeedsEnabled: true,
maxSize: BigNumber { value: "32" },
reward: BigNumber { value: "0" },
oracleTimeout: BigNumber { value: "180" },
gcIdx: BigNumber { value: "0" },
currIdx: BigNumber { value: "0" }
]

PermissionStatusType

PermissionStatusType: keyof typeof PermissionStatus

PollTxnForEventFieldFn

PollTxnForEventFieldFn: { <T>(tx: ContractTransaction, field: T): Promise<T>; <T>(tx: ContractTransaction, field?: undefined): Promise<T> }

Type declaration

    • <T>(tx: ContractTransaction, field: T): Promise<T>
    • <T>(tx: ContractTransaction, field?: undefined): Promise<T>
    • PollTxnForEventFieldFn is a function type that takes a ContractTransaction and an optional field name to poll a transaction for an emitted event field.


      Type parameters

      • T = string

      Parameters

      • tx: ContractTransaction
      • field: T

      Returns Promise<T>

    • PollTxnForEventFieldFn is a function type that takes a ContractTransaction and an optional field name to poll a transaction for an emitted event field.


      Type parameters

      • T

      Parameters

      • tx: ContractTransaction
      • optionalfield: undefined

      Returns Promise<T>

RawMrEnclave

RawMrEnclave: string | Buffer | Uint8Array | number[]

RawMrEnclave is a type that can be a string, Buffer, Uint8Array, or an array of numbers.

SendContractMethod

SendContractMethod<T>: (methodName: MethodNames<T>, args: Parameters<T[MethodNames<T>]>, options: TransactionOptions | undefined) => Promise<ContractTransaction>

Type parameters

Type declaration

SendTransactionMethod

SendTransactionMethod: <T, K>(contract: T, methodName: K, args: Parameters<T[K]>, options: TransactionOptions | undefined) => Promise<ContractTransaction>

Type declaration

SwitchboardMethods

SwitchboardMethods: MethodNames<Switchboard>

SwitchboardMethods is a type that represents the methods for the Switchboard contract.

TransactionOptions

TransactionOptions: Partial<PayableOverrides> & { gasFactor?: number; signer?: Signer; simulate?: boolean }

TransactionOptions is a type that allows the user to specify a subset of PayableOverrides and includes optional properties for gasFactor, simulate and signer.

{
// an optional multiplier to modify the gasEstimation
gasFactor: 1.1,
// simulate the tx before sending
simulate: true,
// the new msg.sender for the tx
signer: myNewSigner,
// it also supports any fields from ethers PayableOverrides
gasLimit: 3000000,
gasPrice: 10000,
maxFeePerGas: 10000,
maxPriorityFeePerGas: 1000,
nonce: 1337
}

TransactionStruct

TransactionStruct: { data: BytesLike; expirationTimeSeconds: BigNumberish; from: string; gasLimit: BigNumberish; to: string; value: BigNumberish }

Type declaration

VerificationStatusType

VerificationStatusType: keyof typeof VerificationStatus

Variables

constFunctionStatus

FunctionStatus: { ACTIVE: 1; DEACTIVATED: 6; EXPIRED: 3; INVALID_PERMISSIONS: 5; NONE: 0; NON_EXECUTABLE: 2; OUT_OF_FUNDS: 4 } = ...

PermissionStatus is an enumeration of possible permission statuses.


Type declaration

  • readonlyACTIVE: 1
  • readonlyDEACTIVATED: 6
  • readonlyEXPIRED: 3
  • readonlyINVALID_PERMISSIONS: 5
  • readonlyNONE: 0
  • readonlyNON_EXECUTABLE: 2
  • readonlyOUT_OF_FUNDS: 4

constPermissionStatus

PermissionStatus: { NONE: 0; PERMIT_ATTESTATION_QUEUE_USAGE: number; PERMIT_ORACLE_HEARTBEAT: number; PERMIT_ORACLE_QUEUE_USAGE: number } = ...

PermissionStatus is an enumeration of possible permission statuses.


Type declaration

  • readonlyNONE: 0
  • readonlyPERMIT_ATTESTATION_QUEUE_USAGE: number
  • readonlyPERMIT_ORACLE_HEARTBEAT: number
  • readonlyPERMIT_ORACLE_QUEUE_USAGE: number

constVerificationStatus

VerificationStatus: { FAILURE: 1; OVERRIDE: 3; PENDING: 0; SUCCESS: 2 } = ...

VerificationStatus is an enumeration of possible verification statuses.


Type declaration

  • readonlyFAILURE: 1
  • readonlyOVERRIDE: 3
  • readonlyPENDING: 0
  • readonlySUCCESS: 2