JSON-RPC API
JSON - Remote Procedure Call API
이더리움 클라이언트는 JSON-RPC를 제공한다.
요청의 구성요소
- port: 8545
- proto: http
body는 json 형식으로 되어있다.
- body
{
"jsonrpc": "2.0", // JSON-RPC 프로토콜의 버전
"method": "web3_clientVersion", // 호출할 메서드 명
"params":[], // 메서드 호출에 사용할 파라미터
"id": 1
}
Example
# client의 version을 묻는 요청
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "method": "web3_clientVersion", "params":[], "id": 1}' http://localhost:8545
# client version
{"jsonrpc":"2.0","id":1,"result":"Geth/v1.16.7-stable/darwin-arm64/go1.25.3"}
# gas 가격을 묻는 요청
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "method": "eth_gasPrice", "params":[], "id": 1}' http://localhost:8545
# gas price
{"jsonrpc":"2.0","id":1,"result":"0x3baa0c40"}