基于以太坊的智能合约开发教程Solidity 合约的销毁
pragma solidity ^0.4.0;
contract destory{
uint public money = 100;
address public owner;
constructor() public{
owner = msg.sender;
}
function increaseMoney() public{
money += 100;
}
modifier onlyOwner{
// 判断合约的调用者是否等于合约的拥有者
require(msg.sender == owner);
_;
}
function destoryContract() public onlyOwner{
selfdestruct(owner); // 执行此函数之后,当前合约已经被销毁 合约者地址以及变量全部被销毁
}
}