Constructors

Properties

crossbarUrl: string
feedCache: Map<string, CrossbarFetchResponse> = ...
oracleFeedCache: Map<string, CrossbarOracleFeedFetchResponse> = ...
verbose: boolean

Methods

  • GET /fetch/:feedHash Fetch data from the crossbar using the provided feedHash

    Parameters

    • feedHash: string

      The hash of the feed to fetch data for

    Returns Promise<CrossbarFetchResponse>

    • The data fetched from the crossbar
  • GET /updates/evm/:chainId/:aggregatorIds Fetch updates for EVM network feeds from the crossbar

    Parameters

    • param0: { aggregatorIds: string[]; chainId: number }

      The chain ID and aggregator IDs to fetch updates for

    Returns Promise<{ encoded: string[]; results: EVMResult[] }>

    Promise<{ results: EVMResult[]; encoded: string[] }> - The updates for the specified feeds

  • Fetch a Gateway instance for the specified network with caching

    This method fetches gateway URLs from the crossbar service and creates a Gateway instance. Results are cached per network to avoid repeated network calls.

    Parameters

    • Optionalnetwork: string

      Network to fetch gateway for (devnet/testnet/mainnet). If not provided, uses the network set via setNetwork()

    Returns Promise<Gateway>

    • A Gateway instance for the specified network

    If no gateways are available for the specified network

    const crossbar = CrossbarClient.default();
    const gateway = await crossbar.fetchGateway('mainnet');
    const response = await gateway.fetchQuote(...);
  • GET /gateways Fetch all gateways from the crossbar

    Parameters

    • Optionalnetwork: string = 'mainnet'

      Optional network parameter (devnet/testnet/mainnet). Defaults to mainnet.

    Returns Promise<string[]>

    • The gateways response containing an array of Gateway urls
  • GET /updates/iota/:network/:aggregatorAddresses Fetch updates for Iota network feeds from the crossbar

    Parameters

    • network: string

      The Iota network to fetch updates for (mainnet / testnet)

    • aggregatorAddresses: string[]

      The addresses of the aggregators to fetch updates for

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

    • The updates and any failures for the specified feeds
  • GET /v2/fetch/:feedHash Fetch OracleFeed data from a crossbar server using the provided feedId

    Parameters

    • feedId: string

      The identifier of the OracleFeed to fetch

    Returns Promise<CrossbarOracleFeedFetchResponse>

    • The data fetched from the crossbar
  • GET /oracle/quote/:aggregatorIds Fetch the quote for the given aggregator IDs

    Parameters

    • aggregatorIds: string[]

      The aggregator IDs to fetch the quote for

    • network: string = 'mainnet'

      The network to fetch the quote for (mainnet / testnet)

    Returns Promise<V2UpdateResponse & { encoded: string }>

    • The quote for the given aggregator IDs with timestamp and encoded data
  • GET /oracles Fetch all oracles for a given network

    Parameters

    • Optionalnetwork: string

      Optional network parameter (devnet/mainnet). Defaults to mainnet.

    Returns Promise<OracleInfo[]>

    • Array of oracle information
  • POST /gateways/fetch_signatures

    Parameters

    • request: FetchSignaturesRequest

      The request parameters

    • Optionalnetwork: string

      Optional network parameter (devnet/mainnet). Defaults to mainnet.

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

    • Array of oracle signatures and results

    Use fetchSignaturesConsensus instead Fetch signatures from oracles for a given set of jobs

  • POST /gateways/fetch_signatures_consensus Fetch consensus signatures from oracles for a given set of feed requests

    Parameters

    • request: FetchSignaturesConsensusRequest

      The request parameters with camelCase fields

    • Optionalnetwork: string

      Optional network parameter (devnet/mainnet). Defaults to mainnet.

    Returns Promise<FetchSignaturesConsensusResponse>

    • Consensus signatures and median responses in camelCase
    // Using FeedRequestV1
    const feedRequestV1 = CrossbarClient.createFeedRequestV1(
    ['base64EncodedJob1', 'base64EncodedJob2'],
    1000000, // maxVariance
    3 // minResponses
    );

    // Using FeedRequestV2
    const feedRequestV2 = CrossbarClient.createFeedRequestV2('base64EncodedProtoBuf');

    const response = await client.fetchSignaturesConsensus({
    apiVersion: '1.0',
    recentHash: 'someRecentHash',
    signatureScheme: 'ed25519',
    hashScheme: 'sha256',
    feedRequests: [feedRequestV1, feedRequestV2],
    numOracles: 3,
    useTimestamp: false
    });
  • GET /updates/solana/:network/:feedpubkeys Fetch updates for Solana network feeds from the crossbar

    Parameters

    • network: string

      The Solana network to fetch updates for

    • feedpubkeys: string[]

      The public keys of the feeds to fetch updates for

    • payer: string
    • OptionalnumSignatures: number

      The number of signatures to fetch (optional)

    Returns Promise<
        {
            lookupTables: string[];
            pullIxns: TransactionInstruction[];
            responses: { errors: string; oracle: string; result: null
            | number }[];
            success: boolean;
        }[],
    >

    • The updates for the specified feeds
  • GET /updates/sui/:network/:aggregatorAddresses Fetch updates for Sui network feeds from the crossbar

    Parameters

    • network: string

      The Sui network to fetch updates for (mainnet / testnet)

    • aggregatorAddresses: string[]

      The addresses of the aggregators to fetch updates for

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

    • The updates and any failures for the specified feeds
  • GET /v2/update/{feedHashes} Fetch V2 oracle consensus updates for feed hashes with enhanced chain support

    Parameters

    • feedHashes: string[]

      Array of feed hashes to fetch updates for

    • Optionaloptions: V2UpdateQuery

      Optional query parameters for the request

    Returns Promise<V2UpdateResponse>

    • The V2 update response with oracle consensus data
    // Basic usage with single feed hash
    const response = await client.fetchV2Update(
    ['0x7418dc6408f5e0eb4724dabd81922ee7b0814a43abc2b30ea7a08222cd1e23ee']
    );
    // With chain-specific options for Sui mainnet
    const response = await client.fetchV2Update(
    ['0x7418dc6408f5e0eb4724dabd81922ee7b0814a43abc2b30ea7a08222cd1e23ee'],
    {
    chain: 'sui',
    network: 'mainnet',
    use_timestamp: true,
    num_oracles: 5
    }
    );
    // Multiple feed hashes with custom gateway
    const response = await client.fetchV2Update(
    [
    '0x7418dc6408f5e0eb4724dabd81922ee7b0814a43abc2b30ea7a08222cd1e23ee',
    '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
    ],
    {
    network: 'testnet',
    gateway: 'https://custom-gateway.example.com',
    signature_scheme: 'Secp256k1'
    }
    );
  • Get the currently configured default network

    Returns string

    The current network (mainnet or devnet)

  • GET /randomness/evm/:chainId/:randomnessId

    Parameters

    • param0: { chainId: number; randomnessId: string }

      The chain ID and randomness ID to resolve

    Returns Promise<
        {
            encoded: string;
            response: { recovery_id: number; signature: string; value: string };
        },
    >

  • Set the default network for CrossbarClient operations

    This network will be used as the default for all operations that accept a network parameter. Individual method calls can still override this by passing their own network parameter.

    Parameters

    • network: CrossbarNetwork

      The network to use (SolanaMainnet or SolanaDevnet)

    Returns void

    const crossbar = CrossbarClient.default();
    crossbar.setNetwork(CrossbarNetwork.SolanaDevnet);

    // Now all operations will default to devnet
    const gateway = await crossbar.fetchGateway(); // Uses devnet
    const simResult = await crossbar.simulateFeed(feedId); // Uses devnet
  • GET /simulate/evm/:network/:aggregatorIds Simulate fetching Solana feed results from the crossbar

    Parameters

    • network: number

      The Solana network to simulate

    • aggregatorIds: string[]

      The public keys of the feeds to simulate

    Returns Promise<{ aggregatorId: string; feedHash: string; results: number[] }[]>

    • The simulated feed results
  • POST /v2/simulate/proto Simulate an OracleFeed from a protobuf object or feed hash

    Parameters

    • feedOrHash: string | IOracleFeed

      The OracleFeed protobuf object or feed hash to simulate

    • OptionalincludeReceipts: boolean

      Whether to include receipts in the response

    • OptionalvariableOverrides: Record<string, string>

      Variable overrides for the simulation

    • Optionalnetwork: string

      Network to use for simulation. If not provided, uses the network set via setNetwork()

    Returns Promise<CrossbarSimulateProtoResponse>

    • The simulation results
    const feed = OracleFeed.create({
    name: "BTC/USD",
    jobs: [
    {
    tasks: [
    {
    httpTask: {
    url: "https://api.coinbase.com/v2/prices/BTC-USD/spot"
    }
    },
    {
    jsonParseTask: {
    path: "$.data.amount"
    }
    }
    ]
    }
    ]
    });

    const response = await client.simulateFeed(
    feed,
    true,
    { MY_VAR: "value" },
    "mainnet"
    );
  • Simulate fetching feed results from the crossbar using feed hashes

    Parameters

    • feedHashes: string[]

      The hashes of the feeds to simulate

    • OptionalincludeReceipts: boolean

      Whether to include receipts in the response

    Returns Promise<CrossbarSimulateProtoResponse[]>

    • The simulated feed results
  • GET /simulate/iota/:network/:aggregatorAddresses Simulate fetching Iota feed results from the crossbar

    Parameters

    • network: string

      The Iota network to simulate (mainnet / testnet)

    • aggregatorAddresses: string[]

      The feed IDs to simulate

    • OptionalincludeReceipts: boolean

      Whether to include receipts in the response

    Returns Promise<SuiSimulationResult[]>

    • The simulated feed results
  • POST /simulate/jobs Simulate oracle jobs execution without storing them

    Parameters

    • request: SimulateJobsRequest

      The simulation request containing jobs and optional parameters

    Returns Promise<SimulateJobsResponse>

    • The simulation results
    const response = await client.simulateJobs({
    jobs: [
    {
    tasks: [
    {
    httpTask: {
    url: "https://api.coinbase.com/v2/prices/BTC-USD/spot"
    }
    },
    {
    jsonParseTask: {
    path: "$.data.amount"
    }
    }
    ]
    }
    ],
    includeReceipts: true,
    variableOverrides: {
    MY_VARIABLE: "custom_value"
    }
    });
  • Simulate V2 oracle feeds with variable overrides and network selection

    Parameters

    • feedHashes: string[]

      The hashes of the V2 feeds to simulate

    • OptionalincludeReceipts: boolean

      Whether to include receipts in the response

    • OptionalvariableOverrides: Record<string, string>

      Variable overrides for the simulation

    • Optionalnetwork: string

      Network to use for simulation (defaults to "mainnet")

    Returns Promise<CrossbarSimulateProtoResponse[]>

    • The simulated feed results

    Use simulateFeeds instead

  • GET /simulate/solana/:network/:feedpubkeys Simulate fetching Solana feed results from the crossbar

    Parameters

    • network: string

      The Solana network to simulate

    • feedpubkeys: string[]

      The public keys of the feeds to simulate

    Returns Promise<{ feed: string; feedHash: string; results: number[] }[]>

    • The simulated feed results
  • GET /simulate/sui/:network/:aggregatorAddresses Simulate fetching Sui feed results from the crossbar

    Parameters

    • network: string

      The Sui network to simulate (mainnet / testnet)

    • aggregatorAddresses: string[]

      The feed IDs to simulate

    • OptionalincludeReceipts: boolean

      Whether to include receipts in the response

    Returns Promise<SuiSimulationResult[]>

    • The simulated feed results
  • POST /store Store oracle jobs on the crossbar, associated with a queue address

    Parameters

    • queueAddress: string

      The address of the queue

    • jobs: IOracleJob[]

      The oracle jobs to store

    Returns Promise<{ cid: string; feedHash: string; queueHex: string }>

    • The stored data information
  • POST /v2/store Store an OracleFeed on IPFS using crossbar.

    Parameters

    Returns Promise<{ cid: string; feedId: string }>

    • The stored data information
  • Create a FeedRequestV1 object

    Parameters

    • jobsB64Encoded: string[]

      Base64 encoded oracle jobs

    • maxVariance: number

      Maximum variance allowed for the feed

    • minResponses: number

      Minimum number of oracle responses required

    Returns FeedRequest

    • A FeedRequestV1 object
  • Create a FeedRequestV2 object

    Parameters

    • feedProtoB64: string

      Base64 encoded feed protobuf

    Returns FeedRequest

    • A FeedRequestV2 object