ERPC Solana RPC 端點文件
Solana RPC 端點文件
這個 Solana RPC 端點可用於 HTTP 請求與 WebSocket 訂閱。將 ERPC Dashboard 產生的 API key 加到
api-key 參數後,即可把交易機器人、錢包、DeFi 應用或分析後端連到 ERPC 的全球代理網路。請將您的 API key 新增到
api-key 參數中。endpoint
範例:
以下是 HTTP 請求範例。
bash
以下是 WebSocket 訂閱範例。主機地址與 HTTP 相同。
endpoint
bash
您可以在 ERPC Web Dashboard 上取得和檢視您的 API key:ERPC Web Dashboard
如果您需要比 WebSocket 更低的延遲,請考慮使用 Geyser gRPC 或 ShredStream。您可以在 ERPC Web Dashboard 中與我們討論詳情。
History Access
若要查找較早的區塊和交易,請在 HTTP 請求的
edge.erpc.global URL 中加入 history=true;值必須恰好是小寫的 true。除 getTransactionsForAddress 外,不帶 history=true 的請求由每個節點保存的近期範圍回應;此選項適用於以下方法:getBlockgetBlockTimegetBlocksgetBlocksWithLimitgetTransaction,包括getParsedTransactiongetSignaturesForAddressgetSignatureStatuses,當searchTransactionHistory為true時getTransactionsForAddress,當transactionDetails為"full"時(需要 History Access)
將 API key 和此選項作為 query parameter 放在 URL 中:
endpoint
或者將
Authorization: Bearer <YOUR_API_KEY> 作為 header 傳送,並在 URL 中保留此選項:endpoint
以下是使用 History Access 的 HTTP 請求範例。
bash
對於除
getTransactionsForAddress 的 "full" 模式之外的所有方法:- 每個由 History Access 回應的呼叫比其一般價格多消耗 640 個代幣:
getBlock消耗 42 + 640 = 682。 - 來自 History Access 的
null、空結果或部分結果同樣會產生額外消耗。查找失敗不會產生額外消耗。 - 由近期資料回應的呼叫即使帶有
history=true,也維持一般價格。 - 批次會逐個計算其中的每次呼叫;
getSignatureStatuses每次呼叫只計算一次,而不是依簽章計算。 - 輪詢近期交易時請不要加
history=true:那裡的每個null都會產生額外消耗。
免費額度(包括 Free 方案的額度)對 History Access 設有上限。Free 方案限制為每 10 秒一個 History Access 請求。
transactionDetails 設為 "full" 的 getTransactionsForAddress 呼叫屬於 History Access,無論交易是近期的還是較早的:- 此呼叫要求在
edge.erpc.globalURL 中帶上history=true。不帶此選項的請求會被拒絕並回傳 History Access 錯誤(錯誤碼-32011),且不會產生任何消耗。 - 帶有
history=true時,此呼叫消耗 420 + 640 × N 個代幣:其一般價格 420,加上所取得的 N 筆交易每筆 640,無論交易是近期的還是較早的。沒有交易的資料列不計入。 - 此呼叫必須作為單獨的請求傳送。包含它的批次無論是否帶有
history=true都會被拒絕:批次中的每個呼叫都會收到錯誤-32600和訊息This request is not available in a mixed JSON-RPC batch. Please send it as a separate request.,且其中沒有任何一個會被傳送。
預設的
signatures 模式不需要 history=true,也不會產生額外消耗。若要輪詢某個地址的新交易,請使用 signatures 模式,並透過 getTransaction 取得所需的交易。查找較早的區塊或交易可能比一般請求耗時長得多,某些情況下會達到數秒。History Access 是一個獨立的選項,它把這類查找與一般請求分開,讓一般請求保持快速。
不帶
history=true 時,對較早 slot 發出的 getBlock 或 getBlockTime 請求可能回傳以下錯誤:json
對於早於節點所保存範圍的簽章,
getTransaction、getParsedTransaction 和 getSignatureStatuses(searchTransactionHistory: true 時)回傳 null,而 getSignaturesForAddress、getBlocks 和 getBlocksWithLimit 回傳空結果或部分結果。帶有
history=true 的請求可能回傳以下訊息:This plan has reached its limit for history access. Add a paid plan to use tokens for history access.— 當某項免費額度(例如 Free 方案的額度)達到上限時顯示。History access is unavailable while your token balance is low. Add tokens.— 在付費方案中,代幣餘額不足時顯示。On the Free plan, history access is limited to one request per 10 seconds. Slow down or use a paid plan.— 在 Free 方案中,History Access 請求到達過快時顯示。
Unlimited Endpoint 支援方法
Unlimited Endpoints 是為低延遲標準 Solana RPC 呼叫最佳化的專用 HTTP 端點。支援的標準 Solana RPC 方法為:
getSlotgetBlockHeightgetLatestBlockhashgetBalancegetAccountInfogetMultipleAccountsgetTransactionsendTransactionsimulateTransactiongetSignatureStatusesgetRecentPrioritizationFeesgetHealthgetVersiongetEpochInfogetBlock
對於不在此支援範圍內的方法,請使用
https://edge.erpc.global?api-key=<YOUR_API_KEY>。Solana RPC 方法和文件
有關方法、參數和訂閱規範的完整列表,請參閱官方文件。文件涵蓋 HTTP 和 WebSocket 的使用方式。






