The gateway class is used to interface with the switchboard gateway REST API.

Constructors

Properties

gatewayUrl: string

The URL of the switchboard gateway.

oracleKey?: PublicKey
program: Program<Idl>

The Anchor program instance.

Methods

  • Fetches signatures from the gateway. REST API endpoint: /api/v1/gateway_attest_enclave

    Parameters

    • params: {
          oracle_ed25519_enclave_signer: string;
          oracle_pubkey: string;
          oracle_reward_wallet: string;
          oracle_secp256k1_enclave_signer: string;
          quote: string;
          recentHash: string;
          timestamp: number;
      }
      • oracle_ed25519_enclave_signer: string
      • oracle_pubkey: string
      • oracle_reward_wallet: string
      • oracle_secp256k1_enclave_signer: string
      • quote: string
      • recentHash: string
      • timestamp: number

    Returns Promise<AttestEnclaveResponse>

    A promise that resolves to the attestation response.

    Throws

    if the request fails.

  • Sends a request to the gateway bridge enclave.

    REST API endpoint: /api/v1/gateway_bridge_enclave

    Parameters

    • params: {
          chainHash: string;
          oraclePubkey: string;
          queuePubkey: string;
      }
      • chainHash: string
      • oraclePubkey: string
      • queuePubkey: string

    Returns Promise<BridgeEnclaveResponse>

    A promise that resolves to the response.

    Throws

    if the request fails.

  • Fetches a quote from the gateway.

    REST API endpoint: /api/v1/gateway_fetch_quote

    Parameters

    • params: {
          blockhash: string;
          get_for_guardian: boolean;
          get_for_oracle: boolean;
      }
      • blockhash: string
      • get_for_guardian: boolean
      • get_for_oracle: boolean

    Returns Promise<FetchQuoteResponse[]>

    A promise that resolves to the quote response.

    Throws

    if the request fails.

  • Fetches the randomness reveal from the gateway.

    Parameters

    • params: {
          randomnessAccount: PublicKey;
          slot: number;
          slothash: string;
      } | {
          minStalenessSeconds: number;
          randomnessId: string;
          timestamp: number;
      }

      The parameters for the randomness reveal.

    Returns Promise<RandomnessRevealResponse>

    The randomness reveal response.

  • Fetches signatures from the gateway.

    REST API endpoint: /api/v1/fetch_signatures

    Parameters

    • params: {
          jobs: OracleJob[];
          maxVariance?: number;
          minResponses?: number;
          numSignatures?: number;
          recentHash?: string;
          useTimestamp?: boolean;
      }
      • jobs: OracleJob[]
      • Optional maxVariance?: number
      • Optional minResponses?: number
      • Optional numSignatures?: number
      • Optional recentHash?: string
      • Optional useTimestamp?: boolean

    Returns Promise<{
        failures: string[];
        responses: FeedEvalResponse[];
    }>

    A promise that resolves to the feed evaluation responses.

    Throws

    if the request fails.

  • Fetches signatures from the gateway without pre-encoded jobs REST API endpoint: /api/v1/fetch_signatures_batch

    Parameters

    • params: {
          feedConfigs: FeedRequest[];
          numSignatures?: number;
          recentHash?: string;
          useTimestamp?: boolean;
      }
      • feedConfigs: FeedRequest[]
      • Optional numSignatures?: number
      • Optional recentHash?: string
      • Optional useTimestamp?: boolean

    Returns Promise<FetchSignaturesBatchResponse>

    A promise that resolves to the feed evaluation responses.

    Throws

    if the request fails.

  • Fetches signatures from the gateway.

    REST API endpoint: /api/v1/fetch_signatures

    Parameters

    • params: {
          encodedJobs: string[];
          maxVariance: number;
          minResponses: number;
          numSignatures: number;
          recentHash?: string;
          useTimestamp?: boolean;
      }
      • encodedJobs: string[]
      • maxVariance: number
      • minResponses: number
      • numSignatures: number
      • Optional recentHash?: string
      • Optional useTimestamp?: boolean

    Returns Promise<{
        failures: string[];
        responses: FeedEvalResponse[];
    }>

    A promise that resolves to the feed evaluation responses.

    Throws

    if the request fails.

  • Fetches signatures from the gateway. REST API endpoint: /api/v1/fetch_signatures_batch

    Parameters

    • params: {
          encodedConfigs: {
              encodedJobs: string[];
              maxVariance: number;
              minResponses: number;
          }[];
          numSignatures: number;
          recentHash?: string;
          useTimestamp?: boolean;
      }
      • encodedConfigs: {
            encodedJobs: string[];
            maxVariance: number;
            minResponses: number;
        }[]
      • numSignatures: number
      • Optional recentHash?: string
      • Optional useTimestamp?: boolean

    Returns Promise<FetchSignaturesBatchResponse>

    A promise that resolves to the feed evaluation responses.

    Throws

    if the request fails.

  • Parameters

    • params: {
          encodedConfigs: {
              encodedJobs: string[];
              maxVariance: number;
              minResponses: number;
          }[];
          numSignatures: number;
          recentHash?: string;
          useTimestamp?: boolean;
      }
      • encodedConfigs: {
            encodedJobs: string[];
            maxVariance: number;
            minResponses: number;
        }[]
      • numSignatures: number
      • Optional recentHash?: string
      • Optional useTimestamp?: boolean

    Returns Promise<FetchSignaturesMultiResponse>