参考这篇博客:JSON-RPC是什么
$ curl -X POST -H "Content-Type:application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' http://localhost:8545
将会从服务器端接收到如下结果(需要在我们的geth客户端启动时加上–rpc,默认打开的时8545端口):
{"jsonrpc":"2.0","id":1,"result":"Geth/v1.9.21-unstable-5883afb3-20200828/linux-amd64/go1.15"}
相当于geth version返回的结果。
再比如
$ curl -X POST -H "Content-Type:application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://localhost:8545
返回结果:
{"jsonrpc":"2.0","id":1,"result":"0x2af"}
0x2af是16进制的687,相当于在geth控制台执行命令:eth.blockNumber。