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

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

ERPC को अपने TRON RPC endpoint के रूप में HTTP JSON-RPC requests और TRON HTTP API के लिए इस्तेमाल करें। TRON RPC हमारे Global Edge Blockchain Infrastructure के भीतर ERPC के RPC APIs का हिस्सा है, और API key को ERPC Web Dashboard से मैनेज किया जा सकता है।
आप वही RPC key इस्तेमाल कर सकते हैं जो Solana, Ethereum और Avalanche के लिए इस्तेमाल होती है।
अपनी API key api-key query parameter में दें, या उसे Authorization: Bearer <YOUR_API_KEY> के रूप में भेजें। दोनों मौजूद होने पर query parameter का इस्तेमाल होता है।

Endpoints

JSON-RPC 2.0 requests को HTTP POST के रूप में यहाँ भेजें:
text
https://edge.erpc.global/tron?api-key=<YOUR_API_KEY>
या dedicated host पर:
text
https://tron.erpc.global?api-key=<YOUR_API_KEY>
Dedicated host पर, / और /jsonrpc एक ही JSON-RPC endpoint तक पहुँचते हैं, और TRON HTTP API /wallet/<name> और /walletsolidity/<name> के अंतर्गत serve होता है। edge.erpc.global पर वही paths /tron prefix के साथ आते हैं: /tron, /tron/jsonrpc, /tron/wallet/<name> और /tron/walletsolidity/<name>। TRON HTTP API की POST body एक JSON object होनी चाहिए। अन्य paths का जवाब HTTP 400 से दिया जाता है।

उदाहरण

यह रहा query parameter में API key के साथ एक HTTP request का उदाहरण।
bash
curl 'https://edge.erpc.global/tron?api-key=<YOUR_API_KEY>' --header 'Content-Type: application/json' --data '{
  "jsonrpc":"2.0","id":1,
  "method":"eth_blockNumber"
}'
यह रहा वही request, जिसमें API key Authorization header में है।
bash
curl 'https://edge.erpc.global/tron' --header 'Content-Type: application/json' --header 'Authorization: Bearer <YOUR_API_KEY>' --data '{
  "jsonrpc":"2.0","id":1,
  "method":"eth_blockNumber"
}'
यह रहा एक TRON HTTP API का उदाहरण।
bash
curl 'https://edge.erpc.global/tron/wallet/getnowblock?api-key=<YOUR_API_KEY>' --header 'Content-Type: application/json' --data '{}'
आप अपनी API key ERPC Web Dashboard पर प्राप्त और verify कर सकते हैं: ERPC Web Dashboard

Batch Requests

प्रति HTTP request 1 से 100 calls वाले JSON-RPC batches समर्थित हैं। हर call का अपना id होना चाहिए, और एक batch के भीतर id values दोहराई नहीं जानी चाहिए। batch में हर call को अपने खुद के call के रूप में मीटर किया जाता है। Request body अधिकतम 1 MiB हो सकती है। Batches /jsonrpc पर भेजे जाते हैं। एक TRON HTTP API request एक call ले जाता है और उसे एक call के रूप में मीटर किया जाता है।

उपयोग मीटरिंग

उपयोग को tokens में मीटर किया जाता है, और token दर method के अनुसार अलग हो सकती है। HTTP batch में हर call को अलग-अलग मीटर किया जाता है। हर TRON HTTP API request को एक call के रूप में मीटर किया जाता है।

Free plan की सीमाएँ

Free plan पर, आपका account हर 10 सेकंड में एक request भेज सकता है। यह सीमा endpoint के अनुसार नहीं, बल्कि account के अनुसार गिनी जाती है, इसलिए किसी दूसरी chain को भेजा गया request भी इसमें गिना जा सकता है। इससे जल्दी भेजे गए request का जवाब HTTP 429 से दिया जाता है, और retry-after header प्रतीक्षा का समय सेकंड में बताता है।
Free plan पर, दो या अधिक JSON-RPC calls वाले request का जवाब HTTP 429 से दिया जाता है, और उसकी कोई भी call नहीं भेजी जाती: हर call को code -32041 वाली JSON-RPC error मिलती है। इसके बजाय इन calls को एक-एक करके भेजें।

समर्थित Methods

यह endpoint ये 38 methods serve करता है। eth_*, net_*, और web3_* methods, / या /jsonrpc पर भेजे जाने वाले JSON-RPC calls हैं। /wallet/* और /walletsolidity/* entries TRON HTTP API paths हैं, जिन्हें POST body के रूप में एक JSON object के साथ call किया जाता है।
  • eth_* (19): eth_blockNumber, eth_call, eth_chainId, eth_estimateGas, eth_gasPrice, eth_getBalance, eth_getBlockByHash, eth_getBlockByNumber, eth_getBlockReceipts, eth_getBlockTransactionCountByHash, eth_getBlockTransactionCountByNumber, eth_getCode, eth_getLogs, eth_getStorageAt, eth_getTransactionByBlockHashAndIndex, eth_getTransactionByBlockNumberAndIndex, eth_getTransactionByHash, eth_getTransactionReceipt, eth_syncing
  • net_* (3): net_listening, net_peerCount, net_version
  • web3_* (2): web3_clientVersion, web3_sha3
  • /wallet/* (9): /wallet/broadcasthex, /wallet/broadcasttransaction, /wallet/estimateenergy, /wallet/getaccount, /wallet/getblockbynum, /wallet/getnowblock, /wallet/gettransactionbyid, /wallet/gettransactioninfobyid, /wallet/triggerconstantcontract
  • /walletsolidity/* (5): /walletsolidity/getaccount, /walletsolidity/getblockbynum, /walletsolidity/getnowblock, /walletsolidity/gettransactionbyid, /walletsolidity/gettransactioninfobyid
जो method या path सूची में नहीं है, उसका जवाब HTTP 400 से दिया जाता है।

Response Status Codes

HTTP statusअर्थ
200Upstream JSON-RPC response। JSON-RPC error भी HTTP 200 के साथ लौटाया जाता है: उसमें request का id और error.code बने रहते हैं, उसका error.message ERPC upstream error होता है, और error.data नहीं लौटाया जाता।
400समर्थित Methods सूची से बाहर का method या path, अमान्य JSON-RPC request, खाली batch या 100 से अधिक calls वाला batch, batch में duplicate id, या 1 MiB से बड़ी body।
401API key गुम या अमान्य है, या key पर लगी IP या Origin पाबंदी पूरी नहीं होती।
405POST के अलावा कोई अन्य request method।
426WebSocket Upgrade का अनुरोध किया गया। यह endpoint केवल HTTP पर काम करता है।
429Rate limited, जिसमें ऊपर बताई गई Free plan की सीमाएँ भी शामिल हैं: हर 10 सेकंड में एक से अधिक request, या एक request में दो या अधिक calls। अगर retry-after header मौजूद है, तो उतने seconds प्रतीक्षा करें।
502Upstream request पूरा नहीं हो सका: upstream response विफल रहा, response 8 MiB से बड़ा था, या 30 seconds के भीतर कोई जवाब नहीं मिला। अगर TRON HTTP API response किसी विफलता की सूचना देता है, तो भी 502 लौटाया जाता है।
503Service अस्थायी रूप से अनुपलब्ध है।

TRON RPC Methods और Documentation

Standard methods, parameters और specifications की पूरी सूची के लिए official documentation देखें।