solidity 可以通过调用 selfdestruct
从区块链中删除合约;
selfdestruct
将合约中存储的所有剩余 Ether 发送到指定地址。
弱点:恶意合约可以使用 selfdestruct
来强制向任何合约发送以太币。
一个模拟业务合约 EtherGame
一个攻击合约 Attack
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;contract EtherGame {uint public targetAmount = 7 ether;address public winner;function deposit() public payable {require(msg.value == 1 ether, "You can only send 1 Ether");uint balance = address(this).bal
上一篇:高等数学笔记(下)