Ethereum JSON-RPC
来源:互联网 发布:矩阵乘法怎么算 编辑:程序博客网 时间:2024/06/07 20:26
1 Ethereum RPC APIs
1) Standard APIs
2) Geth Specific APIs
2 Ethereum RPC
1) HTTP-RPC:手动启动
--rpc--rpcaddr--rpcport--rpcapi--rpccorsdomain2) WS-RPC:手动启动
--ws--wsaddr--wsport--wsapi--wsorigins3) IPC-RPC:自动启动
--ipcdisable--ipcapi--ipcpath
注:出于安全考虑,接口默认开放API子集,通过相应参数可以进行配置。
3 HTTP-RPC 调用实例
# 运行以太坊私有链节点并配置参数
docker run -it -d --name eth-noderpc -p 30303:30303 -p 8545:8545 --net eth-network --ip 172.25.0.10 ethereum:3.0 --rpc --rpcaddr "0.0.0.0" --rpcapi "admin,debug,eth, miner,net,personal,shh,txpool,web3" --nodiscover --networkid 15
注:
--rpc 启用HTTP-RPC服务
--rpcaddr 服务监听接口,默认“localhost”
--rpcapi 配置可使用的api接口,默认“eth, net, web3”
# 调用RPC接口
# 查看账户信息
curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0", "method":"eth_accounts","params":[],"id":67}' 172.25.0.10:8545# 查看账户余额
curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0", "method":"eth_getBalance","params":["0xde1e758511a7c67e7db93d1c23c1060a21db4615","latest"],"id":67}' 172.25.0.10:8545# 查看区块高度
curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0", "method":"eth_blockNumber","params":[],"id":67}' 172.25.0.10:8545# 解锁账户
curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0", "method":"personal_unlockAccount","params":["0xde1e758511a7c67e7db93d1c23c1060a21db4615","password",300],"id":67}' 172.25.0.10:8545# 发送交易
curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params": [{ "from": "0xde1e758511a7c67e7db93d1c23c1060a21db4615", "to": "0xd64a66c28a6ae5150af5e7c34696502793b91ae7", "value": "0x1"}],"id":67}' 172.25.0.10:8545# 查看交易状态
curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0", "method":"miner_start","params":[],"id":67}' 172.25.0.10:8545# 开启挖矿
curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0", "method":"miner_start","params":[],"id":67}' 172.25.0.10:8545# 结束挖矿
curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0", "method":"miner_stop","params":[],"id":67}' 172.25.0.10:8545
4 参考
https://github.com/ethereum/go-ethereum
https://github.com/ethereum/wiki/wiki/JSON-RPC
https://github.com/ethereum/go-ethereum/wiki/Management-APIs
阅读全文
0 0
- Ethereum JSON-RPC
- 以太坊go-ethereum客户端JSON-RPC API调用(一)
- Ethereum JSON-Api 的使用
- RPC-JSON
- json rpc
- JSON json-rpc-c
- JSON-RPC,XML-RPC,SOAP
- JSON RPC Manual Translate
- json-rpc-java
- JSON-RPC-Java (一)
- JSON-RPC-Java 指南
- API reference (JSON-RPC)
- JSON-RPC 1.0 规范
- JSON-RPC for JAVA
- json-rpc-java例子
- json-rpc-for-java
- JSON-RPC说说
- Zabbix JSON-RPC
- 【Scikit-Learn 中文文档】内核近似
- 使用Python和xlwt向Excel文件中写入中文
- Tomcat集群实现Session共享
- 'parent.relativePath' of POM spring.boot.core:
- 机器人控制算法
- Ethereum JSON-RPC
- java json
- 记一次java程序CPU占用过高问题排查
- 【Scikit-Learn 中文文档】成对的矩阵, 类别和核函数
- Android性能优化-过度绘制解决方案
- 良心推荐:Android Studio和IDEA中一个很有用的内存调试插件
- 设计模式
- Python+Selenium3系列教程
- HDOJ1056 HangOver