1

Using Web3to execute transactions, and getting the following error:

Unhandled Rejection (TypeError): param.map is not a function Uncaught (in promise) TypeError: param.map is not a function at ABICoder.push../node_modules/web3-eth/node_modules/web3-eth-abi/lib/index.js.ABICoder.formatParam

Here is the snippet of code:

const detectEth = async () => {
    if (window.ethereum) {
      window.web3 = new web3(window.ethereum);
      await window.ethereum.enable()
    }
    else if (window.web3) {
      window.web3 = new web3(window.web3.currentProvider);
    }
    else {
      window.alert('Non-Ethereum browser detected. You should consider trying MetaMask!')
    }
  };

const mint = async () => {
    detectEth();

    const web3 = window.web3;

    const contract = new web3.eth.Contract(NFT_ABI, NFT_CONTRACT_ADDRESS, { gasLimit: "1000000" });

// This function works well
    const mintFees = await nftContract.methods.mintFees().call({
      from: accountAddress,
      to: NFT_CONTRACT_ADDRESS
    });

// ERROR coming from this line
    contract.methods.claim(index, hash, proof, id).send({
      from: accountAddress,
      value: mintFees
    }, (error, transactionHash) => {
        if (error) {
          console.log('In Error');
          console.log(error);
          hideSpinner();
        }
      });
}

Thanks for helping.

3 Answers 3

1

The issue was having undefined params.

2
  • 1
    Do you mean that some of the call parameters contract.methods.claim(index, hash, proof, id) were undefined?
    – Ismael
    Aug 15, 2021 at 17:13
  • Which of the params was undefined?
    – Layinka
    Jan 29, 2022 at 10:15
0

Faced this same error myself.

Basically, one of the parameters here - index, hash, proof, id - should be passed in as an array. Check the type of input in the ABI or the block explorer and it'll show accordingly.

0

The claim function was expecting an array in one of it's arguments, check the contract which one was requesting array, if its the id as example change contract.methods.claim(index, hash, proof, id) to contract.methods.claim(index, hash, proof, [id])

Your Answer

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

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