Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@metamask/ethjs

MetaMask2.4kMIT0.6.0

A light-weight, highly optimised JS utility for Ethereum

ethereum, events, rpc

readme

ethjs


A highly optimised, light-weight JS utility for Ethereum based on web3.js, but lighter, async only and using BN.js.

Only 106 kB minified!

Install

npm install --save @metamask/ethjs

Usage

const Eth = require('@metamask/ethjs');
const eth = new Eth(new Eth.HttpProvider('https://ropsten.infura.io'));

eth.getBlockByNumber(45300, true, (err, block) => {
  // result null { ...block data... }
});

const etherValue = Eth.toWei(72, 'ether');

// result <BN: 3e733628714200000>

const tokenABI = [{
  "constant": true,
  "inputs": [],
  "name": "totalSupply",
  "outputs":[{"name": "","type": "uint256"}],
  "payable": false,
  "type": "function",
}];

const token = eth.contract(tokenABI).at('0x6e0E0e02377Bc1d90E8a7c21f12BA385C2C35f78');

token.totalSupply().then((totalSupply) => {
  // result <BN ...>  4500000
});

// token.transfer( ... ).then(txHash => eth.getTransactionSuccess(txHash)).then(receipt => console.log(receipt));

About

A simple module for building dApps and applications that use Ethereum.

Please see our complete user-guide for more information.

Contributing

Please help better the ecosystem by submitting issues and pull requests to ethjs. We need all the help we can get to build the absolute best linting standards and utilities. We follow the AirBNB linting standard and the unix philosophy.

Guides

You'll find more detailed information on using ethjs and tailoring it to your needs in our guides:

  • User guide - Usage, configuration, FAQ and complementary tools.
  • Developer guide - Contributing to ethjs and writing your own code and coverage.

Help out

There is always a lot of work to do, and will have many rules to maintain. So please help out in any way that you can:

  • Create, enhance, and debug ethjs rules (see our guide to "Working on rules").
  • Improve documentation.
  • Chime in on any open issue or pull request.
  • Open new issues about your ideas for making ethjs better, and pull requests to show us how your idea works.
  • Add new tests to absolutely anything.
  • Create or contribute to ecosystem tools.
  • Spread the word!

Please consult our Code of Conduct docs before helping out.

We communicate via issues and pull requests.

Important documents

Our Relationship with Ethereum & EthereumJS

We would like to mention that we are not in any way affiliated with the Ethereum Foundation. 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.

Special Thanks

ethjs was built by a strong community of Ethereum developers. A special thanks to:

Licence

This project is licensed under the MIT license, Copyright (c) 2016 Nick Dodson. For more information see LICENSE.md.

The MIT License

Copyright (c) 2016 Nick Dodson. nickdodson.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased

0.6.0

Changed

  • BREAKING: Update bn.js from 4.11.6 to 5.2.1 (#19)
  • BREAKING: @babel/runtime@^7.0.0 is now a peerDependency (#17)
  • Update ethjs dependencies (#19)
    • @metamask/ethjs-contract@^0.3.3->^0.4.1
    • @metamask/ethjs-filter@^0.2.0->^0.3.0
    • @metamask/ethjs-provider-http@^0.2.0->^0.3.0
    • @metamask/ethjs-query@^0.5.2->^0.7.1
    • @metamask/ethjs-unit@^0.2.1->^0.3.0
    • @metamask/ethjs-util@^0.2.1->^0.3.0

Fixed

  • Remove transitive dependency on babel-runtime (#17) (#19)

0.5.1

Changed

  • Replace ethjs packages with @metamask/ forks (#12) (#16)

Fixed

  • Bump js-sha3 from 0.5.5 to ^0.9.2 (#13)
    • npm dedupe; npm audit fix

0.5.0

Changed

  • Rename package from ethjs to @metamask/ethjs (#9)
  • Deprecate nodejs <8.17, npm<6 (#8)

Fixed

  • Re-build dist from source (#2)

0.3.5

Fixed

  • Fix getTransactionSuccess unhandled promise rejection
  • Fix getTx unhandled promise rejection

0.3.4

Fixed

  • EthJS-RPC
    • Fix RPC unhandled promise rejection.

0.2.8

Added

  • getTransactionSuccess
    • Added the very essential getTransactionSuccess method

0.2.7

Changed

  • abi updated, format and contract updates
    • Updated ethjs-abi, ethjs-format, ethjs-query, ethjs-contract
    • The updates will fix some small problems with geth/parity compat

0.2.6

Added

  • added abi, personal sign/ecrecover
    • Expose ABI module
    • Added personal_sign/personal_ecRecover
    • Added log decoders

0.2.4

Changed

  • package updates
    • Updates provider, handle 405 better

0.2.0

Changed

  • provider upate
    • Set Provider now more dynamic accross all modules

0.1.9

Fixed

  • Specified more dependencies in package.json

0.1.6

Changed

  • handle 500 errors better
  • Update ethjs-query

0.1.5

Changed

  • update unit formatting

0.1.4

Fixed

  • BN formatting fix

0.1.3

Changed

  • upgrade ethjs-query

0.1.1

Added

  • ethjs
    • Basic testing
    • Basic docs
    • License