Installation

Installing gbapi

Install

Install the gbapi library from Node Package Manager
1
npm install govblocksjs;
Copied!

Import

1
import { GovBlocksMaster } from 'govblocksjs';
2
import { Web3 } from 'web3';
Copied!
if your application doesn't support 'import' statement, import bundle.js file in main html file
1
<script src="node_modules/govblocksjs/bundle.js" type="text/javascript"></script>
Copied!

Initialize

Next, initialize GovBlocksMaster class. This should be done with a web3 provider.
1
var gbmaster = new GovBlocksMaster(web3);
Copied!
If bundle.js is imported, GovBlocksMaster class is available as window object.
1
var gbmaster = new window.GovBlocksMaster(web3);
Copied!
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
1
gbmaster
2
.getAlldAppRegistered(function(error,result){
3
console.log(error);
4
console.log(result);
5
}
Copied!
Last modified 3yr ago
Copy link