README
Xcare JavaScript API
This is the Ethereum compatible JavaScript API which implements the Generic JSON RPC spec. It's available on npm as a node module.
You need to run a local Xci node to use this library.
Installation
Node.js
npm install xciweb3
Usage
Use the xciweb3
object directly from global namespace:
console.log(xciweb3); // {eth: .., shh: ...} // it's here!
Set a provider (HttpProvider)
if (typeof xciweb3 !== 'undefined') {
xciweb3 = new XciWeb3(xciweb3.currentProvider);
} else {
// set the provider you want from Web3.providers
xciweb3 = new Xciweb3(new Xciweb3.providers.HttpProvider("http://localhost:8545"));
}
Set a provider (HttpProvider using HTTP Basic Authentication)
xciweb3.setProvider(new xciweb3.providers.HttpProvider('http://host.url', 0, BasicAuthUsername, BasicAuthPassword));
There you go, now you can use it:
var coinbase = xciweb3.eth.coinbase;
var balance = xciweb3.eth.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