区块相关 API


getinfo

获取节点相关信息

Parameters * none

Returns

version 节点版本号

protocol_version 协议版本号

net_type 节点运行的网络环境类型

proxy 节点代理地址:端口

ext_ip 节点所在的外网IP地址

conf_dir 配置文件的目录路径

data_dir 区块数据的目录路径

block_interval 出块时间间隔

genblock 是否生产区块

time_offset 当前节点时间偏移量,单位s

wallet_balance 钱包余额

miner_fee_perkb 出块节点的出块交易费用/KB的阈值

relay_fee_perkb 中继交易的费用/KB的阈值

tipblock_fuel_rate 节点中最新区块的燃料费率

tipblock_fuel 节点中最新区块的燃料费

tipblock_time 节点中最新区块的出块时间戳

tipblock_hash 节点中最新区块的哈希值

tipblock_height 节点中最新区块的高度

synblock_height 全网最新区块高度

connections 节点与外部节点的连接数

errors 警告信息提示

Example

// Request
curl -u Waykichain:admin -d '{"jsonrpc":"2.0","id":"curltext","method":"getinfo","params":[]}' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "version" : "v2.0.0.0-1f5ae3e8-release-linux (2019-10-09 18:05:12 +0800)",
        "protocol_version" : 10001,
        "net_type" : "TEST_NET",
        "proxy" : "",
        "ext_ip" : "112.74.162.212",
        "conf_dir" : "/root/.WaykiChain/WaykiChain.conf",
        "data_dir" : "/root/.WaykiChain/testnet",
        "block_interval" : 3,
        "genblock" : 1,
        "time_offset" : 0,
        "wallet_balance" : 0.31810114,
        "miner_fee_perkb" : 0.00010000,
        "relay_fee_perkb" : 0.00001000,
        "tipblock_fuel_rate" : 1,
        "tipblock_fuel" : 0,
        "tipblock_time" : 1570777029,
        "tipblock_hash" : "63bc4c0ce013ca9a6236b750c01e8aaff8be302593894b94b68fad52cd53ed82",
        "tipblock_height" : 77486,
        "synblock_height" : 77486,
        "connections" : 6,
        "errors" : "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues."
    },
    "error": null,
    "id": "curltext"
}

getblockcount

获取当前节点区块高度

Parameters

none

Returns

result 当前区块高度

Example

// Request
curl -u Waykichain:admin -d '{"jsonrpc":"2.0","id":"curltext","method":"getblockcount","params":[]}' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": 38378,
    "error": null,
    "id": "curltext"
}

getblock

根据区块高度/区块哈希获取区块信息

Parameters

height/hash 区块高度/区块哈希

Returns

block_hash 区块哈希值

confirmations 区块确认数 = 当前链上区块高度 - 本区块高度

size 区块大小,单位是byte

height 本区块的高度

version 区块版本

merkle_root 梅克尔树的根哈希值

tx_count 区块在包含的交易数量

tx 交易哈希列表

time 区块生成的时间戳

nonce 随机数

previous_block_hash 父区块的哈希值

next_block_hash 下一个区块的哈希值

median_price 币价中位数列表,用于稳定币系统喂价

`coin_symbol` 币种符号
`price_symbol` 对标法币
`price` 币价

Example

// Request
curl -u Waykichain:admin -d '{"jsonrpc": "1.0", "id":"curltest", "method": "getblock", "params": [1000] }' -H 'content-type:application/json;' http://127.0.0.1:6967

// Response
{
    "result": {
        "block_hash": "c2f37c7c93b031f3eb1555e95b1ce91d55c8cbeba3f2dfcb3a331da11d8285bb",
        "confirmations": 37675,
        "size": 281,
        "height": 1000,
        "version": 1,
        "merkle_root": "1181c6d387754d6608da8acc9cf9cb64832f5b1e431689194d3ff952f065d8ac",
        "tx_count": 4,
        "tx": [
            "e101bbbc06e908279f38d23fa9653fa8bac81f7fa86517e9fc426aeff30ac218",
            "960a9689ebe8484e4d8d79a5a2346d5aea4bdd7ec80f264a09ae3ba9a21e2e90",
            "3f04e5127689bcce8f89d724e504c091955c6f02961769e8d5e3591e2790cfb2",
            "5c60c3514cf7a6c706ca7a254e42533bd8b425b671bbe489c1758be3317c2023"
        ],
        "time": 1567522605,
        "nonce": 399,
        "previous_block_hash": "c2b488e4d8b2e4d1e5ebb11c3fea935834bf798375c0bc622de186d80a2b82ef",
        "next_block_hash": "7c752a743c1c9cdaaec1b85e43d19b339e1655b0074f2aa26b7a107aa997a152",
        "median_price": []
    },
    "error": null,
    "id": "curltest"
}