Avalanche RPC क्विकस्टार्ट | ERPC
Avalanche RPC क्विकस्टार्ट
यह गाइड आपको ERPC के साथ शून्य से आपकी पहली Avalanche JSON-RPC प्रतिक्रिया तक ले जाता है।
1. अपनी API key प्राप्त करें
आप अपनी API key ERPC Web Dashboard पर प्राप्त और verify कर सकते हैं: ERPC Web Dashboard
क्या आप पहले से Solana या Ethereum के लिए ERPC इस्तेमाल कर रहे हैं? आप वही RPC key इस्तेमाल कर सकते हैं।
2. अपना पहला Request भेजें
अपनी API key
api-key parameter में देकर, JSON-RPC 2.0 request को HTTP POST के रूप में भेजें:bash
curl https://edge.erpc.global/ava?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '{
"jsonrpc":"2.0","id":1,
"method":"eth_blockNumber"
}'curl https://edge.erpc.global/ava?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '{
"jsonrpc":"2.0","id":1,
"method":"eth_blockNumber"
}'Response में नवीनतम C-Chain block number hexadecimal में मिलता है:
json
{ "jsonrpc": "2.0", "id": 1, "result": "0x..." }{ "jsonrpc": "2.0", "id": 1, "result": "0x..." }आप
eth_chainId से यह जांच सकते हैं कि endpoint किस chain को serve करता है। परिणाम है 0xa86a — यानी 43114, Avalanche C-Chain mainnet की chain ID:bash
curl https://edge.erpc.global/ava?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '{
"jsonrpc":"2.0","id":1,
"method":"eth_chainId"
}'curl https://edge.erpc.global/ava?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '{
"jsonrpc":"2.0","id":1,
"method":"eth_chainId"
}'यही endpoint Avalanche के native APIs भी serve करता है। upstream API का चुनाव सटीक method नाम के आधार पर होता है, इसलिए X-Chain (
avm.*) और P-Chain (platform.*) की calls को किसी अतिरिक्त path या host की जरूरत नहीं होती:bash
curl https://edge.erpc.global/ava?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '{
"jsonrpc":"2.0","id":1,
"method":"platform.getHeight",
"params":{}
}'curl https://edge.erpc.global/ava?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '{
"jsonrpc":"2.0","id":1,
"method":"platform.getHeight",
"params":{}
}'3. WebSocket पर Subscribe करें
WebSocket endpoint C-Chain की मानक
eth_subscribe subscriptions स्वीकार करता है:bash
wscat -c "wss://edge.erpc.global/ava?api-key=<YOUR_API_KEY>"
# After connected, send:
{"jsonrpc":"2.0","id":1,"method":"eth_subscribe","params":["newHeads"]}wscat -c "wss://edge.erpc.global/ava?api-key=<YOUR_API_KEY>"
# After connected, send:
{"jsonrpc":"2.0","id":1,"method":"eth_subscribe","params":["newHeads"]}उपलब्ध subscription types के लिए, नीचे लिंक की गई आधिकारिक Avalanche C-Chain documentation देखें।
4. Batch Requests
आप एक ही HTTP request में C-Chain के EVM methods के लिए 256 तक JSON-RPC calls भेज सकते हैं। batch में हर call को अपने खुद के call के रूप में मीटर किया जाता है।
bash
curl https://edge.erpc.global/ava?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '[
{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber"},
{"jsonrpc":"2.0","id":2,"method":"eth_gasPrice"}
]'curl https://edge.erpc.global/ava?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '[
{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber"},
{"jsonrpc":"2.0","id":2,"method":"eth_gasPrice"}
]'अगले चरण
- Endpoints, मीटरिंग और status codes: Avalanche RPC Endpoint दस्तावेज़
- Request और response shapes के साथ पूरी method सूची: Avalanche RPC API संदर्भ
- आधिकारिक Avalanche C-Chain documentation: https://build.avax.network/docs/rpcs/c-chain






