Skip to content

API : Block & Node

王辰 edited this page Jan 3, 2020 · 5 revisions

<<< Return API Reference

Navigation

Premise

const api = new boxdjs.Api(fetch, <http://xxx>, 'http')

Methods

getCurrentBlockHeight

Get current block height.

Parameters

-

Returns

block-height <number>

Example

const { height } = await api.getCurrentBlockHeight()

getBlockHashByHeight

Get block-hash by block-height.

Parameters

* block-height <number>

Returns

block-hash <string>

Example

const { hash } = await api.getBlockHashByHeight(11001)

viewBlockDetail

View block-detail by (hash | height).

Parameters

* type <'block_hash' | 'block_height'>
* value <string | number>

Returns

block-detail <object>

Example

await api.viewBlockDetail('block_hash', 'd9984d512645a95899a703b8ba962a8d24f1f5efc9206ec652ede9126b0e58c4')
await api.viewBlockDetail('block_height', 11001)

getBlockHeader

Get block-header by (hash | height).

Parameters

* type <'block_hash' | 'block_height'>
* value <string | number>

Returns

block-header <object>

Example

await api.getBlockHeader('block_hash', 'd9984d512645a95899a703b8ba962a8d24f1f5efc9206ec652ede9126b0e58c4')
await api.getBlockHeader('block_height', 11001)

Clone this wiki locally