vnt.js

VNTChain JavaScript API, middleware to talk to a vntchain node over RPC


Keywords
vntchain, javascript, API
License
LGPL-3.0
Install
npm install vnt.js@0.20.7

Documentation

VNTChain JavaScript API

Join the chat at https://gitter.im/vntchain/vnt.js

This is the VNTChain compatible JavaScript API which implements the Generic JSON RPC spec. It's available on npm as a node module, for bower and component as an embeddable js and as a meteor.js package.

You need to run a local VNTChain node to use this library.

Documentation

Installation

Node.js

npm install vnt

Yarn

yarn add vnt

Meteor.js

meteor add vntchain:vnt

As Browser module

Bower

bower install vnt

Component

component install vntchain/vnt.js
  • Include vnt.min.js in your html file. (not required for the meteor package)

Usage

Use the vnt object directly from global namespace:

console.log(vnt); // {vnt: .., shh: ...} // it's here!

Set a provider (HttpProvider)

if (typeof vnt !== 'undefined') {
  vnt = new Vnt(vnt.currentProvider);
} else {
  // set the provider you want from Vnt.providers
  vnt = new Vnt(new vnt.providers.HttpProvider("http://localhost:8545"));
}

Set a provider (HttpProvider using HTTP Basic Authentication)

vnt.setProvider(new vnt.providers.HttpProvider('http://host.url', 0, BasicAuthUsername, BasicAuthPassword));

There you go, now you can use it:

var coinbase = vnt.core.coinbase;
var balance = vnt.core.getBalance(coinbase);

You can find more examples in example directory.

Contribute!

Requirements

  • Node.js
  • npm
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
sudo apt-get install nodejs-legacy

Building (gulp)

npm run-script build

Testing (mocha)

npm test

Community