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

    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');
        _;
    }

 

Refer:你会销毁Solidity合约吗

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

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

相关文章:

  • 2021-04-08
  • 2022-02-17
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
  • 2021-12-12
  • 2021-06-22
  • 2022-12-23
猜你喜欢
  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
  • 2021-04-03
  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案