[FAQ] Solidity 合约销毁 ?

 

仅创建者可以销毁合约的示例:

    address public owner;

    // When deploy contract
    constructor() public {
        owner = msg.sender;
    }


    function destroyContract() external onlyOwner {
        selfdestruct(msg.sender);
    }

    modifier onlyOwner() {
        require(owner == msg.sender, 'You are not owner');
        _;
    }

 

Ref:https://solidity.readthedocs.io/en/v0.6.3/solidity-by-example.html#the-full-contract

Link:https://www.cnblogs.com/farwish/p/12456369.html

你可能感兴趣的:([FAQ] Solidity 合约销毁 ?)