1

Are event emitted when a contract calls selfdestruct?

2

I just tested it, and the events do get emitted. See:

pragma solidity ^0.4.17;

contract Test {
    address owner;

    constructor() public {
        owner = msg.sender;
    }

    event dying(bool dead);

    function kill() public {
        emit dying(true);
        selfdestruct(owner);
    }
}
  • the events are emitted becase you use emit keyword, not because you are selfestructing a contract – Nulik Aug 30 '18 at 17:28
0

In the following example, the event is not emitted/logged:

pragma solidity ^0.4.17;

contract Test {
    address owner;

    constructor() public {
        owner = msg.sender;
    }

    event dying(bool dead);

    function kill() public {
        selfdestruct(owner);
        emit dying(true);
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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