/ethjs

A light weight abstraction of the Ethereum JSON RPC API

Primary LanguageJavaScriptMIT LicenseMIT

ethjs

Still a work in progress, feel free to log any issues

A light weight Ethereum RPC interface written in ES6. RPC calls return a promise/stream.

Installation

npm install ethjs

Usage

Init

import Eth from 'ethjs';

const client = new Eth('<httpProviderUrl>');

RPC methods

RPC methods exposed on client and follow function signature of RPC spec

client.getCoinbase()
  .then(address => console.log(address), err => console.error(err));

Contracts

Create contracts and generate an JS contract interface using the ABI.

const contract = client.contracts.create(abi, {
    from: '<fromAddress>',
    data: contractCode,
    gas: 1000000,
}).subscribe(res => console.log(res), err => console.error(err));

Contract functions can then be called

contract.aFunctionName(10, 'an argument').subscribe(res => console.log(res), err => console.error(err));

Events can be subscribed to

contract.AnEvent().subscribe(res => console.log(res), err => console.error(err));

Contributing

Feel free to create issues or pull requests!