Solana Geyser gRPC - 快速入門

安裝 SLV

bash
curl -fsSL https://storage.slv.dev/slv/install | sh

$ slv b init

slv b init
只需一條命令 slv b init,即可立即搭建基於高效能流資料的 Solana 機器人開發環境。
bash
slv b init
  • 如果您偏好 TypeScript Geyser 機器人,請選擇 geyser-ts
  • 如果您偏好 Rust Geyser 機器人,請選擇 geyser-rust

將 gRPC 負載均衡器 IP 加入白名單

系統會使用每個區域 gRPC 負載均衡器的實時 ping 檢測,選擇距離您註冊 IP 最近的節點。如果防火牆(ufw、安全組等)阻止了 ICMP,ping 可能顯示 9999ms,這可能導致無法選擇最佳的就近區域。請將以下 IP 加入白名單,以便自動選擇最近的區域。
RegionDomainIP Address
🇳🇱 Amsterdamgrpc-ams1.erpc.global84.32.103.245
🇳🇱 Amsterdamgrpc-ams1.erpc.global84.32.64.77
🇺🇸 New Yorkgrpc-ny6-1.erpc.global64.130.37.222
🇩🇪 Frankfurtgrpc-fra1-1.erpc.global185.191.118.149
🇩🇪 Frankfurtgrpc-fra1-1.erpc.global185.191.118.177
🇩🇪 Frankfurtgrpc-fra1-1.erpc.global185.191.118.206
🇬🇧 Londongrpc-lon6-1.erpc.global67.209.52.250
🇯🇵 Tokyogrpc-tokyo-6.erpc.global198.13.133.88
🇸🇬 Singaporegrpc-sgp6-1.erpc.global202.8.11.52
🇦🇺 Sydneygrpc-syd-1.erpc.global82.26.116.36
🛰️ Far Pointgrpc-far-point.erpc.global63.254.162.14

Burst gRPC 端點

Geyser gRPC Burst 是 ERPC 為延遲敏感型 Solana 串流工作負載提供的低延遲共享 gRPC 層級。Burst 使用與常規 gRPC 服務相同的 Yellowstone/Geyser gRPC 介面,因此現有 gRPC 用戶端可以繼續使用標準的 account、transaction、slot 和 block 訂閱。
Burst 目前在 Frankfurt、Amsterdam、New York、Tokyo 和 Singapore 運行。延遲選擇仍會使用上方列出的常規 gRPC ping 來源 IP;下方的 Burst 負載平衡器 IP 是需要允許用戶端連線的公開 Burst 端點。
RegionBurst DomainIP Address
🇩🇪 Frankfurtgrpc-fra1-burst.erpc.global64.130.41.234
🇳🇱 Amsterdamgrpc-ams1-burst.erpc.global64.130.55.180
🇺🇸 New Yorkgrpc-ny6-burst.erpc.global64.130.59.217
🇯🇵 Tokyogrpc-tokyo-burst.erpc.global208.91.107.247
🇸🇬 Singaporegrpc-singapore-burst.erpc.global67.209.55.15
註冊 IP 後,請使用 ERPC Web Dashboard 中顯示的端點。Burst 仍是完整的 Geyser gRPC stream;Direct Shreds/ShredStream 是用於原始 shred 資料的獨立 UDP 產品。

Geyser 客戶端示例 - TypeScript

  1. .env.sample 重新命名為 .env
  2. 使用您的實際值編輯 .env
ini
GEYSER_ENDPOINT=http://grpc-ams1.erpc.global
SOLANA_RPC_ENDPOINT="https://edge.erpc.global?api-key=YOUR_API_KEY"
請注意:
此端點為示例,不能直接使用。請獲取並配置適合您環境的端點。
  1. 安裝依賴並啟動開發伺服器:
bash
pnpm i
pnpm dev
Geyser TypeScript VSCode

Geyser 客戶端示例 - Rust

  1. .env.sample 重新命名為 .env
  2. 使用您的實際值編輯 .env
ini
GEYSER_ENDPOINT=http://grpc-ams1.erpc.global
SOLANA_RPC_ENDPOINT="https://edge.erpc.global?api-key=YOUR_API_KEY"
請注意:
此端點為示例,不能直接使用。請獲取並配置適合您環境的端點。
  1. 構建並執行客戶端:
bash
RUST_LOG=info cargo run
Geyser Rust VSCode

✅ 提供 1 天免費試用

Geyser 和 Shreds 機器人均可透過 ERPC Web 儀表盤 官方伺服器免費試用 1 天。

Solana Stream SDK

Solana Stream SDK
透過 slv b init 命令下載的啟動程式碼中使用的 Geyser 介面卡 由開源專案 Solana Stream SDK 提供。
它同時支援 Rust 和 TypeScript,能夠高效實現 Solana 流通訊, 包括 Geyser 訂閱、交易處理和實時賬戶更新監控。
您獲得的啟動程式碼是該 SDK 實際應用的直接示例, 便於您擴充套件用於自己的機器人開發或自定義邏輯。
更多詳情請訪問 GitHub 倉庫: https://github.com/ValidatorsDAO/solana-stream