Common REST Interface

获取区块信息

接口功能

接口说明: 获取区块信息

接口地址

URL: /v1/block/detail

返回格式

JSON

请求方式

POST

请求参数:

参数 必选 类型 默认值 说明
block_num FALSE uint64 块号
block_hash FALSE string 块哈希值

备注:block_num、block_hash 必须二选一,若都缺省,默认查询到的是 0 号块的信息。

响应字段:

参数 类型 说明
errcode uint32 错误码,0-相应成功,其他见错误码章节
msg string 响应描述
result jsonObject 响应结果
block_num uint64 块号
prev_block_hash string 前一块哈希值
block_hash string 当前块哈希值
cursor_block_label uint32 当前块标识
block_time uint64 块生成时间
trx_merkle_root string 默克尔根值,该块打包的所有交易的根哈希值
delegate string 生产者名称
delegate_sign string 生产者签名
trxs jsonArray 当前区块所打包的交易列表,具体见“查询交易信息”章节的响应字段

字段变化

  • 接口示例

地址:http://127.0.0.1:8689/v1/block/detail

  • 请求:
  {
      "block_num": 32,
      "block_hash": "405a6fb8b91a055a7a4cf007451ce0b31ea6626cb2d56ec050b126701fbf093d"
  }
  • 响应:
  HTTP/1.1 200 OK

  {
      "errcode": 0,
      "msg": "success",
      "result": {
          "prev_block_hash": "1b345401d8f859c05e37b5ccacd39ff5b4a21615b63f9b96edb59352a3e54e82",
          "block_num": 32,
          "block_hash": "405a6fb8b91a055a7a4cf007451ce0b31ea6626cb2d56ec050b126701fbf093d",
          "cursor_block_label": 532613437,
          "block_time": 1537259127,
          "trx_merkle_root": "85f9d2fbe1d3c0a217e10932899b6f73b24fafe59a006406ed65d7e4a39a7416",
          "delegate": "bottos",
          "delegate_sign": "41c25998e7d432527f07ae5c10c5c30a4873e9519c29cb02e7f46e3a8e238baf47748efe3f24db3ff3630305441b1d24c5d0ba796b3332a8b8fd3fca4efc4cfb",
          "trxs": [
              {
                  "version": 1,
                  "cursor_num": 31,
                  "cursor_label": 2749714050,
                  "lifetime": 1537259224,
                  "sender": "bottos",
                  "contract": "bottos",
                  "method": "newaccount",
                  "param": {
                      "name": "testtest",
                      "pubkey": "0454f1c2223d553aa6ee53ea1ccea8b7bf78b8ca99f3ff622a3bb3e62dedc712089033d6091d77296547bc071022ca2838c9e86dec29667cf740e5c9e654b6127f"
                  },
                  "sig_alg": 1,
                  "signature": "c85fd25af493cbb6a79870ce0fc602acc892664ca17e2c646aff0332ca6db7787beeb7e5d8553de8e4b83bdf7b227762fedf9e3674888893f18bf31f0b05d622"
              }
          ]
      }
  }

获取区块高度信息

接口功能

接口说明: 获取区块高度信息

接口地址

URL: /v1/block/height

返回格式

JSON

请求方式

GET

请求参数:

参数 必选 类型 默认值 说明

响应字段:

参数 类型 说明
errcode uint32 错误码,0-相应成功,其他见错误码章节
msg string 响应描述
result jsonObject 响应结果
head_block_num uint64 块号
head_block_hash string 前一块哈希值
head_block_time uint64 块生成时间
head_block_delegate string 块生产者
cursor_label uint32 块标识
last_consensus_block_num uint32 不可逆块号
chain_id string 链ID,同一链的所有节点的Chain_id必须相同

字段变化

  • 接口示例

地址:http://127.0.0.1:8689/v1/block/height

  • 请求:
  • 响应:
  HTTP/1.1 200 OK
  {
      "errcode": 0,
      "msg": "",
      "result": {
          "head_block_num": 87,
          "head_block_hash": "b34806eefc77b88743ab447f43658bf229fd4e5cd9452340e21f3995a5d2054b",
          "head_block_time": 1534213225,
          "head_block_delegate": "alsephina",
          "cursor_label": 2782004555,
          "last_consensus_block_num": 64,
          "chain_id": "4b97b92d2c78bcffe95ebd3067565c73a2931b39d5eb7234b11816dcec54761a"
      }
  }

发送交易信息

接口功能

接口说明: 发送交易信息

接口地址

URL: /v1/transaction/send

返回格式

JSON

请求方式

POST

请求参数:

参数 必选 类型 默认值 说明
version TRUE uint32 1 链版本号
cursor_num TRUE uint64 最新区块号,调用获取区块头获得
cursor_label TRUE uint32 最新区块标识,调用获取区块头获得
lifetime TRUE uint64 交易过期时间,调用获取区块头,加一定的延时,推荐延时100秒
sender TRUE string 发送者
contract TRUE string 合约名称
method TRUE string 合约方法
param TRUE string 业务参数,十六进制字符串
sig_alg TRUE uint32 1 签名算法
signature TRUE string 签名值

响应字段:

参数 类型 说明
errcode uint32 错误码,0-相应成功,其他见错误码章节
msg string 响应描述
result jsonObject 响应结果
trx_hash string 交易哈希值
trx jsonObject 交易详情
version uint32 链版本号
cursor_num uint64 最新区块号,调用获取区块头获得
cursor_label uint32 最新区块标签,调用获取区块头获得
lifetime uint64 交易过期时间,调用获取区块头,加一定的延时
sender string 发送者
contract string 合约名称
method string 合约方法
param string 业务参数,十六进制字符串
sig_alg uint32 签名算法
signature string 签名值

字段变化

  • 接口示例

地址:http://127.0.0.1:8689/v1/transaction/send

  • 请求:
  {
      "version": 1,
      "cursor_num": 719,
      "cursor_label": 2997806499,
      "lifetime": 1534143531,
      "sender": "bottos",
      "contract": "bottos",
      "method": "newaccount",
      "param": "dc0002da0009757365727465737431da008230346430373538383030353634383861393864613365643234623766613265633061623864383464343764623534366333663138316137363462613366613165383237396637363434303963343164653031623030383065623161616565623935303966373932333535323061373565333432343432393134346234336331303462",
      "sig_alg": 1,
      "signature": "f0069bc363a55dc22207c75d15cc75524bf4950159130c6bf385f6f1ca877177362ad5ab51108e7f396043e3aee7058f1ca6a40fd6c79a8483e439d2e2bccf2c"
  }
  • 响应:
  HTTP/1.1 200 OK
  {
      "errcode": 0,
      "msg": "trx receive succ",
      "result": {
          "trx": {
              "version": 1,
              "cursor_num": 719,
              "cursor_label": 2997806499,
              "lifetime": 1534143531,
              "sender": "delta",
              "contract": "bottos",
              "method": "newaccount",
              "param": "dc0002da0009757365727465737431da008230346430373538383030353634383861393864613365643234623766613265633061623864383464343764623534366333663138316137363462613366613165383237396637363434303963343164653031623030383065623161616565623935303966373932333535323061373565333432343432393134346234336331303462",
              "sig_alg": 1,
              "signature": "f0069bc363a55dc22207c75d15cc75524bf4950159130c6bf385f6f1ca877177362ad5ab51108e7f396043e3aee7058f1ca6a40fd6c79a8483e439d2e2bccf2c"
          },
          "trx_hash": "1815f4d4dfb52b88fb445efc255a5be6275fc3ad694f802c01c40644f09b651f"
      }
  }

查询交易信息

接口功能

接口说明: 查询交易信息

接口地址

URL: /v1/transaction/get

返回格式

JSON

请求方式

POST

请求参数:

参数 必选 类型 默认值 说明
trx_hash TRUE string 交易哈希值

响应字段:

参数 类型 说明
errcode uint32 错误码,0-相应成功,其他见错误码章节
msg string 响应描述
result jsonObject 响应结果
version uint32 链版本号
cursor_num uint64 最新区块号,调用获取区块头获得
cursor_lab uint32 最新区块标签,调用获取区块头获得
lifetime uint64 交易过期时间,调用获取区块头,加一定的延时
sender string 发送者
contract string 合约名称
method string 合约方法
param jsonObject 业务参数
sig_alg uint32 签名算法
signature string 签名值

字段变化

  • 接口示例

地址:http://127.0.0.1:8689/v1/transaction/get

  • 请求:
  {
      "trx_hash": "85f9d2fbe1d3c0a217e10932899b6f73b24fafe59a006406ed65d7e4a39a7416"
  }
  • 响应:
   HTTP/1.1 200 OK
  {
      "errcode": 0,
      "msg": "success",
      "result": {
          "version": 1,
          "cursor_num": 31,
          "cursor_label": 2749714050,
          "lifetime": 1537259224,
          "sender": "bottos",
          "contract": "bottos",
          "method": "newaccount",
          "param": {
              "name": "testtest",
              "pubkey": "0454f1c2223d553aa6ee53ea1ccea8b7bf78b8ca99f3ff622a3bb3e62dedc712089033d6091d77296547bc071022ca2838c9e86dec29667cf740e5c9e654b6127f"
          },
          "sig_alg": 1,
          "signature": "c85fd25af493cbb6a79870ce0fc602acc892664ca17e2c646aff0332ca6db7787beeb7e5d8553de8e4b83bdf7b227762fedf9e3674888893f18bf31f0b05d622"
      }
  }

根据关键字查询数据

接口功能

接口说明: 根据关键字查询数据

接口地址

URL: /v1/common/query

返回格式

JSON

请求方式

POST

请求参数:

参数 必选 类型 默认值 说明
contract TRUE string 合约名称
object TRUE string 合约表名
key TRUE string 查询关键字

响应字段:

参数 类型 说明
errcode uint32 错误码,0-相应成功,其他见错误码章节
msg string 响应描述
result jsonObject 响应结果
contract string 合约名称
object string 合约表名
key string 查询关键字
value uint32 查询到的值

字段变化

  • 接口示例

地址:http://127.0.0.1:8689/v1/common/query

  • 请求:
  {
      "contract":"bottostoken",
      "object":"DTO",
      "key":"aaa"
  }
  • 响应:
   HTTP/1.1 200 OK
  {
    "errcode": 0,
    "msg": "",
    "result": {
          "contract": "bottostoken",
          "object": "DTO",
          "key": "aaa",
          "value": "dc0001cf000000ba43b74000"
    }
  }

序列化业务数据

接口功能

接口说明: 序列化业务数据,json 转为 十六进制字符串,作为“发送交易信息”请求中的parm 字段值。

接口地址

URL: /v1/common/jsontobin

返回格式

JSON

请求方式

POST

请求参数:

参数 必选 类型 默认值 说明
contract TRUE string 合约名称
object TRUE string 合约表名
key TRUE string 查询关键字

响应字段:

参数 类型 说明
errcode uint32 错误码,0-相应成功,其他见错误码章节
msg string 响应描述
result jsonObject 响应结果
contract string 合约名称
object string 合约表名
key string 查询关键字
value uint32 查询到的值

字段变化

  • 接口示例

地址:<http://127.0.0.1:8689/v1/common/jsontobin

  • 请求:
  {
      "account_name": "testtest",
      "public_key": "0454f1c2223d553aa6ee53ea1ccea8b7bf78b8ca99f3ff622a3bb3e62dedc712089033d6091d77296547bc071022ca2838c9e86dec29667cf740e5c9e654b6127f"
  }
  • 响应:
   HTTP/1.1 200 OK
  {
    "errcode": 0,
    "msg": "",
    "result": {
          "contract": "bottostoken",
          "object": "DTO",
          "key": "aaa",
          "value": "dc0001cf000000ba43b74000"
    }
  }

查询账户信息**

接口功能

接口说明: 查询账户信息

接口地址

URL: /v1/account/info

返回格式

JSON

请求方式

POST

请求参数:

参数 必选 类型 默认值 说明
account_name TRUE string 账户名称

响应字段:

参数 类型 说明
errcode uint32 错误码,0-相应成功,其他见错误码章节
msg string 响应描述
result jsonObject 响应结果
account_name string 账号名称
pubkey string 公钥
balance string Token值,
staked_balance string 质押的Token值
unStaking_balance string 正解质押的Token值
unStaking_time uint64 解质押的时间( Unix时间戳 )

备注:balance、staked_balance、unStaking_balance 三者之和为改账户总的Token值 。

字段变化

  • 接口示例

地址:http://127.0.0.1:8689/v1/account/info

  • 请求:
  {
      "account_name":"delta"
  }
  • 响应:
   HTTP/1.1 200 OK
  {
      "errcode": 0,
      "msg": "success",
      "result": {
          "account_name": "testtest",
          "pubkey": "0454f1c2223d553aa6ee53ea1ccea8b7bf78b8ca99f3ff622a3bb3e62dedc712089033d6091d77296547bc071022ca2838c9e86dec29667cf740e5c9e654b6127f",
          "balance": "0",
          "staked_balance": "0",
          "unStaking_balance": "0",
          "unStaking_time": 0
      }
  }

查询合约ABI

接口功能

接口说明: 查询合约ABI

接口地址

URL: /v1/contract/abi

返回格式

JSON

请求方式

POST

请求参数:

参数 必选 类型 默认值 说明
contract TRUE string 合约名称

响应字段:

参数 类型 说明
errcode uint32 错误码,0-相应成功,其他见错误码章节
msg string 响应描述
result jsonObject 响应结果
types jsonObject 预留字段
structs jsonArray 合约所包含的方法结构列表
name string 结构体名,一般为自定义的合约方法名别名
base string 父方法,通常为空
fields jsonObject 方法入参结构体
name string 参数-1,以注册账号为例:账号名称
pubkey string 参数-2,以注册账号为例:公钥
actions jsonArray 合约所包含的方法
action_name string 合约方法名称,对应“发送交易信息”请求参数的method值
type string 同name,结构体名,一般为自定义的合约方法名别名
tables jsonArray 该合约数据的存储方式,定义表名,类型,Key值,类型,Value 类型。内置合约该字段为空。
table_name string 合约存储的表名
index_type string 索引类型,默认为string。
key_names jsonArray 合约数据存储的Key值
key_types jsonArray key值的类型,默认为string
type string 合约数据key对应的value值,通常为 结构体

字段变化

  • 接口示例

地址:<http://127.0.0.1:8689/v1/contract/abi >

  • 请求:
  {
      "contract":"bottos"
  }
  • 响应:
   HTTP/1.1 200 OK
  {
      "errcode": 0,
      "msg": "success",
      "result": {
          "actions": [
              {
                  "action_name": "newaccount",
                  "type": "NewAccount"
              },
              {
                  "action_name": "transfer",
                  "type": "Transfer"
              },
              {
                  "action_name": "grantcredit",
                  "type": "GrantCredit"
              },
              {
                  "action_name": "cancelcredit",
                  "type": "CancelCredit"
              },
              {
                  "action_name": "transferfrom",
                  "type": "TransferFrom"
              },
              {
                  "action_name": "deploycode",
                  "type": "DeployCode"
              },
              {
                  "action_name": "deployabi",
                  "type": "DeployABI"
              },
              {
                  "action_name": "regdelegate",
                  "type": "RegDelegate"
              },
              {
                  "action_name": "unregdelegate",
                  "type": "UnregDelegate"
              },
              {
                  "action_name": "votedelegate",
                  "type": "VoteDelegate"
              },
              {
                  "action_name": "stake",
                  "type": "Stake"
              },
              {
                  "action_name": "unstake",
                  "type": "Unstake"
              },
              {
                  "action_name": "claim",
                  "type": "Claim"
              },
              {
                  "action_name": "setdelegate",
                  "type": "SetDelegate"
              },
              {
                  "action_name": "blkprodtrans",
                  "type": "BlkProdTrans"
              }
          ],
          "structs": [
              {
                  "base": "",
                  "fields": {
                      "name": "string",
                      "pubkey": "string"
                  },
                  "name": "NewAccount"
              },
              {
                  "base": "",
                  "fields": {
                      "from": "string",
                      "to": "string",
                      "value": "uint256"
                  },
                  "name": "Transfer"
              },
              {
                  "base": "",
                  "fields": {
                      "description": "string",
                      "location": "string",
                      "name": "string",
                      "pubkey": "string"
                  },
                  "name": "SetDelegate"
              },
              {
                  "base": "",
                  "fields": {
                      "limit": "uint256",
                      "name": "string",
                      "spender": "string"
                  },
                  "name": "GrantCredit"
              },
              {
                  "base": "",
                  "fields": {
                      "name": "string",
                      "spender": "string"
                  },
                  "name": "CancelCredit"
              },
              {
                  "base": "",
                  "fields": {
                      "from": "string",
                      "to": "string",
                      "value": "uint256"
                  },
                  "name": "TransferFrom"
              },
              {
                  "base": "",
                  "fields": {
                      "contract": "string",
                      "contract_code": "bytes",
                      "vm_type": "uint8",
                      "vm_version": "uint8"
                  },
                  "name": "DeployCode"
              },
              {
                  "base": "",
                  "fields": {
                      "contract": "string",
                      "contract_abi": "bytes"
                  },
                  "name": "DeployABI"
              },
              {
                  "base": "",
                  "fields": {
                      "description": "string",
                      "location": "string",
                      "name": "string",
                      "pubkey": "string"
                  },
                  "name": "RegDelegate"
              },
              {
                  "base": "",
                  "fields": {
                      "name": "string"
                  },
                  "name": "UnregDelegate"
              },
              {
                  "base": "",
                  "fields": {
                      "delegate": "string",
                      "voteop": "uint8",
                      "voter": "string"
                  },
                  "name": "VoteDelegate"
              },
              {
                  "base": "",
                  "fields": {
                      "amount": "uint256"
                  },
                  "name": "Stake"
              },
              {
                  "base": "",
                  "fields": {
                      "amount": "uint256"
                  },
                  "name": "Unstake"
              },
              {
                  "base": "",
                  "fields": {
                      "amount": "uint256"
                  },
                  "name": "Claim"
              },
              {
                  "base": "",
                  "fields": {
                      "actblknum": "uint64"
                  },
                  "name": "BlkProdTrans"
              }
          ],
          "tables": null,
          "types": null
      }
  }

查询合约代码

接口功能

接口说明: 查询合约代码

接口地址

URL: /v1/contract/code

返回格式

JSON

请求方式

POST

请求参数:

参数 必选 类型 默认值 说明
contract TRUE string 合约名称

响应字段:

参数 类型 说明
errcode uint32 错误码,0-相应成功,其他见错误码章节
msg string 响应描述
result jsonObject 响应结果

字段变化

  • 接口示例

地址:<http://127.0.0.1:8689/v1/contract/code >

  • 请求:
  {
      "contract":"usermng"
  }
  • 响应:
   HTTP/1.1 200 OK
  {
      "errcode": 0,
      "msg": "",
      "result": "7b0a2020227479706573223a205b5d2c0a20202273747275637473223a205b7b0a202020202020226e616d65223a202255736572496e666f222c0a2020202020202262617365223a2022222c0a202020202020226669656c6473223a207b0a20202020202020202020226469646964223a2022737472696e67222c0a2020202020202020202022696e666f223a2022737472696e67220a20202020202020207d0a202020207d2c7b0a202020202020226e616d65223a2022557365724c6f67696e222c0a2020202020202262617365223a2022222c0a202020202020226669656c6473223a207b0a2020202020202020202022757365724e616d65223a2022737472696e67222c0a202020202020202020202272616e646f6d4e756d223a202275696e743332220a20202020202020207d0a202020207d2c7b0a202020202020226e616d65223a20225573657242617365496e666f222c0a2020202020202262617365223a2022222c0a202020202020226669656c6473223a207b0a2020202020202020202022696e666f223a2022737472696e67220a20202020202020207d0a202020207d0a20205d2c0a202022616374696f6e73223a205b7b0a20202020202022616374696f6e5f6e616d65223a202272656775736572222c0a2020202020202274797065223a202255736572496e666f220a202020207d2c7b0a20202020202022616374696f6e5f6e616d65223a2022757365726c6f67696e222c0a2020202020202274797065223a2022557365724c6f67696e220a202020207d0a20205d2c0a2020227461626c6573223a205b7b0a202020202020227461626c655f6e616d65223a202275736572726567696e666f222c0a20202020202022696e6465785f74797065223a2022737472696e67222c0a202020202020226b65795f6e616d6573223a205b0a2020202020202020226469646964220a2020202020205d2c0a202020202020226b65795f7479706573223a205b0a202020202020202022737472696e67220a2020202020205d2c0a2020202020202274797065223a20225573657242617365496e666f220a202020207d0a20205d0a7d0a"
  }

查询所有生产者

接口功能

接口说明: 查询所有生产者

接口地址

URL: /v1/delegate/getall

返回格式

JSON

请求方式

POST

请求参数:

参数 必选 类型 默认值 说明
limit TRUE uint32 查询条数
start TRUE uint32 0 查询起始下标

响应字段:

参数 类型 说明
errcode uint32 错误码,0-相应成功,其他见错误码章节
msg string 响应描述
result jsonArray 响应结果
account_name string 账号名称
public_key string 公钥
location string 节点地理位置信息,如"shanghai,china"
desc string 节点描述信息

字段变化

  • 接口示例

地址:<http://127.0.0.1:8689/v1/delegate/getall >

  • 请求:
  {
      "limit": 10,
      "start": 0
  }
  • 响应:
   HTTP/1.1 200 OK
  {
      "errcode": 0,
      "msg": "success",
      "result":  [
          {
              "account_name": "adhil",
              "report_key": "0454f1c2223d553aa6ee53ea1ccea8b7bf78b8ca99f3ff622a3bb3e62dedc712089033d6091d77296547bc071022ca2838c9e86dec29667cf740e5c9e654b6127f",
              "location": "shanghai,china",
              "desc": "",
              "last_slot": 1029945,
              "total_missed": 0,
              "last_confirmed_block_num": 32,
              "active": true
          },
          {
              "account_name": "albireo",
              "report_key": "0454f1c2223d553aa6ee53ea1ccea8b7bf78b8ca99f3ff622a3bb3e62dedc712089033d6091d77296547bc071022ca2838c9e86dec29667cf740e5c9e654b6127f",
              "location": "",
              "desc": "",
              "last_slot": 1026356,
              "total_missed": 123,
              "last_confirmed_block_num": 10,
              "active": false
          }
      ]
  }

results matching ""

    No results matching ""