[Ethereum] Invalid parameters: must provide an Ethereum address. Code -32602

web3js

Here is the transaction I am trying to send using web3.eth.sendTransaction:

{
   data: "0x11a861a700...."
   from: "0x8ccb1711ea5562596f146608fdcf27ccf0d5429c"
   gas: "0x6b540"
   gasPrice: "0xaf16b1bb3"
   nonce: "0x0"
   to: "0x7113dd99c79aff93d54cfa4b2885576535a132de"
   value: "0x38d7ea4c68000"
}

It keeps getting back with the following message:

MetaMask – RPC Error: Invalid parameters: must provide an Ethereum address.

Is there some kind of other form this TX should be fed to web3?

edit. This transaction was generated by https://1inch.exchange/#/api using the following GET request:

https://api.1inch.exchange/v1.1/swap?fromTokenSymbol=ETH&toTokenSymbol=BAT&amount=2000000000000000&fromAddress=0x8ccb1711ea5562596f146608fdcf27ccf0d5ZYZc&slippage=1&disableEstimate=true

edit. XYZ addresses are just placeholders.

Best Answer

I had the same issue, and it was not about specifying a wrong address in terms of format (incorrect hexadecimal structure), but putting one of the addresses in the wrong place within the parameters of the transaction. In my case:

    const txParams = {
        from: fromAccount,  // The error was here!
        to: toAccount,
        data: encodedData,
        value: 0,
        chainId: chainId,
    };

When calling the function from a contract, I incorrectly put the contract address in the 'from' instead of putting the caller address.

Therefore, I assume this issue should be normally addressed by reviewing that 'from' and 'to' addresses are correctly set.

Related Topic