Solidity – Fixing TypeError: Invalid Type for Argument in Function Call

solidity

 constructor(string memory enterOrganizationName) public {
    owner = msg.sender;
    status = true;
    addUser(0, "", "");
    addUser(owner, 'Creator and Owner of Smart Contract', "");
    organizationName = enterOrganizationName;
    numberOfUsers = 0;
    addEndorsee(0, "");
    numberOfEndorsees = 0;
}

giving below error.

TypeError: Invalid type for argument in function call. Invalid implicit conversion from int_const 0 to address requested.
        addUser(0, "", "");
                ^

I'm still new in Ethereum platform so I'm not sure what that error means.

Best Answer

It seems the type of the first argument of your addUser function is an address. If you want to initialize it with the "address 0", you have to explicitly convert it like that : addUser(address(0), "", "")

Related Topic