Introduction to Solidity - Code Your First Coin [PART 2]

I encountered some error in an attempt to mint my Coin during “Introduction to Solidity - Code Your First Coin [PART 2]” tutorial:

transact to Coin.mint errored: Error encoding arguments: Error: invalid address (argument=“address”, value=“0x5B38Da6a701c568545dCfcB03FcB875f56beddC4. 100”, code=INVALID_ARGUMENT, version=address/5.1.0) (argument=null, value=“0x5B38Da6a701c568545dCfcB03FcB875f56beddC4. 100”, code=INVALID_ARGUMENT, version=abi/5.1.2)

Could you clarify, why I got the Error: invalid address?
Thanks!

1 Like

please share your code with us :slight_smile:

// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;

contract Coin {
address public minter;
mapping (address => uint) public balances;

event Sent(address from, address to, uint amount);


constructor() {
    minter = msg.sender;
}

function mint(address receiver, uint amount) public{
    require(msg.sender == minter);
    require(amount < 1e60);
    balances[receiver] += amount;
    
}

function send(address receiver, uint amount) public {
    require(amount <= balances [msg.sender], "Insufficient balance");
    balances[msg.sender] -= amount;
    balances[receiver] += amount;
    emit Sent(msg.sender, receiver, amount);
}

}

ok, I see where is the problem. Your code is fine, just successfully tested it in Remix.
But when you pass in the address and amount, you have to separate the two parameters with a , not with a . !!
WRONG:

0x5B38Da6a701c568545dCfcB03FcB875f56beddC4. 100

CORRECT

0x5B38Da6a701c568545dCfcB03FcB875f56beddC4, 100

works just fine! thanks a lot :slight_smile:

1 Like

My pleasure, keep on :slight_smile:

I am also having error " Error encoding arguments: " executing this code in remix for airdrop
here is my code. What is wrong, i think something is wrong the values in am inputting into ERC721 fied?

// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;

interface IERC20 {

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

function balanceOf(address account) external view returns (uint256);

function allowance(address owner, address spender) external view returns (uint256);

}

interface IERC721 {

function safeTransferFrom(address from, address to, uint256 tokenId) external;

}

interface IERC1155 {

function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data) external;

}

contract BulkAirdropzz {

function bulkAirdropERC20(IERC20 _token, address[] calldata _to, uint256[] calldata _value) public {

require(_to.length == _value.length, "Receivers and amounts are different length");

for (uint256 i = 0; i < _to.length; i++) {

  require(_token.transferFrom(msg.sender, _to[i], _value[i]));

}

}

function bulkAirdropERC721(IERC721 _token, address[] calldata _to, uint256[] calldata _id) public {

require(_to.length == _id.length, "Receivers and IDs are different length");

for (uint256 i = 0; i < _to.length; i++) {

  _token.safeTransferFrom(msg.sender, _to[i], _id[i]);

}

}

function bulkAirdropERC1155(IERC1155 _token, address[] calldata _to, uint256[] calldata _id, uint256[] calldata _amount) public {

require(_to.length == _id.length, "Receivers and IDs are different length");

for (uint256 i = 0; i < _to.length; i++) {

  _token.safeTransferFrom(msg.sender, _to[i], _id[i], _amount[i], "");

}

}

}