Solana RPC Endpoint Documentation
เอกสาร Solana RPC Endpoint
ใช้ ERPC เป็น Solana RPC endpoint สำหรับส่ง HTTP JSON-RPC requests และรับ WebSocket subscriptions. Solana endpoint URL เดียวกันรองรับ RPC methods มาตรฐาน และคุณสามารถจัดการ API key ได้จาก ERPC Web Dashboard.
เพิ่ม API key ของคุณในพารามิเตอร์
api-key.endpoint
ตัวอย่าง
ตัวอย่าง HTTP request:
bash
ตัวอย่าง WebSocket subscription. Host ใช้โดเมนเดียวกับ HTTP.
endpoint
bash
คุณสามารถสร้างและตรวจสอบ API key ได้ใน ERPC Web Dashboard: ERPC Web Dashboard
หากต้องการ latency ต่ำกว่า WebSocket ให้พิจารณา Geyser gRPC หรือ ShredStream และติดต่อเราเพื่อหารายละเอียดผ่าน ERPC Web Dashboard.
History Access
เพิ่ม
history=true ใน URL edge.erpc.global ของ HTTP request เพื่อค้นหาบล็อกและธุรกรรมที่เก่ากว่า ค่าต้องเป็น true ตรงตัว และเป็นตัวพิมพ์เล็ก นอกจาก getTransactionsForAddress แล้ว request ที่ไม่มี history=true จะได้รับคำตอบจากช่วงข้อมูลล่าสุดที่แต่ละ node เก็บไว้ ตัวเลือกนี้ใช้กับ method ต่อไปนี้:getBlockgetBlockTimegetBlocksgetBlocksWithLimitgetTransactionรวมถึงgetParsedTransactiongetSignaturesForAddressgetSignatureStatusesเมื่อsearchTransactionHistoryเป็นtruegetTransactionsForAddressเมื่อtransactionDetailsเป็น"full"(ต้องใช้ History Access)
ใส่ API key และตัวเลือกใน URL เป็น query parameter:
endpoint
หรือส่ง
Authorization: Bearer <YOUR_API_KEY> เป็น header โดยให้ตัวเลือกอยู่ใน URL:endpoint
ตัวอย่าง HTTP request ที่ใช้ History Access:
bash
สำหรับทุก method ยกเว้น
getTransactionsForAddress ในโหมด "full":- การเรียกแต่ละครั้งที่ History Access ตอบจะใช้มากกว่าราคาปกติ 640 tokens:
getBlockใช้ 42 + 640 = 682 - ผลลัพธ์
nullว่าง หรือบางส่วนจาก History Access มีค่าใช้จ่ายเพิ่มเติมเช่นกัน การค้นหาที่ล้มเหลวไม่มีค่าใช้จ่ายเพิ่มเติม - การเรียกที่ตอบจากข้อมูลล่าสุดยังคงใช้ราคาปกติ แม้จะมี
history=true - batch นับแต่ละการเรียกแยกกัน;
getSignatureStatusesนับหนึ่งครั้งต่อการเรียก ไม่ใช่ต่อ signature - อย่าใส่
history=trueในการ polling ธุรกรรมล่าสุด: ทุกnullที่นั่นมีค่าใช้จ่ายเพิ่มเติมเช่นกัน
โควตาฟรี รวมถึงของแพ็กเกจ Free มีขีดจำกัดสำหรับ History Access แพ็กเกจ Free จำกัดไว้ที่หนึ่ง request ของ History Access ต่อ 10 วินาที
การเรียก
getTransactionsForAddress ที่ตั้งค่า transactionDetails เป็น "full" คือ History Access ไม่ว่าธุรกรรมจะล่าสุดหรือเก่า:- การเรียกนี้ต้องมี
history=trueใน URLedge.erpc.globalส่วน request ที่ไม่มีตัวเลือกนี้จะถูกปฏิเสธด้วย error ของ History Access (code-32011) และไม่มีค่าใช้จ่าย - เมื่อมี
history=trueการเรียกนี้ใช้ 420 + 640 × N tokens: ราคาปกติ 420 บวก 640 สำหรับธุรกรรมแต่ละรายการจาก N รายการที่ดึงมา ไม่ว่าจะล่าสุดหรือเก่า แถวที่ไม่มีธุรกรรมจะไม่ถูกนับ - ต้องส่งการเรียกนี้เป็น request แยกต่างหาก batch ที่มีการเรียกนี้จะถูกปฏิเสธ ไม่ว่าจะมีหรือไม่มี
history=true: ทุกการเรียกใน batch จะได้รับ error-32600พร้อมข้อความThis request is not available in a mixed JSON-RPC batch. Please send it as a separate request.และจะไม่มีการเรียกใดถูกส่ง
โหมด
signatures เริ่มต้นไม่ต้องใช้ history=true และไม่มีค่าใช้จ่ายเพิ่มเติม หากต้องการ poll ที่อยู่เพื่อหาธุรกรรมใหม่ ให้ใช้โหมด signatures แล้วดึงธุรกรรมที่ต้องการด้วย getTransactionการค้นหาบล็อกหรือธุรกรรมที่เก่ากว่าอาจใช้เวลานานกว่า request ปกติมาก ในบางกรณีนานเป็นวินาที History Access เป็นตัวเลือกแยกต่างหากที่แยกการค้นหาเหล่านี้ออกจาก request ปกติ เพื่อให้ request ปกติยังคงเร็ว
หากไม่มี
history=true request getBlock หรือ getBlockTime สำหรับ slot ที่เก่ากว่าอาจคืนค่า error นี้:json
getTransaction, getParsedTransaction และ getSignatureStatuses (เมื่อใช้ searchTransactionHistory: true) คืนค่า null สำหรับ signature ที่เก่ากว่าที่ node เก็บไว้ ส่วน getSignaturesForAddress, getBlocks และ getBlocksWithLimit คืนผลลัพธ์ว่างหรือบางส่วนrequest ที่มี
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.— แสดงในแพ็กเกจแบบชำระเงินเมื่อยอด tokens คงเหลือต่ำOn the Free plan, history access is limited to one request per 10 seconds. Slow down or use a paid plan.— แสดงในแพ็กเกจ Free เมื่อ request ของ History Access เข้ามาเร็วเกินไป
เมธอดที่ Unlimited Endpoint รองรับ
Unlimited Endpoints คือ HTTP endpoint เฉพาะที่ปรับให้เหมาะกับการเรียก Solana RPC มาตรฐานที่มีความหน่วงต่ำ เมธอด Solana RPC มาตรฐานที่รองรับมีดังนี้:
getSlotgetBlockHeightgetLatestBlockhashgetBalancegetAccountInfogetMultipleAccountsgetTransactionsendTransactionsimulateTransactiongetSignatureStatusesgetRecentPrioritizationFeesgetHealthgetVersiongetEpochInfogetBlock
สำหรับเมธอดที่อยู่นอกชุดที่รองรับนี้ ให้ใช้
https://edge.erpc.global?api-key=<YOUR_API_KEY>Solana RPC Methods และ Documentation
สำหรับรายการ methods, parameters และ subscription specifications ทั้งหมด โปรดดูเอกสารทางการ ซึ่งครอบคลุมการใช้งานทั้ง HTTP และ WebSocket.






