Class: RestAPI

RestAPI(addressnon-null) → {RestAPI}

new RestAPI(addressnon-null) → {RestAPI}

Creates an instance of RestAPI.
与RepChain网络节点交互的Restful API客户端.
Parameters:
Name Type Description
address string RepChain节点Restful API服务地址
Source:
Returns:
RestAPI对象实例
Type
RestAPI

Methods

block(id, blockFormatopt) → {Promise.<Object>|Promise.<Buffer>}

获取区块数据
Parameters:
Name Type Attributes Default Description
id number | string | Buffer 区块唯一标识,可为区块高度(number)或区块哈希值(base64编码字符串或二进制数据)
blockFormat string <optional>
"JSON" 期望返回的区块数据的格式,可为JSON或STREAM
Source:
Returns:
区块数据
Type
Promise.<Object> | Promise.<Buffer>

chainCurrentBlockHash() → {Promise.<string>}

获取最新区块哈希值
Source:
Returns:
区块哈希值(base64编码字符串)
Type
Promise.<string>

chainCurrentStateHash() → {Promise.<string>}

获取当前的世界状态哈希值
Source:
Returns:
世界状态哈希值(base64编码字符串)
Type
Promise.<string>

chainHeight() → {Promise.<number>}

获取区块链最新区块高度
Source:
Returns:
区块高度
Type
Promise.<number>

chainInfo() → {Promise.<ChainInfo>}

获取区块链的当前概要信息
Source:
Returns:
Json格式信息ChainInfo
Type
Promise.<ChainInfo>

chainPreviousBlockHash() → {Promise.<string>}

获取最新区块的父区块哈希值
Source:
Returns:
最新区块的父区块哈希值(base64编码字符串)
Type
Promise.<string>

chainTotalTransactions() → {Promise.<number>}

获取区块链中的交易总数量
Source:
Returns:
交易总量
Type
Promise.<number>

sendTransaction(tx) → {Promise.<{txid: string}>|Promise.<{err: string}>}

发送签名交易
Parameters:
Name Type Description
tx Buffer | String 待发送的已签名交易数据,支持使用Buffer类型数据或其hex编码的String数据
Source:
Returns:
接收交易后RepChain节点的返回信息
Type
Promise.<{txid: string}> | Promise.<{err: string}>

transaction(id, txFormatopt, withBlockHeightopt) → {Promise.<Object>|Promise.<Buffer>}

获取交易数据
Parameters:
Name Type Attributes Default Description
id string 交易唯一标识,即txid
txFormat string <optional>
"JSON" 期望返回的交易数据的格式
withBlockHeight string <optional>
false 返回交易数据中是否包含区块高度,当txFormat="JSON"时才有效
Source:
Returns:
Type
Promise.<Object> | Promise.<Buffer>

Type Definitions

ChainInfo

区块链的概要信息
Type:
  • Object
Properties:
Name Type Description
height number 最新区块高度
currentBlockHash string 最新区块哈希值(base64编码字符串)
previousBlockHash string 最新区块的父区块哈希值(base64编码字符串)
currentStateHash string 世界状态哈希值(base64编码字符串)
totalTransactions number 交易总量
Source: