switchboard
Skill này làm gì
Skill này hướng dẫn tích hợp Switchboard, một giao thức oracle không cần cấp phép trên Solana. Nó dành cho nhà phát triển cần feed giá, tính ngẫu nhiên có thể kiểm chứng hoặc dữ liệu tùy chỉnh cho chương trình của mình.
Khi nào nên dùng
- ✓Khi chương trình Solana của bạn cần feed giá từ một oracle bạn có thể triển khai mà không cần phê duyệt.
- ✓Khi bạn cần tính ngẫu nhiên có thể kiểm chứng cho tính năng trò chơi hoặc xổ số.
- ✓Khi bạn muốn dữ liệu streaming độ trễ thấp qua dịch vụ Surge.
Liên kết skill
https://github.com/internet-court/internet-court-skill/blob/main/vendored/sendaifun/switchboard/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy giúp tôi thêm feed giá Switchboard vào chương trình Solana và đọc giá mới nhất.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent thiết lập SDK Switchboard, chọn giữa báo giá theo yêu cầu, feed giá hoặc streaming, rồi viết mã đọc dữ liệu. Nó dùng tích hợp Rust hoặc TypeScript tùy theo dự án của bạn.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Switchboard Oracle Protocol - Complete Integration Guide
The definitive guide for integrating Switchboard - the fastest, most customizable, and only permissionless oracle protocol on Solana.
What is Switchboard?
Switchboard is a permissionless oracle protocol enabling developers to bring custom data on-chain with industry-leading performance:
- Price Feeds - Real-time asset pricing with pull-based efficiency
- Oracle Quotes - Sub-second latency without on-chain storage (90% cost reduction)
- Surge - WebSocket streaming with sub-100ms latency
- VRF Randomness - Cryptographically secure verifiable random functions
- Prediction Markets - Market-based forecasting data
Key Statistics
- Secures $1B+ in on-chain volume
- Used by Kamino, Jito, MarginFi, Drift Protocol
- 2-5ms latency with Surge pricing
- 90% cost reduction vs traditional oracles
Core Principles
| Principle | Description |
|---|---|
| Speed | 2-5ms with Surge, 400ms standard - industry-leading for DeFi |
| Cost Efficiency | Pull-based feeds eliminate constant streaming costs |
| Permissionless | Deploy feeds instantly without approvals |
| Security | TEE (Trusted Execution Environments) prevent data manipulation |
Integration Approaches
1. Oracle Quotes (Recommended)
Direct oracle-to-program data flow without on-chain storage:
- Sub-second latency
- 90% cost reduction
- No write locks (parallel reads)
- Stateless design
2. Traditional Feeds
Classic pull-based feed updates:
- Feed account maintenance
- Cranking operations
- Good for simple use cases
3. Surge (Real-Time)
WebSocket streaming for high-frequency applications:
- Sub-100ms latency
- Persistent connections
- Ideal for trading interfaces
Program IDs
| Program | Mainnet | Devnet |
|---|---|---|
| Oracle Program | SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f |
Aio4gaXjXzJNVLtzwtNVmSqGKpANtXhybbkhtAC94ji2 |
| Quote Program | orac1eFjzWL5R3RbbdMV68K9H6TaCVVcL6LjvQQWAbz |
- |
Default Queues
| Network | Queue Address |
|---|---|
| Mainnet | A43DyUGA7s8eXPxqEjJY6EBu1KKbNgfxF8h17VAHn13w |
| Devnet | EYiAmGSdsQTuCw413V5BzaruWuCCSDgTPtBGvLkXHbe7 |
Quick Start
Installation
# TypeScript SDK
npm install @switchboard-xyz/on-demand @switchboard-xyz/common
# Rust (Cargo.toml)
# switchboard-on-demand = "0.8.0"
Basic Setup
import { web3, AnchorProvider, Program } from "@coral-xyz/anchor";
import {
PullFeed,
CrossbarClient,
ON_DEMAND_MAINNET_PID,
ON_DEMAND_DEVNET_PID
} from "@switchboard-xyz/on-demand";
// Setup connection and provider
const connection = new web3.Connection("https://api.mainnet-beta.solana.com");
const wallet = useWallet(); // or Keypair
const provider = new AnchorProvider(connection, wallet);
// Load Switchboard program
const sbProgram = await Program.at(ON_DEMAND_MAINNET_PID, provider);
// Initialize Crossbar client for oracle communication
const crossbar = new CrossbarClient("https://crossbar.switchboard.xyz");
Price Feeds
Fetch and Update Feed
import { PullFeed, asV0Tx } from "@switchboard-xyz/on-demand";
// Create feed account reference
const feedPubkey = new web3.PublicKey("YOUR_FEED_PUBKEY");
const feedAccount = new PullFeed(sbProgram, feedPubkey);
// Fetch update instruction with oracle signatures
const { pullIx, responses, numSuccess, luts } = await feedAccount.fetchUpdateIx({
crossbarClient: crossbar,
chain: "solana",
network: "mainnet", // or "devnet"
});
// Build and send transaction
const tx = await asV0Tx({
connection,
ixs: [pullIx],
signers: [payer],
computeUnitPrice: 200_000,
computeUnitLimitMultiple: 1.3,
lookupTables: luts,
});
const signature = await connection.sendTransaction(tx);
console.log("Feed updated:", signature);
Read Feed Value
// Get current feed value
const feedData = await feedAccount.loadData();
const value = feedData.value.toNumber();
const lastUpdated = feedData.lastUpdatedSlot;
console.log(`Price: ${value}, Last Updated: ${lastUpdated}`);
Oracle Quotes (Recommended)
Oracle Quotes provide the most efficient way to consume oracle data:
import { OracleQuote } from "@switchboard-xyz/on-demand";
// Feed hashes (64-char hex strings)
const feedHashes = [
"0x...", // SOL/USD
"0x...", // BTC/USD
];
// Derive canonical quote account
const queueKey = new web3.PublicK
Câu hỏi thường gặp
Switchboard có cần cấp phép không?
Có. Skill nói bạn có thể triển khai feed mà không cần phê duyệt từ ai.
VRF randomness là gì?
Skill mô tả đó là hàm ngẫu nhiên có thể kiểm chứng, cho ra giá trị ngẫu nhiên an toàn.
Nó có dùng phần cứng bảo mật không?
Skill nói môi trường thực thi đáng tin cậy (TEE) giúp ngăn chặn việc thao túng dữ liệu.
Chi tiết
Mô tả gốc của tác giả
Complete Switchboard Oracle Protocol SDK for Solana - the permissionless oracle solution for price feeds, on-demand data, VRF randomness, and real-time streaming via Surge. Covers TypeScript SDK, Rust integration, Oracle Quotes, and all Switchboard tools.
Độ phổ biến
- Sao GitHub
- 7.0k
- Vị trí xếp hạng
- #13683
- Giấy phép
- —
- Cập nhật
- 26/10/2026
Bình luận
- …
Thêm skill từ kho mã này
internet-court
7.0kGiúp agent của bạn thanh toán, thuê hoặc giao dịch an toàn với một agent AI khác hoặc dịch vụ trả phí, và chỉ đến hướng dẫn chuyên sâu phù hợp.
genlayer-erc7710-connector
7.0kGiúp agent của bạn kết nối kết quả đánh giá AI với hệ thống quyền hạn, để một đánh giá xấu có thể hạn chế hoặc hủy quyền của agent.
genlayer-intelligent-contracts
7.0kGiúp agent của bạn xác định quy tắc, bằng chứng và đầu ra của một AI judge kiểm tra xem agent khác có làm đúng nhiệm vụ được ủy quyền hay không.
x402-erc7710
7.0kGiúp agent của bạn trả tiền cho dịch vụ web theo từng yêu cầu, và thiết lập chi tiêu định kỳ nằm trong ngân sách quyền hạn.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.