Back

blockchain - 根据json rpc 获得链上信息

发布时间: 2022-02-11 09:29:00

1

打开接口列表:https://eth.wiki/json-rpc/API

记得请求的时候,需要header中包含  Content-Type: 'application/json'

完整的 curl 命令:

curl -H 'Content-Type: application/json' -X POST https://moonriver.api.onfinality.io/rpc?apikey=8e195da1-d4e2-4ded-a8fb-a8ef8b642763 --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x166c1c",true],"id":1}'

下面是方法列表

获得最新的block height:

根据block 获得所有的hash

使用eth_getTransactionReceipt 获知某tx是否是创建新的contract

一个普通的主链币 转账:

获得event

{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0x407dfc76f9a13f7fa06a0706dbc9f052c205153c4ac26f55e985c0078a78c344"],"id":1}

Back