sec blockchain block lib

Usage no npm install needed!

<script type="module">
  import secBlockSecjsBlock from 'https://cdn.skypack.dev/@sec-block/secjs-block';




This libary contains the definition of block and block chain model. Use this libary can get the information of the block and blockchain information. And also generate the genesis block.

API of token blockchain

new secjsTokenBlock()

Instance object of block of token chain.

  • config: the file path to save the token information

secjsTokenBlock.generateBlock(tokenPool, tokenBlockChain)

Get the block information from transaction pool and write the information to block object.

  • tokenPool: Instance of token transaction pool
  • tokenBlockChain: Instance of token-blockchain


Return the block instance.

secjsTokenBlock.putGenesis(genesis, cb)

Put token chain genesis block into database.

  • genesis: json object of genesis block
  • cb: callback function

secjsTokenBlock.getBlockFromDB(hash, cb)

Get Block from database using hash.

  • hash: the hash of a block
  • cb: callback function

secjsTokenBlock.getBlocksFromDB(hashArray, cb)

Get blocks from array of blockhash

  • hashArray: an array of block hash
  • cb: callback function

secjsTokenBlock.putBlockToDB(block, cb)

  • block: json object of block
  • cb: callback function


Get genesis block direct from buffer


Get last block direct from buffer


Verification the transaction.

new secjsTokenBlockChain()

  • config: Token Block chain


This function check the existence of the file to save the block chain information. If the file is not existed, a new file will be created. Otherwise the block chain will be loaded from the file.

  • callback: callback function with parameter tocken blockchain


Return the block chain instance


Create the genesis blockchain

API of transaction block chain

Funcionality simlar as token blockchain and token block