Skip to content

Latest commit

 

History

History
170 lines (135 loc) · 9.36 KB

user-guide.md

File metadata and controls

170 lines (135 loc) · 9.36 KB

User Guide

All information for developers using ethjs-rpc should consult this document.

Install

npm install --save ethjs-rpc

Usage

const HttpProvider = require('ethjs-provider-http');
const EthRPC = require('ethjs-rpc');
const eth = new EthRPC(new HttpProvider('http://localhost:8545'));

eth.sendAsync({ method: 'eth_accounts' }, (err, accounts1) => {
  // null ['0x...', '0x....']
});

eth.sendAsync({ method: 'eth_gasPrice' }, (err, gasPrice) => {
  // null '0xe83922'
});

Async Only

All methods are async only.

Error handling

Error handling is done through function callbacks or promised catches.

Supported Methods

ethjs-rpc supports all Ethereum spec RPC methods.

Browser Builds

ethjs provides production distributions for all of its modules that are ready for use in the browser right away. Simply include either dist/ethjs-rpc.js or dist/ethjs-rpc.min.js directly into an HTML file to start using this module. Note, an EthRPC object is made available globally.

<script type="text/javascript" src="ethjs-rpc.min.js"></script>
<script type="text/javascript">
new EthRPC(...);
</script>

Note, even though ethjs should have transformed and polyfilled most of the requirements to run this module across most modern browsers. You may want to look at an additional polyfill for extra support.

Use a polyfill service such as Polyfill.io to ensure complete cross-browser support: https://polyfill.io/

Latest Webpack Figures

Version: webpack 2.1.0-beta.15
Time: 859ms
             Asset    Size  Chunks             Chunk Names
    ethjs-rpc.js  175 kB       0  [emitted]  main
ethjs-rpc.js.map  219 kB       0  [emitted]  main
   [4] ./lib/index.js 5.02 kB {0} [built]
    + 13 hidden modules

Version: webpack 2.1.0-beta.15
Time: 2699ms
             Asset     Size  Chunks             Chunk Names
ethjs-rpc.min.js  78.5 kB       0  [emitted]  main
   [4] ./lib/index.js 5.02 kB {0} [built]
    + 13 hidden modules

Other Awesome Modules, Tools and Frameworks

Foundation

  • web3.js -- the original Ethereum JS swiss army knife Ethereum Foundation
  • ethereumjs -- critical ethereum javascript infrastructure Ethereum Foundation
  • browser-solidity -- an in browser Solidity IDE Ethereum Foundation

Nodes

  • geth Go-Ethereum
  • parity Rust-Ethereum build in Rust
  • testrpc Testing Node (ethereumjs-vm)

Testing

  • wafr -- a super simple Solidity testing framework
  • truffle -- a solidity/js dApp framework
  • embark -- a solidity/js dApp framework
  • dapple -- a solidity dApp framework
  • chaitherium -- a JS web3 unit testing framework
  • contest -- a JS testing framework for contracts

Wallets

  • ethers-wallet -- an amazingly small Ethereum wallet
  • metamask -- turns your browser into an Ethereum enabled browser =D

Our Relationship with Ethereum & EthereumJS

We would like to mention that we are not in any way affiliated with the Ethereum Foundation or ethereumjs. However, we love the work they do and work with them often to make Ethereum great! Our aim is to support the Ethereum ecosystem with a policy of diversity, modularity, simplicity, transparency, clarity, optimization and extensibility.

Many of our modules use code from web3.js and the ethereumjs- repositories. We thank the authors where we can in the relevant repositories. We use their code carefully, and make sure all test coverage is ported over and where possible, expanded on.