function endSuply() public {
require(msg.sender == admin,"only admin can end the token sale");
require(tokenContract.transfer(admin, tokenContract.balanceOf(address(this))),"balance not transferring");
selfdestruct(admin);
}
here admin is a state variable declared as address admin;
But the error pops up and doesn't compile !
I just need to disable the contract, how can it be done ?
Best Answer
Elsewhere in the contract, find
address admin;
and declare it asaddress payable admin;
.Alternatively,
selfdestruct(msg.sender);
becauserequire(msg.sender == admin);
ensures they are the same andmsg.sender
should bepayable
.A word of caution.
selfdestruct
is an inelegant way to stop a contract and could lead to non-trivial problems. Consider using Open Zeppelin Pausable.sol instead.Hope it helps.