Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't call contract with uint256 as a parameter #178

Closed
Kastamarov opened this issue May 16, 2018 · 7 comments
Closed

Can't call contract with uint256 as a parameter #178

Kastamarov opened this issue May 16, 2018 · 7 comments

Comments

@Kastamarov
Copy link

Kastamarov commented May 16, 2018

I have a contract with this part off ABI:

[
{
      "constant": true,
      "inputs": [
        {
          "name": "",
          "type": "uint256"
        }
      ],
      "name": "btcTransactions",
      "outputs": [
        {
          "name": "",
          "type": "bool"
        }
      ],
      "payable": false,
      "stateMutability": "view",
      "type": "function"
    }
] 

The contract can be found in the rinkeby test network on the address 0xf941b2f00aedd0bd8b98642a6e8232ccf02efd50.

Using the truffle I can easy call this function with a string or a BigNumber as a parameter, for example:
(rinkeby)>ICO.at("0xf941b2f00aedd0bd8b98642a6e8232ccf02efd50").btcTransactions("0x9d8336ca0217be46aba738cf09c429086398f0432420c8fe391a9d2ee18319a8");
false
(rinkeby)>ICO.at("0xf941b2f00aedd0bd8b98642a6e8232ccf02efd50").btcTransactions(web3.toBigNumber("0x9d8336ca0217be46aba738cf09c429086398f0432420c8fe391a9d2ee18319a8"));
false

But when i try to do the same thing using ethers.js I get the error:

Error: call exception (address="0xf941b2f00aedd0bd8b98642a6e8232ccf02efd50", method="btcTransactions(uint256)", value=[{"_bn":"9d8336ca0217be46aba738cf09c429086398f0432420c8fe391a9d2ee18319a8"}])
at Object.throwError (node_modules/ethers/utils/errors.js:74:17)

I've tried different ways to resolve this:

  • contract.btcTransactions("hash");
  • contract.btcTransactions(toUtf8Bytes("hash"));
  • contract.btcTransactions(bigNumberify("hash"));
  • contract.btcTransactions(bigNumberify(toUtf8Bytes("hash"))).

but it didn't help.

Thanks.

@ricmoo
Copy link
Member

ricmoo commented May 16, 2018

Are you sure you are using a Rinkeby provider? Is there any reason the method would throw? Call exception means the response from the network was empty...

@Kastamarov
Copy link
Author

Yes, I'm sure, because I can easily call any other method from the contract using ethers.js

@ricmoo
Copy link
Member

ricmoo commented May 16, 2018

we are looking into this now. My partner has been trying it out.

Is it possible to get the source code? No worries if not.

@akucheruk-vareger
Copy link

I’m working on this either.
There are no reason the method would throw:

mapping (uint256 => bool) public btcTransactions;

I’ll try to prepare a snippet of code(but may be won’t be able to do this today).
Thank you for your help!

@ricmoo ricmoo added investigate Under investigation and may be a bug. on-deck This Enhancement or Bug is currently being worked on. labels May 16, 2018
@ricmoo
Copy link
Member

ricmoo commented May 16, 2018

I think you may have a typo in your ABI or you are targeting an old version of your contract?

Looking at the code on the blockchain there is no method jump destination in the EVM bytecode for 0xbce71fc0, which is the signature for btcTransactions(uint256).

The fact that truffle returns false, is an issue with Web3; it treats exceptions as the default zero value for the type. Try using a value that should return false in Truffle, and I suspect it will also return false.

Let me know if you can verify this.

@akucheruk-vareger
Copy link

I feel you are deadly right.
We have a number of deployments for this contract and accidentally can use a one without this mapping, but trust truffle when check this issue.
I’ll try tomorrow when get to my laptop but I think you are right, especially if there are no signature in the bytecode
why I didn’t try to look there... arrgh :(
Sorry for that and many thanks!

@Kastamarov
Copy link
Author

Thanks!

@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Aug 27, 2018
@ricmoo ricmoo removed the investigate Under investigation and may be a bug. label Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants