ERPC Ethereum RPC クイックスタート
Ethereum RPC クイックスタート
このガイドでは、ゼロの状態から ERPC で最初の Ethereum JSON-RPC レスポンスを受け取るまでの手順を解説します。
1. API key を取得する
API key は ERPC Web Dashboard 上にて取得、確認いただけます: ERPC Web Dashboard
すでに ERPC を Solana で利用中ですか?Solana と同じ RPC キーを利用できます。
2. 最初のリクエストを送信する
api-key パラメータに API key を指定し、JSON-RPC 2.0 リクエストを HTTP POST で送信します。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"
}'レスポンスには最新のブロック番号が 16 進数で返されます。
json
{ "jsonrpc": "2.0", "id": 1, "result": "0x..." }{ "jsonrpc": "2.0", "id": 1, "result": "0x..." }エンドポイントがどのチェーンを提供しているかは
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"
}'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. WebSocket で購読する
WebSocket エンドポイントは標準の
eth_subscribe 購読に対応しています。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"]}利用可能な購読タイプについては、下記リンク先の公式 Ethereum JSON-RPC ドキュメントをご参照ください。
4. バッチリクエスト
1 回の HTTP リクエストで最大 256 件の JSON-RPC 呼び出しをまとめて送信できます。バッチ内の各呼び出しは、それぞれ個別の呼び出しとして計測されます。
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"}
]'次のステップ
- エンドポイント、計測、ステータスコード: Ethereum RPC エンドポイント ドキュメント
- リクエストとレスポンスの形式を含む全メソッド一覧: Ethereum RPC API リファレンス
- 公式 Ethereum JSON-RPC ドキュメント: https://ethereum.org/en/developers/docs/apis/json-rpc/






