Giter Site home page Giter Site logo

ethjs-abi's Introduction

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 ethjs

CDN

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ethjs.min.js"></script>

Note, exports to window.Eth global.

Usage

const Eth = require('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.
  • Examples - Examples of ethjs in use.

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.

ethjs-abi's People

Contributors

karlfloersch avatar kumavis avatar pelle avatar silentcicero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ethjs-abi's Issues

Make Results Iterable

ethjs-abi

Before opening a new issue, please take a moment to review our community guidelines to make the contribution process easy and effective for everyone involved.

Before opening a new issue, you may find an answer in already closed issues:
https://github.com/ethjs/ethjs-abi/issues?q=is%3Aissue+is%3Aclosed

Issue Type

Description

I'd love to have Symbol.iterator implemented on the Result data structure. This would enable destructuring assignment, spreads, etc, when handling values returned from contracts. Additionally, iteration should only be performed over numerically indexed keys.

Steps to reproduce

Using the decodeParams function with any valid parameters, the following code will currently throw:

const [a, b, c] = decodeParams(...);

Only the following works currently:

const result = decodeParams(...);
const a = result[0]
const b = result[1]
const c = result[2]

Versions

Increase error depth/detail for debugging

ethjs-abi

Before opening a new issue, please take a moment to review our community guidelines to make the contribution process easy and effective for everyone involved.

Before opening a new issue, you may find an answer in already closed issues:
https://github.com/ethjs/ethjs-abi/issues?q=is%3Aissue+is%3Aclosed

Issue Type

Description

(Add images if possible)

Steps to reproduce

(Add link to a demo on https://jsfiddle.net or similar if possible)

Versions

  • Node/NPM:
  • Browser:

Uncaught TypeError: Cannot read property '0' of undefined

Issue Type

Uncaught TypeError: Cannot read property '0' of undefined
    at http://localhost:8080/app.js:29773:34
    at Array.map (native)
    at Object.decodeEvent (http://localhost:8080/app.js:29772:6)
    at http://localhost:8080/app.js:33803:38
    at Array.map (native)
    at Object.decodeLogs (http://localhost:8080/app.js:33774:19)
    at Object.callback (http://localhost:8080/app.js:33896:35)
    at http://localhost:8080/app.js:6974:25
    at http://localhost:8080/app.js:37588:9
    at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/scripts/inpage.js:168:7

Description

On a private-network on port 8545 using testrpc and MetaMask when I send coins to another account I get this error

error

Steps to reproduce

On Windows
Prompt1
truffle.cmd init webpack

Prompt2
testrpc

Prompt1
truffle.cmd compile
truffle.cmd migrate
npm run dev

Go to localhost:8080

Versions

  • Node/NPM: Node 8.0 npm 5.0.3
  • Browser: Chrome

TypeError thrown when event received.

TypeError thrown when event received.

Running in nodejs, I watch for the following event:

    event Transfer(address indexed _from, address indexed _to, uint256 _value);

When the event occurs, an exception is thrown:

Error: [ethjs-filter] while decoding filter change event data from RPC '[{"logIndex":"0","transactionIndex":"0","transactionHash":"0x6b0d1c8f2b072615aab822459b6318bfad01dca4663c2c4d41c6cdd1d84b3033","blockHash":"0x1f603b873f6e016ce99a2f4a34b13e877cbdd94308e4fc4fbd42f1d8a132cb1a","blockNumber":"17","address":"0x345ca3e014aaf5dca488057592ee47305d9b3e10","data":"0x0000000000000000000000000000000000000000000000001bc16d674ec80000","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000627306090abab3a6e1400e9345bc60c78a8bef57","0x000000000000000000000000f17f52151ebef6c7334fad080c5704d77216b732"],"type":"mined"}]': TypeError: Cannot read property 'slice' of undefined
    at C:\Development\sandbox\ethereum\repl-alliance\node_modules\ethjs-filter\lib\index.js:29:31
    at C:\Development\sandbox\ethereum\repl-alliance\node_modules\ethjs-query\lib\index.js:101:16
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)

The problem appears to be caused in the decodeEvent function. My topics array contains only a single value - 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. This was set by eth-contract v0.1.9 and is the hash of the signature of the Transfer event. However, the code in decodeEvent looks for a value in topics[1].

The event has two indexed 'inputs' and is not anonymous, but there is only a single item in the topics array (the signature), so the .slice is called on undefined, and the exception is thrown.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.