1

I'm trying to call using web3.js a read-only methods, but I'm having the following error:

Error: invalid type (argument="type", value="s", code=INVALID_ARGUMENT, version=abi/5.7.0)  

This is the code I use to call the method:

signedContract.methods.getEnabledCurrencies().call().then(console.log)

While the following is the ABI of my method:

 {  type: 'function',
    name: 'getEnabledCurrencies',
    constant: true,
    stateMutability: 'view',
    payable: false,
    inputs: [],
    outputs: [ [Object] ]
  }

The function on the smart contract is the following:

function getEnabledCurrencies() public view returns (string[] memory) {
    return currencyNames;
}

I can use the same signedContract object to call state changing methods without any problems.

2
  • Which compiler version?
    – matank001
    Oct 8, 2022 at 8:50
  • do you mean solc? Then it's 0.8.4
    – xcsob
    Oct 8, 2022 at 8:58

1 Answer 1

1

Try changing outputs in the ABI to:

"outputs": [
    {
        "internalType": "string[]",
        "name": "",
        "type": "string[]"
    }
]
3
  • It worked. Can you provide me an explanation of this? I'll accept your question
    – xcsob
    Oct 8, 2022 at 9:41
  • Well, I don’t know what generates your ABI, for me this was the output and it seemed more correct than the one you posted. I use truffle.
    – matank001
    Oct 8, 2022 at 9:59
  • I generate it using ethers.js. In fact I've problems only using web3 not ethers.js. Maybe that's could explain the problem.
    – xcsob
    Oct 8, 2022 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.