xciweb3

Xcare JavaScript API, middleware to talk to a xcare node over RPC

Usage no npm install needed!

<script type="module">
  import xciweb3 from 'https://cdn.skypack.dev/xciweb3';
</script>

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.

Documentation

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

Community