一、简介
以太坊的交互操作方式有console和JsonRPC,JsonRPC又有IPC、HTTP、WS等方式,例如开启挖矿操作可以有以下方式:
-
Console:
miner.start()
-
IPC:
echo '{"jsonrpc":"2.0","method":"miner_start","params":[],"id":1}' | nc -U $datadir/geth.ipc
-
HTTP:
curl -X POST --data '{"jsonrpc":"2.0","method":"miner_start","params":[],"id":74}' localhost:8545
console交互操作在系列四中已作介绍,在此介绍JsonRPC的交互接口(编写程序时,在代码中可使用RPC接口)
二、JsonRPC接口
详情https://github.com/ethereum/wiki/wiki/JSON-RPC
- JavaScript API
- JSON-RPC Endpoint
- JSON-RPC support
- HEX value encoding
- The default block parameter
- Curl Examples Explained
- JSON-RPC methods
- JSON RPC API Reference