Ethereum RPC - Snelstart
Ethereum RPC - Snelstart
Deze handleiding leidt u van nul naar uw eerste Ethereum JSON-RPC-respons met ERPC.
1. Uw API key verkrijgen
U kunt uw API key verkrijgen en controleren in het ERPC Web Dashboard: ERPC Web Dashboard
Gebruikt u ERPC al voor Solana? U kunt dezelfde RPC key als Solana gebruiken.
2. Uw eerste verzoek doen
Verstuur een JSON-RPC 2.0-verzoek als HTTP POST, met uw API key in de
api-key-parameter:bash
curl https://edge.erpc.global/eth?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '{
"jsonrpc":"2.0","id":1,
"method":"eth_blockNumber"
}'curl https://edge.erpc.global/eth?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '{
"jsonrpc":"2.0","id":1,
"method":"eth_blockNumber"
}'Het antwoord retourneert het laatste bloknummer in hexadecimaal:
json
{ "jsonrpc": "2.0", "id": 1, "result": "0x..." }{ "jsonrpc": "2.0", "id": 1, "result": "0x..." }Met
eth_chainId kunt u controleren welke chain het endpoint bedient:bash
curl https://edge.erpc.global/eth?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '{
"jsonrpc":"2.0","id":1,
"method":"eth_chainId"
}'curl https://edge.erpc.global/eth?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '{
"jsonrpc":"2.0","id":1,
"method":"eth_chainId"
}'3. Abonneren via WebSocket
Het WebSocket-endpoint accepteert standaard
eth_subscribe-abonnementen:bash
wscat -c "wss://edge.erpc.global/eth?api-key=<YOUR_API_KEY>"
# After connected, send:
{"jsonrpc":"2.0","id":1,"method":"eth_subscribe","params":["newHeads"]}wscat -c "wss://edge.erpc.global/eth?api-key=<YOUR_API_KEY>"
# After connected, send:
{"jsonrpc":"2.0","id":1,"method":"eth_subscribe","params":["newHeads"]}Voor de beschikbare abonnementstypen verwijzen wij u naar de hieronder gelinkte officiële Ethereum JSON-RPC-documentatie.
4. Batch-verzoeken
U kunt tot 256 JSON-RPC-aanroepen in één HTTP-verzoek versturen. Elke aanroep in een batch wordt gemeten als een eigen aanroep.
bash
curl https://edge.erpc.global/eth?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/eth?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"}
]'Volgende stappen
- Endpoints, metering en statuscodes: Ethereum RPC endpoint documentatie
- Volledige methodelijst met verzoek- en antwoordstructuren: Ethereum RPC API-referentie
- Officiële Ethereum JSON-RPC-documentatie: https://ethereum.org/en/developers/docs/apis/json-rpc/






