【solidity】析构函数(13)

Page content

这篇文章简单的整理了析构函数相关的内容。

1.销毁合约

pragma solidity ^0.4.0;

contract destruct {

    address owner;
    uint public money = 0;

    constructor(){
        owner = msg.sender;
    }

    function increment(){
        money += 10;
    }

    // 销毁当前的合约
    function kill(){
        if (msg.sender == owner) {
            selfdestruct(owner);
        }
    }

}

欢迎大家的意见和交流

email: li_mingxie@163.com