Constructs a OnDemandQueue
instance.
The Anchor program instance.
The public key of the queue account.
Static
loadLoads the default queue for the current network
Automatically detects whether you're on mainnet or devnet and loads the appropriate default queue. This is the recommended way to get started with Switchboard On-Demand.
Anchor program instance
The default queue for your network
Fetches a gateway URL from the Crossbar network
The gateway is the interface to oracle operators. This method automatically detects your network and returns an appropriate gateway for fetching oracle data. The gateway is cached after the first successful fetch and reused for subsequent calls.
Crossbar client instance
Gateway instance for oracle communication
Fetches a gateway with the latest/majority version from Crossbar
CrossbarClient instance
Promise
Fetches an oracle with the latest/majority version from Crossbar
CrossbarClient instance
Promise
Static
createCreates a new queue account
Anchor program instance
Queue configuration parameters
Tuple of [Queue instance, keypair, creation instruction]
Static
createCreates a new instance of the Queue
account with a PDA for SVM (non-solana) chains.
The anchor program instance.
The initialization parameters for the queue.
Add an Oracle to a queue and set permissions
Static
fetchFetches signatures from a random gateway on the queue.
REST API endpoint: /api/v1/fetch_signatures
A promise that resolves to the feed evaluation responses.
Static
fetchStatic
fetchStatic
fetchStatic
fetchLoads the queue data from on chain and returns the listed oracle keys.
A promise that resolves to an array of oracle public keys.
Loads the queue data from on chain and returns the listed gateways.
A promise that resolves to an array of gateway URIs.
Fetches a gateway interface for interacting with oracle nodes.
Optional
gatewayUrl: stringOptional URL of a specific gateway to use. If not provided, a random gateway will be selected from the queue's available gateways.
Gateway - A Gateway instance for making oracle requests
Fetches signatures from a random gateway on the queue.
REST API endpoint: /api/v1/fetch_signatures
A promise that resolves to the feed evaluation responses.
Static
loadLoads the queue data for this Queue
account from on chain.
A promise that resolves to the queue data.
Loads the queue data for this Queue
account from on chain.
A promise that resolves to the queue data.
Adds a new MR enclave to the queue. This will allow the queue to accept signatures from the given MR enclave.
A promise that resolves to the transaction instruction.
Removes an MR enclave from the queue. This will prevent the queue from accepting signatures from the given MR enclave.
A promise that resolves to the transaction instruction.
Sets the queue configurations.
Optional
authority?: PublicKeyThe new authority for the queue.
Optional
reward?: numberThe new reward for the queue.
Optional
nodeTimeout?: numberThe new node timeout for the queue.
A promise that resolves to the transaction instruction.
Sets the oracle permission on the queue.
The oracle to set the permission for.
The permission to set.
A promise that resolves to the transaction instruction
Get the PDA for the queue (SVM chains that are not solana)
Queue PDA Pubkey
Static
queuePDAGet the PDA for the queue (SVM chains that are not solana)
Anchor program
Queue pubkey
Queue PDA Pubkey
Crossbar client for data routing
Array of feed hashes to fetch (hex strings)
Optional
configs: {Configuration object with optional parameters
Optional
gateway?: GatewayOptional
variableOverrides?: Record<string, string>Variable overrides for feed processing
Number of oracle signatures required
Instruction index for Ed25519 instruction
Signature verification instruction
Use fetchQuoteIx instead. The bundle terminology has been replaced with quote terminology.
Fetches oracle bundle and creates verification instruction
This is the primary method for fetching oracle data in the bundle approach. It retrieves signed price data from oracle operators and creates the instruction to verify signatures on-chain.
// Fetch prices for BTC and ETH
const sigVerifyIx = await queue.fetchUpdateBundleIx(
gateway,
crossbar,
['0x1234...', '0x5678...'], // Feed hashes
{
numSignatures: 3, // Require 3 oracle signatures
variableOverrides: {},
instructionIdx: 0
}
);
// Use in your transaction
const tx = await asV0Tx({
connection,
ixs: [sigVerifyIx, yourProgramIx],
signers: [payer],
});
Fetches oracle quote and creates verification instruction
This is the primary method for fetching oracle data in the quote approach. It retrieves signed price data from oracle operators and creates the instruction to verify signatures on-chain.
Crossbar client for data routing
Array of feed hashes (hex strings) or array of OracleFeed objects (max 16 feeds)
Optional
configs: {Ed25519 signature verification instruction ready for transaction
// Basic usage with single feed hash
const btcFeedHash = '0xef0d8b6fcd0104e3e75096912fc8e1e432893da4f18faedaacca7e5875da620f';
const sigVerifyIx = await queue.fetchQuoteIx(
crossbar,
[btcFeedHash],
{
numSignatures: 1, // Single oracle signature
variableOverrides: {},
instructionIdx: 0
}
);
// Using OracleFeed objects
const btcFeed: IOracleFeed = {
name: 'BTC/USD Price Feed',
jobs: [btcJob1, btcJob2],
minOracleSamples: 3,
// ... other feed properties
};
const ethFeed: IOracleFeed = {
name: 'ETH/USD Price Feed',
jobs: [ethJob1, ethJob2],
minOracleSamples: 3,
};
const feedsIx = await queue.fetchQuoteIx(
crossbar,
[btcFeed, ethFeed],
{
numSignatures: 3,
variableOverrides: {},
instructionIdx: 0
}
);
// Multi-feed quote with higher consensus
const feedHashes = [
'0xef0d8b6fcd0104e3e75096912fc8e1e432893da4f18faedaacca7e5875da620f', // BTC/USD
'0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef', // ETH/USD
'0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890' // SOL/USD
];
const multiQuoteIx = await queue.fetchQuoteIx(
crossbar,
feedHashes,
{
numSignatures: 5, // Require 5 oracle signatures for high-value operations
variableOverrides: {},
instructionIdx: 1 // Instruction index for multiple Ed25519 instructions
}
);
// Use in your transaction with proper error handling
try {
const tx = await asV0Tx({
connection,
ixs: [sigVerifyIx, yourBusinessLogicIx],
signers: [payer],
computeUnitPrice: 200_000,
computeUnitLimitMultiple: 1.3,
});
const txSignature = await connection.sendTransaction(tx, {
preflightCommitment: "processed",
});
console.log('Transaction confirmed:', txSignature);
} catch (error) {
console.error('Quote fetch failed:', error);
}
Creates instructions for managed oracle updates using the new quote program
This method generates instructions to call the verified_update method in the quote program (PID: orac1eFjzWL5R3RbbdMV68K9H6TaCVVcL6LjvQQWAbz). It creates both the Ed25519 signature verification instruction and the quote program instruction that verifies and stores the oracle data.
The oracle account is automatically derived from the feed hashes using the canonical derivation logic. Gateway is automatically fetched and cached.
Crossbar client for data routing
Array of feed hashes (hex strings) or array of OracleFeed objects (max 16 feeds)
Optional
configs: {Configuration object with optional parameters
Optional
gateway?: GatewayOptional
variableOverrides?: Record<string, string>Variable overrides for feed processing
Optional
numSignatures?: numberNumber of oracle signatures required (default: 1)
Optional
instructionIdx?: numberInstruction index for Ed25519 program (default: 0)
Optional
payer?: PublicKeyPayer for oracle account creation (default: program provider payer)
Array of instructions: [Ed25519 verification, quote program verified_update]
// Using feed hashes
const btcFeedHash = '0xef0d8b6fcd0104e3e75096912fc8e1e432893da4f18faedaacca7e5875da620f';
// Create the instructions (oracle account is derived automatically)
const instructions = await queue.fetchManagedUpdateIxs(
crossbar,
[btcFeedHash],
{
numSignatures: 3, // Require 3 oracle signatures for consensus
variableOverrides: {},
instructionIdx: 0,
payer: myWallet.publicKey,
programId: customQuoteProgramId // Optional: use custom program ID for oracle derivation
}
);
// Using OracleFeed objects
const btcFeed: IOracleFeed = {
name: 'BTC/USD Price Feed',
jobs: [btcJob1, btcJob2],
minOracleSamples: 3,
// ... other feed properties
};
const ethFeed: IOracleFeed = {
name: 'ETH/USD Price Feed',
jobs: [ethJob1, ethJob2],
minOracleSamples: 3,
};
const instructionsFromFeeds = await queue.fetchManagedUpdateIxs(
crossbar,
[btcFeed, ethFeed],
{
numSignatures: 3,
variableOverrides: {},
instructionIdx: 0,
payer: myWallet.publicKey
}
);
// Build transaction with managed update instructions
const tx = await asV0Tx({
connection,
ixs: [...instructions, yourBusinessLogicIx],
signers: [payer],
computeUnitPrice: 200_000,
computeUnitLimitMultiple: 1.3,
});
await connection.sendTransaction(tx);
Queue account management for Switchboard On-Demand
The Queue class is the primary interface for interacting with oracle operators in the Switchboard network. It manages:
Key Features
Example
Queue