[Ethereum] How to fix Error: invalid address

contract-debuggingerrormetamaskremix

I am trying to run the smart contract listed in the documentation here https://docs.soliditylang.org/en/v0.8.7/introduction-to-smart-contracts.html#subcurrency-example

    // Sends an amount of newly created coins to an address
    // Can only be called by the contract creator
    function mint(address receiver, uint amount) public {
        require(msg.sender == minter);
        balances[receiver] += amount;
    }

But every time I try to execute the mint function, it fails with the following error:

transact to Coin.mint errored: Error encoding arguments: Error:
invalid address (argument="address", value="1000000",
code=INVALID_ARGUMENT, version=address/5.4.0) (argument=null,
value="1000000", code=INVALID_ARGUMENT, version=abi/5.4.0)

I am using the Remix IDE integrated with my MetaMask.

Any idea why and how to fix it?

Best Answer

As per the error message and logs it looks like you're passing invalid arguments ---

(argument="address", value="1000000", code=INVALID_ARGUMENT, version=address/5.4.0)

The address argument expects an address type argument, but you're passing a number (1000000) instead.

(argument=null, value="1000000", code=INVALID_ARGUMENT, version=abi/5.4.0)

The second parameter should have had an argument type "amount" but it appears to be null.

Looks like you need to double-check the parameter-argument pairs that you're passing.