0

What actually happens after self destruct function is called ?

//SPDX-License-Identifier:MIT
pragma solidity 0.8.7;
contract PiggyBank{
    event Deposit(uint amount);
    event Withdraw(uint amount);
    receive() external payable {
        emit Deposit(msg.value);
    }
    address public owner = msg.sender;
    function withdraw() external{
        require(msg.sender ==owner ,"not owner");
        emit Withdraw(address(this).balance);
        selfdestruct(payable(msg.sender));
    }
}

In the above code if I destruct the contract then also I am able to access the functions of Smart Contract.What about the events I have emitted on Blockchain?

1 Answer 1

0

event will not be deleted. when you call selfdestruct(owner), byte code in that contract address is deleted but events are not stored in the byte code.

events are stored in the logsBloom which is stored in the header of each block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.