GETH Parity Openethereum这几种以太坊钱包命令行交互使用起来都差不多,下面给出几个示例。
其中 method
表示命令,params
表示参数,'Content-Type:application/json'
表示要使用json格式的数据进行交互,-X 'POST'
表示要使用POST方法,最后的地址加端口为钱包的RPC地址和端口。
同步情况
curl --data-binary '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":67}' -H 'Content-Type:application/json' -X 'POST' http://127.0.0.1:15301
区块高度
curl --data-binary '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":67}' -H 'Content-Type:application/json' -X 'POST' http://127.0.0.1:15301
本地交易
curl --data-binary '{"jsonrpc":"2.0","method":"parity_localTransactions","params":[],"id":67}' -H 'Content-Type:application/json' -X 'POST' http://127.0.0.1:15301
取消交易
curl --data-binary '{"jsonrpc":"2.0","method":"parity_removeTransaction","params":["the_tx_id"],"id":67}' -H 'Content-Type:application/json' -X 'POST' http://127.0.0.1:15301
创建账户
curl --data-binary '{"jsonrpc":"2.0","method":"personal_newAccount","params":["the_password"],"id":67}' -H 'Content-Type:application/json' -X 'POST' http://127.0.0.1:15301
解锁账户
curl --data-binary '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["address","the_passwd",null],"id":67}' -H 'Content-Type:application/json' -X 'POST' http://127.0.0.1:15301