Skip to content
Gung De Surya edited this page Jul 8, 2020 · 3 revisions

Block

Block.getBlockById()

Get the detail information about the specific block by passing its ID. The block can containing some transaction or just an empty block. Also you can see some information like who created the block and the fee they got.

Typescript

zoobc.Block.getBlockById(blockId);

Parameters

  1. blockId

Return
return Promise<BlockResponse>

Example

zoobc.Block.getBlockById("7339302356952867200").then((block: BlockResponse) => {
  console.log(block)
});

Result

{
  block: {
    id: "7339302356952867200",
    blockhash: "gOFcvZtw2mU0zf7vt7Rxx30ncl6qMd7mC3PQwBMafS4=", 
    previousblockhash: "0pGZaRH5fhaTdQS5OLFexQoGhmFU3ogUcQkyVU4twAE=", 
    height:  1000, 
    timestamp:  "1592465088", 
	...
  },
  blocksmithaccountaddress:  "ZNK_ABMJHKVF_7X3EMF4M_WFESOYAW_XMZIVZZ4_LBIT2T47_JJ33HKLO_WZDBCG4H"
  popchange:  "-500000000"
  receiptvalue:  "100000000"
  skippedblocksmithsList:  []
  totalreceipts:  "2"
}

Block.getBlockByHeight()

Get the detail information about the specific block by passing its block height

Typescript

zoobc.Block.getBlockByHeight(height);

Parameters

  1. height - blockchain's block height

Return
return Promise<BlockResponse>

Example

zoobc.Block.getBlockByHeight(1000).then((block: BlockResponse) => {
  console.log(block)
});

Block.getBlocks()

Get list of the blocks at once. You can limit the number of block will given. Also you can choose from which block number should the list start.

Typescript

zoobc.Block.getBlocks(params);

Parameters

  1. params - BlockListParams
    • height: the start of the block height that you looking for
    • limit: the limit of the blocks will display

Return
return Promise<BlocksResponse>

Example

const params: BlockListParams = [
  "ZBC_RERG3XD7_GAKOZZKY_VMZP2SQE_LBP45DC6_VDFGDTFK_3BZFBQGK_JMWELLO7",
  "ZBC_ABMJHKVF_7X3EMF4M_WFESOYAW_XMZIVZZ4_LBIT2T47_JJ33HKLO_WZDBCG4H"
]
zoobc.Block.getBlocks(params).then((blocks: BlocksResponse) => {
  console.log(blocks)
});
Clone this wiki locally