web3i.js version 0.14.0 supports multiple instances of web3i object. To migrate to this version, please follow the guide:
-var web3i = require('web3i');
+var web3i = require('web3i');
+var web3i = new web3i();
This is the Ethereum 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.
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![dependency status][dep-image]][dep-url] [![dev dependency status][dep-dev-image]][dep-dev-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Stories in Ready][waffle-image]][waffle-url]
You need to run a local Ethereum node to use this library.
<script src="./dist/web3i.js"></script>Bower
bower install web3i
Component
component install ethereum/web3i.js
- Include
web3i.min.js
in your html file. (not required for the meteor package)
Use the web3i
object directly from global namespace:
console.log(web3i); // {eth: .., shh: ...} // it's here!
Set a provider (HttpProvider)
if (typeof web3i !== 'undefined') {
web3i = new web3i(web3i.currentProvider);
} else {
// set the provider you want from web3i.providers
web3i = new web3i(new web3i.providers.HttpProvider("http://localhost:8545"));
}
Set a provider (HttpProvider using HTTP Basic Authentication)
web3i.setProvider(new web3i.providers.HttpProvider('http://host.url', 0, BasicAuthUsername, BasicAuthPassword));
There you go, now you can use it:
var coinbase = web3i.inb.coinbase;
var balance = web3i.inb.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