Events

呼叫 selfdestruct() 時是否會發出事件?

  • September 10, 2018

合約呼叫 selfdestruct 時是否會發出事件?

我剛剛對其進行了測試,並且確實發出了事件。看:

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);
   }
}

在以下範例中,未發出/記錄事件:

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);
   }
}

引用自:https://ethereum.stackexchange.com/questions/57759