0

I call to a method that returns two contract addresses, like this, where method is the method object taken from the ABI (triple-checked that already):

web3.eth.call(
    {
        from: account,
        to: contract,
        data: web3.eth.abi.encodeFunctionCall(method, [])
    },
    "latest",
    callback
)

For all the methods I call that return a single value, everything works fine. But with this one, which returns two values, it seems to be something wrong.
I receive the following result: 0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000019434f4e545241545f494e41435449462f5452414e534645524500000000000000

And, when trying to decode it :

web3.eth.abi.decodeParameters([{"internalType": "contract MyData","name": "dat","type": "address"},{"internalType": "contract Data","name": "_dat","type": "address"}],"0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000019434f4e545241545f494e41435449462f5452414e534645524500000000000000")

The result is:

{
  '0': '0x0000000000000000000000000000000000000000',
  '1': '0x0000000000000000000000000000000000000000',
  __length__: 2,
  dat: '0x0000000000000000000000000000000000000000',
  _dat: '0x0000000000000000000000000000000000000000'
}

I also tried with

web3.eth.abi.decodeParameters(["address","address"],"0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000019434f4e545241545f494e41435449462f5452414e534645524500000000000000")

which gives me

{
  '0': '0x0000000000000000000000000000000000000000',
  '1': '0x0000000000000000000000000000000000000000',
  __length__: 2
}

The expect result should be :

{
  '0': '0xEed7569548df9BAD3D770D1B7767B752698449ee',
  '1': '0xC7D9037067E161E9E9d20Cdab3BCA0ba0c9a97ea
',
  __length__: 2,
  dat: '0xEed7569548df9BAD3D770D1B7767B752698449ee',
  _dat: '0xC7D9037067E161E9E9d20Cdab3BCA0ba0c9a97ea
'
}

Can someone point me if there is something wrong in the decode function, or in the call itself ?
Should I maybe convert the returned string in some way before calling abi.decodeParameters() ?

Edit:

I was using web3js v1.2.7.
I upgraded to v1.2.9, and now, there is an error thrown apparently from the decodeParameters method:

dat: value out of range (argument="value", value=20, code=INVALID_ARGUMENT, version=bytes/5.0.2)
2
  • The first 4 bytes from the output look like method's signature Error(string). Are you testing against geth? There is/was an issue between geth/web3 in the case a call to a view function reverts with a message (github.com/ethereum/web3.js/pull/3571). It seems to be fixed in github but it hasn't been released yet. – Ismael Jul 12 '20 at 23:06
  • 1
    I'm testing this on ganache-cli for now. Thanks for the clues. I'll investigate further. – FabioB Jul 13 '20 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.