### Quick Start: Price Feeds Example Setup Source: https://docs.switchboard.xyz/docs-by-chain/evm/monad Steps to clone the example repository, install dependencies, build the project, and configure environment variables for running the price feeds example. ```bash git clone https://github.com/switchboard-xyz/sb-on-demand-examples.git cd sb-on-demand-examples/evm/price-feeds bun install ( cd ../randomness/coin-flip [ -d lib/forge-std ] || forge install foundry-rs/forge-std --no-git --shallow ) forge build cp .env.example .env ``` -------------------------------- ### Clone Examples and Install Dependencies Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/x402/x402-tutorial Clone the Switchboard X402 examples repository and install project dependencies using pnpm. ```bash git clone https://github.com/switchboard-xyz/sb-on-demand-examples.git cd sb-on-demand-examples/solana/x402 pnpm install ``` -------------------------------- ### Install Dependencies Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/prediction-market/prediction-market-tutorial Install the necessary Node.js dependencies for the example project using npm. ```bash npm install ``` -------------------------------- ### Clone and Install Dependencies Source: https://docs.switchboard.xyz/docs-by-chain/evm/randomness/randomness-tutorial Clone the example repository and install necessary dependencies, including forge-std. ```bash git clone https://github.com/switchboard-xyz/sb-on-demand-examples cd sb-on-demand-examples/evm/randomness/pancake-stacker bun install # or npm install [ -d lib/forge-std ] || forge install foundry-rs/forge-std --no-git --shallow forge build ``` -------------------------------- ### Install Dependencies and Build Source: https://docs.switchboard.xyz/docs-by-chain/evm/price-feeds/price-feeds-tutorial Installs project dependencies using `bun` and `forge`, including necessary Forge std libraries. This step is required before running the example. ```bash bun install ( cd ../randomness/coin-flip [ -d lib/forge-std ] || forge install foundry-rs/forge-std --no-git --shallow ) forge build ``` -------------------------------- ### Clone the Examples Repository Source: https://docs.switchboard.xyz/docs-by-chain/evm/surge/surge-tutorial Clone the Switchboard on-demand examples repository to get started with the provided code. ```bash git clone https://github.com/switchboard-xyz/sb-on-demand-examples cd sb-on-demand-examples/evm/price-feeds ``` -------------------------------- ### Run Randomness Example Source: https://docs.switchboard.xyz/docs-by-chain/evm/monad Installs dependencies, sets up environment variables, and runs the generic randomness example script. ```bash bun install cp .env.example .env bun run example ``` -------------------------------- ### Agent Instructions: Querying Documentation via HTTP GET Source: https://docs.switchboard.xyz/ai-agents-llms/switchboard-agent-skill/switchboard-movement-feeds This example shows how to dynamically query documentation using an HTTP GET request with an 'ask' query parameter. This is useful for retrieving specific information not explicitly present on the page or for clarification. ```http GET https://docs.switchboard.xyz/ai-agents-llms/switchboard-agent-skill/switchboard-movement-feeds.md?ask= ``` -------------------------------- ### Install K3s Kubernetes Source: https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/installation-setup-via-scripts/bare-metal-with-kubernetes-k3s-%2B-amd-sev-snp Execute the script to download, install, and start K3s, a lightweight Kubernetes distribution. ```bash ./30-k3s-install.sh ``` -------------------------------- ### Install Dependencies and Build Coin Flip Project Source: https://docs.switchboard.xyz/docs-by-chain/evm/monad Installs project dependencies, fetches external libraries, builds the project, and sets up environment variables for the coin flip example. ```bash cd ../randomness/coin-flip bun install [ -d lib/forge-std ] || forge install foundry-rs/forge-std --no-git --shallow forge build cp .env.example .env ``` -------------------------------- ### Install Switchboard Solidity Interfaces Source: https://docs.switchboard.xyz/docs-by-chain/evm/price-feeds/price-feeds-tutorial Installs the Switchboard Solidity interfaces either by copying them from the examples repository or via npm. This is necessary for interacting with Switchboard contracts in your Solidity project. ```bash # Copy from examples repo cp -r sb-on-demand-examples/evm/price-feeds/src/switchboard your-project/src/ # Or install via npm npm install @switchboard-xyz/on-demand-solidity ``` -------------------------------- ### Clone Examples Repository Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/prediction-market/prediction-market-tutorial Clone the Switchboard on-demand examples repository to get started with the prediction market examples. Navigate into the prediction market directory. ```bash git clone https://github.com/switchboard-xyz/sb-on-demand-examples cd sb-on-demand-examples/solana/prediction-market ``` -------------------------------- ### Run the Example Source: https://docs.switchboard.xyz/docs-by-chain/sui/price-feeds/price-feeds-tutorial Executes the complete example, which includes creating a QuoteConsumer, fetching data, and updating the price. Ensure the SUI_NETWORK and EXAMPLE_PACKAGE_ID environment variables are set correctly. ```bash # Match the network to the Move package you deployed export SUI_NETWORK=testnet export EXAMPLE_PACKAGE_ID=0xYOUR_PACKAGE_ID # Run the example npm run example # Or with custom parameters export FEED_HASH=0x4cd1cad962425681af07b9254b7d804de3ca3446fbfd1371bb258d2c75059812 export NUM_ORACLES=5 npm run example ``` -------------------------------- ### Clone Repository and Navigate Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/randomness/randomness-tutorial Clones the Switchboard on-demand examples repository and navigates into the coin-flip example directory. ```bash git clone https://github.com/switchboard-xyz/sb-on-demand-examples cd sb-on-demand-examples/solana/randomness/coin-flip ``` -------------------------------- ### Run the Conversion Example Source: https://docs.switchboard.xyz/docs-by-chain/evm/surge/surge-tutorial Execute the Surge conversion example using Bun. You can provide custom Surge data via an environment variable. ```bash # With sample data bun run surge-convert # With custom surge data file SURGE_DATA_FILE=path/to/surge-data.json bun run surge-convert ``` -------------------------------- ### Install Dependencies Source: https://docs.switchboard.xyz/docs-by-chain/evm/surge/surge-tutorial Install the necessary project dependencies using Bun. ```bash bun install ``` -------------------------------- ### HTTP GET Request Example Source: https://docs.switchboard.xyz/docs-by-chain/evm/price-feeds/price-feeds-tutorial To query documentation dynamically, perform an HTTP GET request to the page URL with the 'ask' query parameter. The question should be specific and self-contained. ```http GET https://docs.switchboard.xyz/docs-by-chain/evm/price-feeds/price-feeds-tutorial.md?ask= ``` -------------------------------- ### Clone Switchboard Examples Repository Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/price-feeds/basic-price-feed Clones the Switchboard on-demand examples repository and navigates into the basic price feed directory. This is the first step to running the example. ```bash git clone https://github.com/switchboard-xyz/sb-on-demand-examples cd sb-on-demand-examples/solana/feeds/basic ``` -------------------------------- ### Example Output: Program Not Deployed Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/price-feeds/basic-price-feed This output indicates that the example consumer program is not deployed, so the crank step was skipped and only the quote account was updated. ```text ℹ️ Skipping crank: basic_oracle_example program not deployed ✅ Transaction sent: 5c... ✅ Managed update confirmed ℹ️ The quote account was updated without the example consumer instruction ``` -------------------------------- ### Querying Documentation Dynamically Source: https://docs.switchboard.xyz/docs-by-chain/movement This example demonstrates how to perform an HTTP GET request to query documentation dynamically. Use the 'ask' query parameter for specific questions. ```http GET https://docs.switchboard.xyz/docs-by-chain/movement.md?ask= ``` -------------------------------- ### Clone the Examples Repository Source: https://docs.switchboard.xyz/docs-by-chain/sui/price-feeds/price-feeds-tutorial Clones the Switchboard on-demand examples repository and navigates into the basic Sui feeds directory. ```bash git clone https://github.com/switchboard-xyz/sb-on-demand-examples cd sb-on-demand-examples/sui/feeds/basic ``` -------------------------------- ### Run the Example with npm Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/price-feeds/basic-price-feed Executes the example using npm, defaulting to the BTC/USD feed. This command will run the TypeScript client to fetch and process the oracle data. ```bash # Using default BTC/USD feed npm run update ``` -------------------------------- ### Clone Examples Repository (Bash) Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/price-feeds/advanced-price-feed Clone the Switchboard on-demand examples repository to access the advanced price feed example code. ```bash git clone https://github.com/switchboard-xyz/sb-on-demand-examples cd sb-on-demand-examples/solana/feeds/advanced ``` -------------------------------- ### Install Switchboard Dependencies Source: https://docs.switchboard.xyz/custom-feeds/build-and-deploy-feed/deploy-feed Install the necessary Switchboard SDK packages for your project. ```bash bun add @switchboard-xyz/on-demand @switchboard-xyz/common ``` -------------------------------- ### Install Helm and K9s Source: https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/installation-setup-via-scripts/bare-metal-with-kubernetes-k3s-%2B-amd-sev-snp Run the script to install essential utility tools like Helm and K9s for Kubernetes interaction. ```bash ./01-helm-install.sh ``` -------------------------------- ### Install snphost Utility Source: https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/installation-setup-via-scripts/bare-metal-with-kubernetes-k3s-%2B-amd-sev-snp Install the 'snphost' utility, which performs AMD SEV SNP checks. Run 'snphost ok' to verify system settings. ```bash ./02-snphost-install.sh ``` ```bash snphost ok ``` -------------------------------- ### Install Solidity SDK Source: https://docs.switchboard.xyz/docs-by-chain/evm/randomness/randomness-tutorial Install the Switchboard on-demand Solidity SDK using npm. This package provides the necessary interfaces and libraries for interacting with Switchboard randomness on EVM. ```bash npm install @switchboard-xyz/on-demand-solidity ``` -------------------------------- ### Install Switchboard On-Demand SDK Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/surge/surge-tutorial Install the Switchboard On-Demand SDK using npm or yarn. Ensure you are using Node.js 18+. ```bash npm install @switchboard-xyz/on-demand@3.9.0 # or yarn add @switchboard-xyz/on-demand@3.9.0 ``` -------------------------------- ### Install Switchboard SDKs for Sui Source: https://docs.switchboard.xyz/docs-by-chain/sui/surge Install the necessary Switchboard SDKs and their dependencies for Sui development. This includes the on-demand SDK, Sui SDK, Sui client, and Solana web3.js. ```bash npm install @switchboard-xyz/on-demand@3.9.0 @switchboard-xyz/sui-sdk@0.1.14 @mysten/sui@1.38.0 @solana/web3.js@1.98.4 ``` ```bash yarn add @switchboard-xyz/on-demand@3.9.0 @switchboard-xyz/sui-sdk@0.1.14 @mysten/sui@1.38.0 @solana/web3.js@1.98.4 ``` -------------------------------- ### Run Price Feeds Example on Monad Mainnet Source: https://docs.switchboard.xyz/docs-by-chain/evm/monad Run the price feeds example on Monad mainnet by setting the NETWORK environment variable. Ensure your .env file is configured for mainnet. ```bash NETWORK=monad-mainnet bun run example ``` -------------------------------- ### Configure Environment Variables Source: https://docs.switchboard.xyz/docs-by-chain/evm/price-feeds/price-feeds-tutorial Sets up the `.env` file for the example, including `PRIVATE_KEY`, `NETWORK`, `RPC_URL`, `SWITCHBOARD_ADDRESS`, and `CONTRACT_ADDRESS`. It is recommended to add `.env` to `.gitignore` for security. ```bash PRIVATE_KEY=0x... NETWORK=monad-testnet RPC_URL= SWITCHBOARD_ADDRESS= # Optional: if omitted, the script deploys a new consumer contract CONTRACT_ADDRESS=0x... ``` -------------------------------- ### Install VM Agent for Kubernetes Source: https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/installation-setup-via-scripts/bare-metal-with-kubernetes-k3s-%2B-amd-sev-snp Installs the VM agent for Kubernetes. Choose the appropriate network (devnet or mainnet) for your setup. ```bash # only choose the one that applies to your setup - optional step ./73-k8s-apps-vmagent.sh # uses devnet by default ./73-k8s-apps-vmagent.sh devnet # equivalent to above ./73-k8s-apps-vmagent.sh mainnet # run this for mainnet ``` -------------------------------- ### Run Price Feeds Example (Testnet) Source: https://docs.switchboard.xyz/docs-by-chain/evm/monad Execute the price feeds example. If CONTRACT_ADDRESS is unset in .env, a fresh consumer will be deployed automatically. Use 'bun run deploy' to deploy separately first. ```bash bun run example ``` -------------------------------- ### Install Infisical for Secrets Management Source: https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/installation-setup-via-scripts/bare-metal-with-kubernetes-k3s-%2B-amd-sev-snp Installs artifacts and code for Infisical integration. This step is optional and requires data from your `cfg` file with variables starting with `INFISICAL_`. ```bash # only choose the one that applies to your setup - optional step ./79-k8s-apps-infisical.sh # uses devnet by default ./79-k8s-apps-infisical.sh devnet # equivalent to above ./79-k8s-apps-infisical.sh mainnet # run this for mainnet ``` -------------------------------- ### ExponentPTLinearPricingTask Example Source: https://docs.switchboard.xyz/custom-feeds/task-types Computes the current price of an Exponent principal token using a linear schedule from a specified start price to 1.0 at maturity. Requires the vault address and the starting price. ```json { "exponentPtLinearPricingTask": { "vault": "9YbaicMsXrtupkpD72pdWBfU6R7EJfSByw75sEpDM1uH", "startPrice": 0.8 } } ``` -------------------------------- ### Build and Deploy Anchor Program Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/price-feeds/basic-price-feed Builds and deploys the sample Anchor program. This step is optional if you only want to test the quote update flow, but it's required if you want the example to invoke `read_oracle_data` after the update. ```bash anchor build anchor deploy ``` -------------------------------- ### Legacy EVM Update Response Payload Source: https://docs.switchboard.xyz/ai-agents-llms/switchboard-agent-skill/switchboard-crossbar-ops Example JSON response payload for GET /updates/evm/{chainId}/{aggregatorIds} endpoint. ```json { "results": [ { "result": "123450000000000000000" } ], "failures": [], "encoded": [ "0x8f6f2b7c..." ] } ``` -------------------------------- ### MinTask Example with Jobs Source: https://docs.switchboard.xyz/custom-feeds/task-types Demonstrates MinTask with a list of jobs, each containing HTTP and JSON parsing tasks to fetch numerical data for minimum calculation. ```json { "minTask": { "jobs": [ { "tasks": [ { "httpTask": { "url": "https://www.binance.com/api/v3/ticker/price?symbol=SOLUSDT" } }, { "jsonParseTask": { "path": "$.price" } } ] }, { "tasks": [ { "httpTask": { "url": "https://www.binance.us/api/v3/ticker/price?symbol=SOLUSD" } }, { "jsonParseTask": { "path": "$.price" } } ] }, { "tasks": [ { "httpTask": { "url": "https://api-pub.bitfinex.com/v2/tickers?symbols=tSOLUSD" } }, { "jsonParseTask": { "path": "$[0][7]" } } ] } ] } } ``` -------------------------------- ### Example Script Naming Convention Source: https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/installation-setup-via-scripts Scripts are named with a numerical prefix to indicate the correct execution order, facilitating a step-by-step installation process. ```bash 00-kernel-install.sh # absolutely FIRST step # [...] 30-k3s-install.sh # then this needs to be run before ... 31-k3s-sail-setup.sh # ... this script but ... # [...] 70-k8s-apps-cert-manager.sh # ... this happens even # later in the setup! # [...] 90-k8s-oracle-install.sh # this is usually # the last step you'll run ``` -------------------------------- ### Get Sui LST Price (haSUI Example) Source: https://docs.switchboard.xyz/custom-feeds/task-types Retrieve the exchange rate for a Sui Liquid Staking Token (LST) relative to SUI. This example demonstrates fetching the rate for haSUI, requiring package ID, module, function, and shared object details. ```json { "suiLstPriceTask": { "packageId": "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d", "module": "staking", "function": "get_sui_by_stsui", "sharedObjects": [ "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca" ], "provideLstAmount": true } } ``` -------------------------------- ### v2 Update Response Payload Source: https://docs.switchboard.xyz/ai-agents-llms/switchboard-agent-skill/switchboard-crossbar-ops Example JSON response payload for GET /v2/update/{feedHashes} endpoint. For EVM consumers, wrap 'encoded' into a one-element bytes[] when calling getFee or updateFeeds. ```json { "medianResponses": [ { "value": "123450000000000000000", "feedHash": "0xfd2b067707a96e5b67a7500e56706a39193f956a02e9c0a744bf212b19c7246c", "numOracles": 3 } ], "oracleResponses": [], "timestamp": 1730000000, "slot": 0, "recentHash": "0xabc123...", "encoded": "0x8f6f2b7c..." } ``` -------------------------------- ### Test TLS Certificate Creation Source: https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/installation-setup-via-scripts/bare-metal-with-kubernetes-k3s-%2B-amd-sev-snp Creates an Ingress to test Kubernetes installation, DNS setup, and the entire flow. After running, visit your system's DNS record to verify. This step is optional. ```bash # only choose the one that applies to your setup - optional step ./80-test-cert-setup.sh # uses devnet by default ./80-test-cert-setup.sh devnet # equivalent to above ./80-test-cert-setup.sh mainnet # run this for mainnet ``` -------------------------------- ### Example Output: Program Deployed Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/price-feeds/basic-price-feed This output shows successful fetching and reading of oracle data, including simulated feed results, staleness, and final feed values, when the example program is deployed. ```text Queue: FdRnYujMnYbAJp5P2rkEYZCbF2TKs2D2yXZ7MYq89Hms Network: devnet Quote Account: 8Js7NsQ7sF3WLJN3JC4LJQGz8kHiEJwZ7sdGTtJC5J7d Simulated feed result: { value: 97234.5, ... } Number of feeds: 1 Quote slot: 123456789, Current slot: 123456790 Staleness: 1 slots Feed 0: ID = 4cd1cad962425681af07b9254b7d804de3ca3446fbfd1371bb258d2c75059812 Feed 0: Value = 97234.50 Successfully read 1 oracle feeds! ``` -------------------------------- ### Get Sui LST Price (vSUI Example) Source: https://docs.switchboard.xyz/custom-feeds/task-types Fetch the exchange rate for vSUI relative to SUI, involving multiple shared objects for the StakePool and Metadata. Configuration includes package ID, module, function, and a list of shared objects. ```json { "suiLstPriceTask": { "packageId": "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20", "module": "stake_pool", "function": "lst_amount_to_sui_amount", "sharedObjects": [ "0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5", "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60" ], "provideLstAmount": true } } ``` -------------------------------- ### Bash: Environment File Setup for Variable Overrides Source: https://docs.switchboard.xyz/custom-feeds/advanced-feed-configuration/data-feed-variable-overrides Shows how to set up environment variables using a .env file. The recommended method only includes authentication variables. ```bash # Not recommended .env setup # echo "BASE_URL=https://api.example.com" >> .env # Unverifiable # echo "SYMBOL=BTC" >> .env # Data selection # echo "JSON_PATH=$.result.price" >> .env # Data extraction # Recommended .env setup - only authentication echo "API_KEY=your_api_key_here" >> .env echo "AUTH_TOKEN=your_auth_token" >> .env # Load automatically with dotenv bun run scripts/test-job.ts ``` -------------------------------- ### Derive Multiple Random Values (Rust) Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/randomness/randomness-tutorial After obtaining the 32-byte random value, you can derive multiple independent random outcomes by using different bytes for different purposes. This example shows how to get a coin flip, dice roll, and card draw. ```rust let random_bytes = randomness_data.get_value(clock.slot)?; // Use different bytes for different purposes let coin_flip = random_bytes[0] % 2 == 0; let dice_roll = (random_bytes[1] % 6) + 1; // 1-6 let card_draw = random_bytes[2] % 52; // 0-51 ``` -------------------------------- ### Initialize Surge and Subscribe to Feeds Source: https://docs.switchboard.xyz/docs-by-chain/sui/surge Initialize the Surge SDK with your keypair and connection. Discover available feeds and subscribe to specific price feeds like BTC/USD and ETH/USD. Handles price updates and converts them to Sui oracle quotes. ```typescript import * as sb from "@switchboard-xyz/on-demand"; import { convertSurgeUpdateToQuotes, MAINNET_QUEUE_ID } from "@switchboard-xyz/sui-sdk"; import { Transaction } from "@mysten/sui/transactions"; // Initialize with keypair and connection (uses on-chain subscription) const surge = new sb.Surge({ connection, keypair }); // `connection` is a Solana RPC Connection from @solana/web3.js (used to verify the Solana subscription), // not your Sui client. Keep a separate Sui client for on-chain writes. // Auth note: the SDK signs with your keypair to authenticate the session. // If the keypair has no active Surge subscription, connectAndSubscribe will fail. // Discover available feeds const availableFeeds = await surge.getSurgeFeeds(); console.log(`${availableFeeds.length} feeds available`); // Subscribe to specific feeds await surge.connectAndSubscribe([ { symbol: 'BTC/USD' }, { symbol: 'ETH/USD' }, ]); // Handle price updates surge.on('signedPriceUpdate', async (response: sb.SurgeUpdate) => { const metrics = response.getLatencyMetrics(); if (metrics.isHeartbeat) return; const prices = response.getFormattedPrices(); metrics.perFeedMetrics.forEach((feed) => { console.log(`${feed.symbol}: ${prices[feed.feed_hash]}`); }); // Convert to on-chain Oracle Quote for Sui contracts when needed const ptb = new Transaction(); const quoteData = await convertSurgeUpdateToQuotes(ptb, response, MAINNET_QUEUE_ID); ptb.moveCall({ target: `${PACKAGE_ID}::your_module::your_function`, arguments: [quoteData], }); }); ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/price-feeds/advanced-price-feed To get additional information not directly on the page, perform an HTTP GET request with the 'ask' query parameter. ```http GET https://docs.switchboard.xyz/docs-by-chain/solana-svm/price-feeds/advanced-price-feed.md?ask= ``` -------------------------------- ### Build and Deploy Advanced Oracle Program Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/price-feeds/advanced-price-feed Build the Solana program for the advanced oracle example and deploy it to devnet. ```bash cargo build-sbf --manifest-path programs/advanced-oracle-example/Cargo.toml solana program deploy target/deploy/advanced_oracle_example.so ``` -------------------------------- ### Install Custom Linux Kernel Source: https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/installation-setup-via-scripts/bare-metal-with-kubernetes-k3s-%2B-amd-sev-snp Execute the script to download and install a custom Linux kernel patched for AMD SEV SNP support. A reboot is required after installation. ```bash ./00-kernel-install.sh ``` -------------------------------- ### Build and Deploy Program Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/prediction-market/prediction-market-tutorial Build the Solana program and deploy it to the devnet cluster using the Anchor framework. ```bash anchor build anchor deploy --provider.cluster devnet ``` -------------------------------- ### Minimal Example: Fetching and Executing an Aggregator Update Transaction Source: https://docs.switchboard.xyz/ai-agents-llms/switchboard-agent-skill/switchboard-iota-feeds This snippet demonstrates the basic steps to initialize a Switchboard client and an aggregator, fetch an update transaction, and then sign and execute it on the Iota network. Ensure you have the necessary imports and an initialized Iota client and keypair. ```typescript import { Aggregator, SwitchboardClient } from "@switchboard-xyz/iota-sdk"; import { Transaction } from "@iota/iota-sdk/transactions"; const sb = new SwitchboardClient(iotaClient); const aggregator = new Aggregator(sb, aggregatorId); const tx = new Transaction(); await aggregator.fetchUpdateTx(tx); await iotaClient.signAndExecuteTransaction({ signer: keypair, transaction: tx }); ``` -------------------------------- ### Install Switchboard Iota SDK via Bun Source: https://docs.switchboard.xyz/docs-by-chain/iota Add the Switchboard Iota SDK and its dependencies to your project using Bun. Ensure you are using compatible versions. ```bash bun add @switchboard-xyz/iota-sdk@0.0.3 @switchboard-xyz/common@5.7.0 @iota/iota-sdk@1.11.0 ``` -------------------------------- ### Navigate to Kubernetes Installation Directory Source: https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/installation-setup-via-scripts/bare-metal-with-kubernetes-k3s-%2B-amd-sev-snp Change the current directory to the Kubernetes installation scripts. ```bash cd install/bare-metal/kubernetes ``` -------------------------------- ### Deploy Price Feeds Consumer Separately Source: https://docs.switchboard.xyz/docs-by-chain/evm/monad Deploy a fresh consumer contract for the price feeds example. After deployment, save the emitted address into CONTRACT_ADDRESS in your .env file before rerunning 'bun run example'. ```bash bun run deploy ``` -------------------------------- ### Project Structure Overview Source: https://docs.switchboard.xyz/docs-by-chain/sui/price-feeds/price-feeds-tutorial Illustrates the directory structure for the Switchboard price feed example project on Sui. ```bash sui/feeds/basic/ ├── Move.toml # Checked-in default Move config (testnet) ├── Move.testnet.toml # Explicit testnet configuration ├── Move.mainnet.toml # Explicit mainnet configuration ├── sources/ │ └── example.move # Quote Consumer contract with verifier ├── scripts/ │ ├── run.ts # Complete TypeScript example │ └── quotes.ts # Simple quote fetching example └── package.json ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/configuration-tweaking-configurations/cfg-00-common-vars.cfg To get additional information not directly on the page, perform an HTTP GET request to the current URL with the 'ask' query parameter. The question should be specific and in natural language. ```http GET https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/configuration-tweaking-configurations/cfg-00-common-vars.cfg.md?ask= ``` -------------------------------- ### Query Documentation with GET Request Source: https://docs.switchboard.xyz/custom-feeds/build-and-deploy-feed/build-with-typescript To get additional information not explicitly present on the page, perform an HTTP GET request to the current page URL with the `ask` query parameter. The question should be specific and self-contained. ```http GET https://docs.switchboard.xyz/custom-feeds/build-and-deploy-feed/build-with-typescript.md?ask= ``` -------------------------------- ### Setup EVM Environment Source: https://docs.switchboard.xyz/docs-by-chain/evm/randomness/randomness-tutorial Initializes the ethers provider, wallet, and Crossbar client. Ensure your PRIVATE_KEY and PANCAKE_STACKER_CONTRACT_ADDRESS environment variables are set. ```typescript import { ethers } from "ethers"; import { CrossbarClient } from "@switchboard-xyz/common"; // Contract ABI (only the functions we need) const PANCAKE_STACKER_ABI = [ "function flipPancake() public", "function catchPancake(bytes calldata encodedRandomness) public", "function getFlipData(address user) public view returns (bytes32 randomnessId, address oracle, uint256 rollTimestamp, uint256 minSettlementDelay)", "function getPlayerStats(address user) public view returns (uint256 currentStack, bool hasPendingFlip)", "event PancakeLanded(address indexed user, uint256 newStackHeight)", "event StackKnockedOver(address indexed user)", "event SettlementFailed(address indexed user)", ]; async function main() { // Resolve the target network. The packaged example defaults to Monad testnet // and lets you flip to mainnet by setting NETWORK=monad-mainnet. const networkName = process.env.NETWORK || "monad-testnet"; const rpcUrl = process.env.RPC_URL || (networkName === "monad-mainnet" ? "https://rpc.monad.xyz" : "https://testnet-rpc.monad.xyz"); const provider = new ethers.JsonRpcProvider(rpcUrl); const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider); const crossbar = new CrossbarClient("https://crossbar.switchboard.xyz"); const contract = new ethers.Contract( process.env.PANCAKE_STACKER_CONTRACT_ADDRESS!, PANCAKE_STACKER_ABI, wallet ); } ``` -------------------------------- ### Querying Documentation via HTTP GET Source: https://docs.switchboard.xyz/ai-agents-llms/switchboard-agent-skill/switchboard-aptos-feeds To get additional information not directly present on the page, perform an HTTP GET request to the current page URL with an 'ask' query parameter containing your question. ```http GET https://docs.switchboard.xyz/ai-agents-llms/switchboard-agent-skill/switchboard-aptos-feeds.md?ask= ``` -------------------------------- ### Example DNS Record for xip.switchboard-oracles.xyz Source: https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/prerequisites/network-requirements This example shows how to construct a DNS name using an IPv4 address and the `xip.switchboard-oracles.xyz` domain. This method provides a valid DNS resolution to the specified IPv4 address while also enabling TLS certificate management. ```dns 127.0.0.1.xip.switchboard-oracles.xyz ``` -------------------------------- ### Query Documentation via HTTP GET Request Source: https://docs.switchboard.xyz/ai-agents-llms/switchboard-agent-skill/switchboard-x402 To get additional information not directly present on the page, perform an HTTP GET request to the current page URL with the `ask` query parameter. The question should be specific and self-contained. ```http GET https://docs.switchboard.xyz/ai-agents-llms/switchboard-agent-skill/switchboard-x402.md?ask= ``` -------------------------------- ### Run Coin Flip Example Source: https://docs.switchboard.xyz/docs-by-chain/solana-svm/randomness/randomness-tutorial Executes the coin flip example script with either 'heads' or 'tails' as the argument. ```bash npm run start -- heads # or npm run start -- tails ``` -------------------------------- ### Clone and Build EVM Price Feeds Project Source: https://docs.switchboard.xyz/docs-by-chain/evm/hyperliquid Clone the Switchboard examples repository and build the shared price-consumer project using bun and forge. ```bash git clone https://github.com/switchboard-xyz/sb-on-demand-examples.git cd sb-on-demand-examples/evm/price-feeds bun install forge build ``` -------------------------------- ### Uninstall Logs Forwarding Source: https://docs.switchboard.xyz/how-it-works/switchboard-protocol/running-a-switchboard-oracle/installation-setup-via-scripts/bare-metal-with-kubernetes-k3s-%2B-amd-sev-snp Cleans up the logs forward installation after the support phase is completed. Verify that the installation is gone. ```bash helm uninstall -n sb-log-forwarding sb-log-forwarding ```