TypeError: Invalid type for argument in function call. Invalid implicit conversion from contract spsTokenSale to address requested. require(tokenContract.balanceOf(this)>= _numberOfTokens);

Invalid type for argument in function call. Invalid implicit conversion from address to address payable requested. selfdestruct(admin);

3

There are 3 answers

0
ska On

You need to provide code for better understanding. May be you have not declared address 'payable' that's why you are facing this "Invalid implicit conversion from address to address payable requested" issue.

As in latest version of solidity you must declare address also as payable if it will be receiving/transferring ethers.

If the issue is in truffle not in remix you can check for the version of solidity in truffle box. As it's most likely version mismatch issue.

0
Spandan Joshi On

If you are using solidity version > 7 then your syntex is not correct.Use address(this) if you want to access your contract address & use selfdestruct(payable(admin)); if you want to destroy your smart contract .

require(tokenContract.balanceOf(address(this))>= _numberOfTokens);
selfdestruct(payable(admin));
0
Seng Wee On

I saw the solution to this question in another forum. The compiler requires you to explicitly declare the type of the token address.

Instead of using tokenContract.balanceOf(this), change it to tokenContract.balanceOf(address(this)).

Refer to this link for more details - https://ethereum.stackexchange.com/questions/64868/typeerror-invalid-type-for-argument-in-function-call-invalid-implicit-conversi/64869