1
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 ?

5

Elsewhere in the contract, find address admin; and declare it as address payable admin;.

Alternatively, selfdestruct(msg.sender); because require(msg.sender == admin); ensures they are the same and msg.sender should be payable.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.