Ethereum RPC - Quickstart

Ethereum RPC - Quickstart

Esta guía te lleva de cero a tu primera respuesta Ethereum JSON-RPC con ERPC.

1. Obtén tu API key

Puedes obtener y comprobar tu API key en ERPC Web Dashboard: ERPC Web Dashboard
¿Ya usas ERPC para Solana? Puedes usar la misma RPC key que Solana.

2. Realiza tu primera solicitud

Envía una solicitud JSON-RPC 2.0 como HTTP POST, con tu API key en el parámetro api-key:
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"
}'
La respuesta devuelve el último número de bloque en hexadecimal:
json
{ "jsonrpc": "2.0", "id": 1, "result": "0x..." }
Puedes comprobar qué chain sirve el endpoint con eth_chainId:
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"
}'

3. Suscríbete por WebSocket

El endpoint WebSocket acepta suscripciones eth_subscribe estándar:
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"]}
Para los tipos de suscripción disponibles, consulta la documentación oficial de Ethereum JSON-RPC enlazada abajo.

4. Solicitudes por lotes

Puedes enviar hasta 256 llamadas JSON-RPC en una sola solicitud HTTP. Cada llamada en un lote se mide como una llamada individual.
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"}
]'

Próximos pasos