question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CALL_EXCEPTION on array getter

See original GitHub issue

maybe i’m missing something here, but i cannot call an array getter successfully with an index different from 0.

my code:

const swap = new Contract(pool.curve.address, curvefi.curveAbi, provider);
console.log(await swap.coins(0)); // works ok
console.log(await swap.coins(1)); // Error: call revert exception (method="coins(int128)", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.0.5)

getter abi:

{
 "name": "coins",
 "outputs": [
  {
   "type": "address",
   "name": "out"
  }
 ],
 "inputs": [
  {
   "type": "int128",
   "name": "arg0"
  }
 ],
 "constant": true,
 "payable": false,
 "type": "function",
 "gas": 2040
}

contract: https://etherscan.io/dapp/0x45f783cce6b7ff23b2ab2d70e416cdb7d6055f51#readContract

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
yuetloocommented, Sep 23, 2020

@cruzdanilo , I got my ABI from etherscan. If I remove gas from the abi, my example works too. ethers uses the abi gas when provided.

From my testing, different node gives different error when a low gas amount is provided.

  • infura: call revert exception (method=“coins(int128)”, errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.0.5

  • alchemy and Cloudflare {“jsonrpc”:“2.0”,“id”:42,“error”:{“code”:-32000,“message”:“out of gas”}}

  • etherscan sometimes works sometimes timeout Error: timeout

1reaction
ricmoocommented, Sep 23, 2020

Actually. This might be something I need to address in ethers.

I currently add 21000 gas to the gas cost in the ABI, but I should compute the intrinsic gas cost of sending the data in the transaction. i.e. the cost of sending a byte in data that is 0, is cheaper than the cost of sending non-zero. So the 1 costs more. Ethers can account for this. It just isn’t now.

Vyper is much more accurate when estimating gas costs, which is why it’s on the edge and this hasn’t come up before.

I’ll look into this soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Null Getter, when split throwing exception - java - Stack Overflow
If you're looking for a "prettier" way of doing it, then this is a spot that seems decent for the '?' operator (called...
Read more >
Best Practices for Java Getter and Setter - DZone
In this post, we take a closer look at getter and setter methods in Java, common mistakes, and best practices for combating these...
Read more >
Java Getter and Setter Tutorial - from Basics to Best Practices
How to write getter and setter methods in Java with in-depth description, various code examples and best practices.
Read more >
Getter and Setter Method in Java Example - Javatpoint
The setter method setVal() expecting a reference of an int array, and at line 7, the reference of the int arr[] is getting...
Read more >
Introduction to JavaScript getters and setters in ES6
The setName() removes the whitespaces from both ends of the newName argument and throws an exception if the newName is empty. The constructor()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found