vnt.js
v0.20.7
Published
VNTChain JavaScript API, middleware to talk to a vntchain node over RPC
Readme
VNTChain JavaScript API
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.
Installation
Node.js
npm install vntYarn
yarn add vntMeteor.js
meteor add vntchain:vntAs Browser module
Bower
bower install vntComponent
component install vntchain/vnt.js- Include
vnt.min.jsin 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-legacyBuilding (gulp)
npm run-script buildTesting (mocha)
npm test