Fetches signatures from the gateway. REST API endpoint: /api/v1/gateway_attest_enclave
A promise that resolves to the attestation response.
Fetches an attestation quote from the gateway.
REST API endpoint: /api/v1/gateway_fetch_quote
A promise that resolves to the quote response.
Sends a request to the gateway bridge enclave.
REST API endpoint: /api/v1/gateway_bridge_enclave
A promise that resolves to the response.
Fetches oracle quote data from the gateway
This method retrieves signed price quotes from oracle operators through the gateway interface. It's the primary method for fetching oracle data using the modern quote terminology.
The returned response contains:
oracle_responses: Array of signed oracle datarecent_hash: Recent Solana block hash for replay protectionslot: Recent slot number for temporal validationCrossbar client for data routing and feed resolution
Array of feed hashes to fetch (hex strings, max 16)
Number of oracle signatures required (default: 1, max based on queue config)
OptionalvariableOverrides: Record<string, string>Oracle quote response with signatures
import { CrossbarClient } from '@switchboard-xyz/common';
// Initialize crossbar client
const crossbar = CrossbarClient.default();
// Single feed quote
const btcQuote = await gateway.fetchQuote(
crossbar,
['0xef0d8b6fcd0104e3e75096912fc8e1e432893da4f18faedaacca7e5875da620f'], // BTC/USD
1 // Single signature for fast updates
);
// Multi-feed quote for DeFi protocol
const defiAssets = [
'0xef0d8b6fcd0104e3e75096912fc8e1e432893da4f18faedaacca7e5875da620f', // BTC/USD
'0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef', // ETH/USD
'0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890', // SOL/USD
'0x9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba' // USDC/USD
];
const portfolioQuote = await gateway.fetchQuote(
crossbar,
defiAssets,
5 // Higher consensus for financial operations
);
// Access oracle responses
console.log('Oracle responses:', portfolioQuote.oracle_responses.length);
console.log('Recent slot:', portfolioQuote.slot);
// Process individual feed responses
portfolioQuote.oracle_responses.forEach((oracle, index) => {
oracle.feed_responses.forEach((feed, feedIndex) => {
console.log(`Oracle ${index}, Feed ${feedIndex}:`, {
feedHash: feed.feed_hash,
value: feed.success_value,
confidence: feed.min_oracle_samples
});
});
});
Fetches the randomness reveal from the gateway.
The parameters for the randomness reveal.
The randomness reveal response.
Fetches signatures using consensus mechanism REST API endpoint: /api/v1/fetch_signatures_consensus
A promise that resolves to the consensus response.
Gateway - Interface to Switchboard Oracle Network
The Gateway class provides methods to interact with Switchboard's oracle network, allowing you to fetch signatures, quotes, and randomness from oracle operators.
Variable Overrides
Many methods support
variableOverrideswhich allow you to inject custom values into oracle job execution. This is particularly useful for:How Variable Overrides Work
When you provide variableOverrides, the gateway will:
Example Usage
Best Practices
Gateway