Constructs a OnDemandQueue instance.
The Anchor program instance.
The public key of the queue account.
StaticloadLoads 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 with the latest/majority version from Crossbar
CrossbarClient instance
Promise
Fetches an oracle with the latest/majority version from the queue
This method queries all oracles on the queue, checks their health status, and selects one running the most common (majority) version. This ensures compatibility and consensus across oracle operators.
The health checks are performed in parallel for optimal performance.
Oracle instance running the majority version
StaticcreateCreates a new queue account
Anchor program instance
Queue configuration parameters
Tuple of [Queue instance, keypair, creation instruction]
StaticcreateCreates 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
StaticfetchStatic method to fetch oracle signatures using the consensus mechanism
This convenience method creates a Queue instance and fetches signed oracle responses for multiple feed configurations. Gateway is automatically fetched from CrossbarClient.
Anchor program instance
OptionalcrossbarClient?: CrossbarClientOptional CrossbarClient instance (defaults to CrossbarClient.default())
Public key of the queue account
Array of feed configurations to fetch signatures for
OptionaluseTimestamp?: booleanWhether to use timestamp in the signature
OptionalnumSignatures?: numberNumber of oracle signatures to fetch
OptionaluseEd25519?: booleanWhether to use Ed25519 signatures (default: false for Secp256k1)
OptionalvariableOverrides?: Record<string, string>Optional variable overrides for job execution
A promise that resolves to the consensus response with oracle signatures
Manually set the network for this queue
This method allows you to explicitly set the network type, which will be used by methods that need network-specific configuration (e.g., crossbar gateway selection).
The network to use (SolanaMainnet or SolanaDevnet)
Get the cached network type
The network (SolanaMainnet, SolanaDevnet, or null if not yet determined)
Loads the queue data from on chain and returns the listed oracle keys.
A promise that resolves to an array of oracle public keys.
Fetches oracle signatures using the consensus mechanism
This method retrieves signed oracle responses for multiple feed configurations using the consensus endpoint. Gateway is automatically fetched from CrossbarClient.
OptionalcrossbarClient?: CrossbarClientOptional CrossbarClient instance (defaults to CrossbarClient.default())
Array of feed configurations to fetch signatures for
OptionaluseTimestamp?: booleanWhether to use timestamp in the signature
OptionalnumSignatures?: numberNumber of oracle signatures to fetch
OptionaluseEd25519?: booleanWhether to use Ed25519 signatures (default: false for Secp256k1)
OptionalvariableOverrides?: Record<string, string>Optional variable overrides for job execution
A promise that resolves to the consensus response with oracle signatures
StaticloadLoads 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.
Optionalauthority?: PublicKeyThe new authority for the queue.
Optionalreward?: numberThe new reward for the queue.
OptionalnodeTimeout?: numberThe new node timeout for the queue.
OptionaloracleFeeProportionBps?: numberThe oracle fee proportion in basis points (e.g., 5000 = 50%).
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
StaticqueuePDAGet the PDA for the queue (SVM chains that are not solana)
Anchor program
Queue pubkey
Queue PDA Pubkey
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)
Optionalconfigs: {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)
Optionalconfigs: {Configuration object with optional parameters
OptionalvariableOverrides?: Record<string, string>Variable overrides for feed processing
OptionalnumSignatures?: numberNumber of oracle signatures required (default: 1)
OptionalinstructionIdx?: numberInstruction index for Ed25519 program (default: 0)
Optionalpayer?: 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