function endSale() public {
require(msg.sender == admin);
require(tokenContract.transfer(admin, tokenContract.balanceOf(address(this))));
admin.transfer(address(this).balance);
}
}
error line ---> admin.transfer(address(this).balance);
can someone help me with this thank you
Address literals have the type
addressinstead ofaddress payable. They can be converted toaddress payableby using an explicit conversion, e.g.payable(0xdCad3a6d3569DF655070DEd06cb7A1b2Ccd1D3AF).
Source: Solidity v0.8.0 Breaking Changes
What it means, is that since Solidity 0.8, address is not payable by default. And if you want to send it native currency, you need to cast it to payable first.
Example:
payable(admin).transfer(address(this).balance);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With