Solana RPC endpoint दस्तावेज़ | ERPC

Solana RPC endpoint दस्तावेज़

ERPC को अपने Solana RPC endpoint के रूप में HTTP JSON-RPC requests और WebSocket subscriptions के लिए इस्तेमाल करें। वही Solana endpoint URL standard RPC methods के लिए काम करता है, और API key ERPC Web Dashboard से बनाई और देखी जा सकती है।
कृपया अपनी API key को api-key parameter में जोड़ें।
text
https://edge.erpc.global?api-key=<YOUR_API_KEY>

उदाहरण:

HTTP request का उदाहरण:
bash
curl https://edge.erpc.global?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '{
  "jsonrpc":"2.0","id":1,
  "method":"getBlockHeight"
}'
WebSocket subscription का उदाहरण। Host HTTP जैसा ही है।
text
wss://edge.erpc.global?api-key=<YOUR_API_KEY>
bash
# Example: subscribe to slot updates
wscat -c "wss://edge.erpc.global?api-key=<YOUR_API_KEY>"
# After connected, send:
{"jsonrpc":"2.0","id":1,"method":"slotSubscribe"}
आप अपनी API key ERPC Web Dashboard पर प्राप्त और verify कर सकते हैं: ERPC Web Dashboard
यदि आपको WebSocket से भी कम latency चाहिए, तो Geyser gRPC या ShredStream पर विचार करें। अधिक जानकारी के लिए ERPC Web Dashboard से संपर्क करें।

History Access

पुराने blocks और transactions खोजने के लिए HTTP request के URL edge.erpc.global में history=true जोड़ें; मान ठीक true होना चाहिए, lowercase में। getTransactionsForAddress को छोड़कर, history=true के बिना भेजे गए request का जवाब हर node के पास मौजूद हाल की range से दिया जाता है; यह option इन methods पर लागू होता है:
  • getBlock
  • getBlockTime
  • getBlocks
  • getBlocksWithLimit
  • getTransaction, getParsedTransaction सहित
  • getSignaturesForAddress
  • getSignatureStatuses, जब searchTransactionHistory true हो
  • getTransactionsForAddress, जब transactionDetails "full" हो (History Access ज़रूरी)
API key और option को URL में query parameters के रूप में दें:
text
https://edge.erpc.global?api-key=<YOUR_API_KEY>&history=true
या Authorization: Bearer <YOUR_API_KEY> को header के रूप में भेजें, और option URL में रखें:
text
https://edge.erpc.global?history=true
History Access इस्तेमाल करने वाले HTTP request का उदाहरण:
bash
curl 'https://edge.erpc.global?history=true' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc":"2.0","id":1,
  "method":"getBlock",
  "params":[<SLOT>,{"maxSupportedTransactionVersion":1}]
}'
"full" mode में getTransactionsForAddress को छोड़कर हर method के लिए:
  • History Access से जवाब पाने वाले हर call पर उसकी सामान्य कीमत से 640 tokens अधिक लगते हैं: getBlock में 42 + 640 = 682 लगते हैं।
  • History Access से मिले null, खाली या आंशिक result पर भी अतिरिक्त शुल्क लगता है। असफल खोज पर कोई अतिरिक्त शुल्क नहीं लगता।
  • हाल के data से जवाब पाने वाला call history=true होने पर भी अपनी सामान्य कीमत पर ही रहता है।
  • batch में हर call अलग गिना जाता है; getSignatureStatuses हर call के लिए एक बार गिना जाता है, हर signature के लिए नहीं।
  • हाल के transactions की polling में history=true न लगाएँ: वहाँ हर null पर अतिरिक्त शुल्क लगता है।
Free plan के आवंटन सहित, मुफ़्त आवंटनों की History Access के लिए एक सीमा होती है। Free plan में History Access हर 10 सेकंड में एक request तक सीमित है।
transactionDetails को "full" पर सेट करके getTransactionsForAddress का call History Access है, चाहे transactions हाल के हों या पुराने:
  • इस call के लिए edge.erpc.global URL में history=true ज़रूरी है। इस option के बिना भेजा गया request History Access error (code -32011) के साथ अस्वीकार हो जाता है, और उस पर कोई शुल्क नहीं लगता।
  • history=true के साथ call की कीमत 420 + 640 × N tokens होती है: 420 की सामान्य कीमत, और लाए गए N transactions में से हर एक के लिए 640, चाहे वह हाल का हो या पुराना। जिस row में transaction नहीं है, उसे गिना नहीं जाता।
  • इस call को अलग request के रूप में भेजना होगा। इसे शामिल करने वाला batch history=true के साथ या उसके बिना अस्वीकार हो जाता है: batch के हर call को error -32600 और संदेश This request is not available in a mixed JSON-RPC batch. Please send it as a separate request. के साथ जवाब मिलता है, और उनमें से कोई भी नहीं भेजा जाता।
डिफ़ॉल्ट signatures mode में history=true ज़रूरी नहीं है और कोई अतिरिक्त शुल्क नहीं लगता। किसी address पर नए transactions के लिए polling करनी हो, तो signatures mode इस्तेमाल करें और ज़रूरी transactions getTransaction से लाएँ।
पुराने blocks या transactions की खोज सामान्य request से काफ़ी ज़्यादा समय ले सकती है, कुछ मामलों में सेकंड लग सकते हैं। History Access एक अलग option है, जो इन खोजों को सामान्य requests से अलग रखता है, ताकि सामान्य requests तेज़ बने रहें।
history=true के बिना, किसी पुराने slot के लिए getBlock या getBlockTime request यह error लौटा सकता है:
json
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32011,
    "message": "This request needs history access. Add history=true to the endpoint URL.",
    "data": {
      "erpcCode": "ERPC_HISTORY_OPTION_REQUIRED"
    }
  },
  "id": 1
}
getTransaction, getParsedTransaction और getSignatureStatuses (searchTransactionHistory: true के साथ) उस signature के लिए null लौटाते हैं जो node के पास मौजूद data से पुराना है, जबकि getSignaturesForAddress, getBlocks और getBlocksWithLimit खाली या आंशिक result लौटाते हैं।
history=true वाला request ये messages लौटा सकता है:
  • This plan has reached its limit for history access. Add a paid plan to use tokens for history access. — तब दिखता है जब कोई आवंटन, जैसे Free plan का, अपनी सीमा तक पहुँच जाता है।
  • History access is unavailable while your token balance is low. Add tokens. — paid plan पर तब दिखता है जब tokens का balance कम हो।
  • On the Free plan, history access is limited to one request per 10 seconds. Slow down or use a paid plan. — Free plan पर तब दिखता है जब History Access के requests बहुत तेज़ी से आते हैं।

Solana RPC methods और documentation

Methods, parameters और subscription specifications की पूरी सूची के लिए official documentation देखें। इसमें HTTP और WebSocket दोनों का उपयोग शामिल है।