Installation

Installing gbapi

Install

Install the gbapi library from Node Package Manager

npm install govblocksjs;

Import

import { GovBlocksMaster } from 'govblocksjs';
import { Web3 } from 'web3';

if your application doesn't support 'import' statement, import bundle.js file in main html file

<script src="node_modules/govblocksjs/bundle.js" type="text/javascript"></script>

Initialize

Next, initialize GovBlocksMaster class. This should be done with a web3 provider.

var gbmaster = new GovBlocksMaster(web3);

If bundle.js is imported, GovBlocksMaster class is available as window object.

var gbmaster = new window.GovBlocksMaster(web3);

As most of the calls are asynchronous , GovBlocks Protocol library uses callback function for every call.

Callback example:

This is an example function of gbmaster instance which requires callback function as an argument

gbmaster
.getAlldAppRegistered(function(error,result){
console.log(error);
console.log(result);
}

‚Äč