Giter VIP home page Giter VIP logo

ethjs'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's People

Contributors

canterberry avatar hcastano avatar neurone 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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  avatar  avatar

ethjs's Issues

How do you add an account?

Issue Type

Description

Add some documentation on how to add a private key or HD wallet to eth instance.

Steps to reproduce

There doesn't seem to be any sort of accounts or wallet available on the eth object. The docs only mention going to look at the other packages like ethjs-accounts, then going there doesn't show how it interacts with ethjs. All documentation just leaves out any mention of how to add an account.

Versions

  • Node/NPM: 8.9
  • ethjs: 0.3.3

WARNING: ethjs v0.3.8 is adding [email protected] to deps !!!

I just couldn't figure why between two run of my CI build system I had completely different npm install log result...

I finally figured out that ethjs has just been updated, and I don't know how you managed guys, but [email protected] is now a DEPENDENCY of EthJS!!! :D

So its a reminder for always using npm i --save-exact...

eth.contract method result not iteratable

should be able to write

  const [ resultBn ] = await uniswapv1Dai.getEthToTokenInputPrice(oneEth)

error

TypeError: (intermediate value) is not iterable

workaround

  const { 0: resultBn } = await uniswapv1Dai.getEthToTokenInputPrice(oneEth)

Add to bower

ethjs is currently in NPM

It would be great if it was in bower also.

Error: [ethjs-query] while formatting outputs from RPC

Issue Type

Not able to deploy smart contract.

Description

I am on ethereum private network (via running my local endpoint node ) and trying to deploy contract using metamask. The internal error from metamask show some Issue with ethjs-query module:-

{
"note": "transactions:tx-state-manager#fail - add error",
"op": "add",
"path": "/err",
"timestamp": 1563861209948,
"value": {
"message": "Error: [ethjs-query] while formatting outputs from RPC '{"value":{"message":"missing trie node 0d0151dcc41746f67e67a17d8761aaae22351d014f25dca2fc63f42d34623ac4 (path )","code":-32603}}'",
"stack": "Error: [ethjs-query] while formatting outputs from RPC '{"value":{"message":"missing trie node 0d0151dcc41746f67e67a17d8761aaae22351d014f25dca2fc63f42d34623ac4 (path )","code":-32603}}'\n at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/background.js:1:1210794"
}

Steps to reproduce

Deploy Smart contract using metamask which internally uses ethjs

Versions

  • Browser: Chrome

eth.contract is not a function

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

TypeError: eth.contract is not a function

why does it say so , I even tried "C"ontract web3js

Error when calling contract function with address as argument

Issue Type

  • Bug

Description

When calling a Solidity function that takes only one argument, an address, I get the following error:

Uncaught (in promise) Error: [ethjs-query] while formatting inputs '[{"to":{"0":"0x409ba3dd291bb5d48d5b4404f5efa207441f6cba"},"data":"0x70a08231000000000000000000000000627306090abab3a6e1400e9345bc60c78a8bef57"},"latest"]' for method 'call' error: Error: [ethjs-format] hex string '[object Object]' must be an alphanumeric 42 utf8 byte hex (chars: a-fA-F) string, is 0 bytes

Full steps are below. Please let me know if you need any more information 😄

Steps to reproduce

The relevant function in my contract is from OpenZeppelin.

/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
    return balances[_owner];
}

I create a contract with EthJS:

const contract = eth.contract(ABI.abi, ABI.bytecode).at(address);

This is successful and gives me a contract object that looks like:

Object
  Approval:()
  Mint:()
  MintFinished:()
  OwnershipTransferred:()
  Transfer:()
  abi:Array[21]
  address:Object
  allowance:()
  approve:()
  balanceOf:()
  bytecode:"0x60606040526000600360146101000a81548160ff0219169083151502179055506040805190810160405280600981526020017f5961626279436f696e0000000000000000000000000000000000000000000000815250600490805190602001906200006c92919062000107565b506040805190810160405280600581526020017f594142425900000000000000000000000000000000000000000000000000000081525060059080519060200190620000ba92919062000107565b50601260065533600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550620001b6565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200014a57805160ff19168380011785556200017b565b828001600101855582156200017b579182015b828111156200017a5782518255916020019190600101906200015d565b5b5090506200018a91906200018e565b5090565b620001b391905b80821115620001af57600081600090555060010162000195565b5090565b90565b61185380620001c66000396000f3006060604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305d2035b146100eb57806306fdde0314610118578063095ea7b3146101a657806318160ddd1461020057806323b872dd14610229578063313ce567146102a257806340c10f19146102cb578063661884631461032557806370a082311461037f5780637d64bcb4146103cc5780638da5cb5b146103f957806395d89b411461044e578063a9059cbb146104dc578063d73dd62314610536578063dd62ed3e14610590578063f2fde38b146105fc575b600080fd5b34156100f657600080fd5b6100fe610635565b604051808215151515815260200191505060405180910390f35b341561012357600080fd5b61012b610648565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016b578082015181840152602081019050610150565b50505050905090810190601f1680156101985780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101b157600080fd5b6101e6600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106e6565b604051808215151515815260200191505060405180910390f35b341561020b57600080fd5b6102136107d8565b6040518082815260200191505060405180910390f35b341561023457600080fd5b610288600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506107de565b604051808215151515815260200191505060405180910390f35b34156102ad57600080fd5b6102b5610b9d565b6040518082815260200191505060405180910390f35b34156102d657600080fd5b61030b600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ba3565b604051808215151515815260200191505060405180910390f35b341561033057600080fd5b610365600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610d8b565b604051808215151515815260200191505060405180910390f35b341561038a57600080fd5b6103b6600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061101c565b6040518082815260200191505060405180910390f35b34156103d757600080fd5b6103df611065565b604051808215151515815260200191505060405180910390f35b341561040457600080fd5b61040c61112d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561045957600080fd5b610461611153565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104a1578082015181840152602081019050610486565b50505050905090810190601f1680156104ce5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156104e757600080fd5b61051c600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506111f1565b604051808215151515815260200191505060405180910390f35b341561054157600080fd5b610576600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611415565b604051808215151515815260200191505060405180910390f35b341561059b57600080fd5b6105e6600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611611565b6040518082815260200191505060405180910390f35b341561060757600080fd5b610633600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611698565b005b600360149054906101000a900460ff1681565b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106de5780601f106106b3576101008083540402835291602001916106de565b820191906000526020600020905b8154815290600101906020018083116106c157829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffff…00160002081905550610f30565b610eaf83826117f090919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156110c357600080fd5b600360149054906101000a900460ff161515156110df57600080fd5b6001600360146101000a81548160ff0219169083151502179055507fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0860405160405180910390a16001905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111e95780601f106111be576101008083540402835291602001916111e9565b820191906000526020600020905b8154815290600101906020018083116111cc57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561122e57600080fd5b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561127c57600080fd5b6112ce82600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f090919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061136382600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461180990919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60006114a682600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461180990919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156116f457600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561173057600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008282111515156117fe57fe5b818303905092915050565b600080828401905083811015151561181d57fe5b80915050929150505600a165627a7a723058204d67b69cfce14fcc0e0643ab675a7b56cc0bfc320767ae0516b72ab919a667000029"
  decimals:()
  decreaseApproval:()
  defaultTxObject:Object
  filters:n
  finishMinting:()
  increaseApproval:()
  mint:()
  mintingFinished:()
  name:()
  owner:()
  query:r
  symbol:()
  totalSupply:()
  transfer:()
  transferFrom:()
  transferOwnership:()
  __proto__:Object

With the contract initialised, I try to call the balanceOf method.

const balance = await coinContract.balanceOf(""0x627306090abab3a6e1400e9345bc60c78a8bef57"");

This is where it fails and throws the error 😢 ,

Versions

  • Node/NPM: 8.2.1
  • Browser: Version 55.0.2883.87 (64-bit)

ethjs-abi and ethjs-query are out-of-date

The ethjs-abi and ethjs-query dependencies are out-of-date. Please upgrade and deploy a new version to npm.

Examples of things that are broken

  • ethjs-abi encodeSignature method does not exist yet.
  • ethjs-query does not handle promise rejections correctly and results in UnhandledPromiseRejectionWarning exceptions. See #21 as well.

Current workaround is to use the child libraries directly, but that defeats the purpose of having the parent ethjs library at all.

TypeError: filter.watch is not a function

Code example is from user guide

const Eth = require('ethjs');
const eth = new Eth(new Eth.HttpProvider('http://localhost:8545'));

const filter = new eth.filter.PendingTransactionFilter()
.new()
.then((result) => {
  // result <BigNumber ...> filterId
})
.catch((error) => {
  // result null
});

const watcher = filter.watch((error, result) => {
  // result null ['0xfd234829...', '0xsf2030d1...']
});
watcher.stopWatching(cb);

filter.uninstall()
.then((result) => {
  // result true
})
.catch((error) => {
  // result null
});

Error

$ node index.js
index.js:13
const watcher = filter.watch((error, result) => {
                       ^

TypeError: filter.watch is not a function
    at Object.<anonymous> (/index.js:13:24)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:423:7)
    at startup (bootstrap_node.js:147:9)
    at bootstrap_node.js:538:3

Unable to write tests for events when using Solidity Events

The convention when writing Solidity Smart Contracts is to capitalize events (http://solidity.readthedocs.io/en/develop/structure-of-a-contract.html#events) aka

contract SimpleAuction {
    event HighestBidIncreased(address bidder, uint amount); // Event

    function bid() payable {
        // ...
        HighestBidIncreased(msg.sender, msg.value); // Triggering event
    }
}

Such a contract will generate a javascript function that will appear as

SimpleAuction.HighestBidIncreased

But if you try to use the ABI when writing tests for ethjs, you will anger ESLint with the error:

A function with a name starting with an uppercase letter should only be used as a constructor  ne
w-cap

The workaround is to write solidity contracts with events starting with a lower case character, which isn't ideal if there are linting constraints introduced in Solidity which force uppercase event names.

Getting error when decoding event with indexed fields.

Hi! I'm using Ganache 1.0.1 and ethjs 0.4.0.
Here how i use watcher:

this.FightFinished = Contracts.zoneContract.FightFinished(
  { toBlock: 'latest', player: Client.activeAccount }
)
this.FightFinished.new()
this.FightFinished.watch(r => {  
})

I believe this was outlined at https://github.com/ethjs/ethjs-abi/issues/15
But no response at all, i'll try get response here instead.

Log from watch:

Error: [ethjs-filter] while decoding filter change event data from RPC '[{"logIndex":"2","transactionIndex":"0","transactionHash":"0x2823403d01f35e4d04a2316c72c9a9906160cafa447099644c6af0c48c18261e","blockHash":"0x745dd38108efe3469825dcbc9986a27717ccee25c95cae8cb338886eb73aa639","blockNumber":"92","address":"0xb57e97e510c60673412307547142e7492cd2cb1f","data":"0x0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002","topics":["0x79b7b95e80b1a19a31c1a9cdfdbc01f323ac30aef005dd716b3474f8d4b72c68","0x000000000000000000000000e91d5216f69648ce919442e2c426cf48738f4101"],"type":"mined"}]': TypeError: Cannot read property 'slice' of undefined

Cannot call transfer method of smart contract

Issue Type

It's a bug and I am not sure how to fix it.

Description

I am using ethjs in a react project to interact with a smart contract.

What I do so far:

  • Accessing the address that the user is currently logged in with in meta mask ✅
window.web3.eth.getAccounts(function(err,accounts) {
	resolve(accounts[0]);
});
  • Reading values from the Smart Contract such as the Symbol, Currency Name, Balance for Address ✅
const OASContract = eth.contract(abi).at('0x559623d3660bbae4ee3c90c6ad600d54a520b792');
OASContract.symbol().then(function(result) {
	resolve(result["0"])
});
OASContract.balanceOf(address).then(function(result) {
	resolve(result.balance)
});
OASContract.name().then(function(result) {
	resolve(result["0"])
});

This all works. But now I want to call the transfer method of the SC and this is where I get lost.

Steps to reproduce

OASContract.transferFrom(_from, _to, amount, {from: _from, gas:55000})

Now, this does not work. I get some weird messages in the console:

XML Parsing Error: no root element found
Location: https://ropsten.infura.io/C2D8VJd9N6XXXXXXXXX
Line Number 1, Column 1:

Error: [ethjs-query] while formatting inputs

Calling function 'create'
myethobj.create("0x2ce13d8dd1b248286575591b695805327cf7d9ba", "hello");
Gives me an error:

Error: [ethjs-query] while formatting inputs '[{"to":"0x208A8B1A0318E5ed3E1bd3412B5d2E7eE688fac0","data":"0xa15ab08d0000000000000000000000002ce13d8dd1b248286575591b695805327cf7d9ba0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000"}]' for method 'sendTransaction' error: Error: [ethjs-format] object {"to":"0x208A8B1A0318E5ed3E1bd3412B5d2E7eE688fac0","data":"0xa15ab08d0000000000000000000000002ce13d8dd1b248286575591b695805327cf7d9ba0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000"} must contain properties: from, data

The function in solidity:

function create(address to, string metadata) public onlyAdmin {

Whats going on here?

Update getTransactionSuccess to decode logs

Update getTransactionSuccess method to optionally decode logs

Issue Type

Description

The getTransactionSuccess method is helpful, but I'd like it to be able to decode returned logs as well. The method could either take as argument an ABI or could be added as a method to a contract instance (i.e. contractInstance.getTransactionSuccess("<txHash>")).

I've found myself creating a log decoder (i.e. const decoder = Eth.abi.logDecoder(<ABI>)) and running logs returned via getTransactionSuccess through that decoder, and it would be nice to have the method do that for me.

Getting error insufficient funds for gas * price + value

we find the pending transaction. After finding it, we want to swap for the same token.
SwapExactEthtoToken

this error changes from time to time as shown below why get these errors ?

Error code -32000 Message is changing

  1. Insufficient balance for transaction
  2. Gas fee too low for this transaction
  3. Replacement underpriced

Getting error insufficient funds for gas * price + value

we find the pending transaction. After finding it, we want to swap for the same token.
SwapExactEthtoToken

this error changes from time to time as shown below why get these errors ?

Error code -32000 Message is changing

  1. Insufficient balance for transaction
  2. Gas fee too low for this transaction
  3. Replacement underpriced

Getting errors

ethjs

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/issues?q=is%3Aissue+is%3Aclosed

Issue Type

Description

On node 8.9.4 i do

yarn add ethjs

I get this

ReferenceError: Unknown plugin "transform-imports" specified in "/home/andy/dev/free-shift/node_modules/ethjs-provider-http/package.json" at 1, attempted to resolve relative to "/home/andy/dev/free-shift/node_modules/ethjs-provider-http"

then I do

yarn add transform imports

and get

ERROR in ./node_modules/ethjs-provider-http/lib/index.js
Module build failed: SyntaxError: Unexpected token, expected , (1:8)
at Parser.pp$5.raise (/home/andy/dev/free-shift/node_modules/babylon/lib/index.js:4454:13)

(Add images if possible)

Steps to reproduce

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

Versions

  • Node/NPM:
  • Browser:

Tx `from` should default to `selectedAccount`.

Web3 defaults a tx with no from field to be the current selectedAddress, and this makes for some pretty obvious and clean web3.eth.sendTransaction calls.

I'd vote to loosen the enforcement of the from parameter to allow this to follow to the provider level.

Can't store string at smart contract

When I pass string to the smartcontract method, it says :

Error: [ethjs-abi] invalid hex or buffer, must be a prefixed alphanumeric even length hex string
    at hexOrBuffer (index.js:41)
    at Object.encodeFixedBytes [as encode] (index.js:144)
    at eval (index.js:27)
    at Array.forEach (<anonymous>)

Unhandled promise rejection on errors

Issue Type

Bug

Description

Produce unhandled promise rejection on each error in Node.js and Browser.

Steps to reproduce

  1. Initialize eths:
const eth = new Eth(new Eth.HttpProvider('...url...'));
  1. Call any method:
await eth.contract(abi, bytecode).new();

Versions

  • Node/NPM: 9.3
  • Browser: Chrome 63

ethjs-contract out of date

The ethjs-contract was upgraded to 0.2.x.

Example of things that are broken: eth.contract(...).new() returns undefined instead of a promise if no callback is given.

Current workaround is to use the child libraries directly.

> > > got the same error can anyone help me with this???

Not Working for me
Error: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32000,"message":"replacement transaction underpriced"}}'

same for me :(
did you deal with that?

Have you found a solution?

inpage.js:1 MetaMask - RPC Error: Error: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32603,"data":{"message":"VM Exception while processing transaction: revert","code":-32000,

same here :(

Originally posted by @abids99 in #33 (comment)

[Feature] Static or CDN version.

Started working with ethjs recently and one of the pain points was including it for online examples,
( had to use the one from one of the sample files) and couldn't make one with browserify. It also feels like this should be included front and center since your landing page states "Only 103 kB minified!"

Thanks

Allow schema to be defined at runtime

Maybe this turns it into a very different module, but:

As a wallet developer who sometimes wants to add methods, but doesn't want to deal with PRs and npm publishes of schema, ethjs, and all their dependents, I'd rather just add a getSchema RPC method which allows my web3 context to define its own expanded set of available methods.

Would you merge a change like that?

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.