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.
npm install vnt
yarn add vnt
meteor add vntchain:vnt
Bower
bower install vnt
Component
component install vntchain/vnt.js
- Include
vnt.min.js
in your html file. (not required for the meteor package)
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.
- Node.js
- npm
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
sudo apt-get install nodejs-legacy
npm run-script build
npm test