Skip to content

vntchain/vnt.js

 
 

Repository files navigation

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

About

The VNT Chain JavaScript API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 97.3%
  • HTML 2.7%