Guest User

Untitled

a guest
Nov 17th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. pragma solidity 0.4.18;
  2.  
  3. contract ForceEther {
  4.  
  5. bool youWin = false;
  6.  
  7. // due to the throwing fallback function normally the contract cannot receive ether
  8. // if a contract selfdestructs with this contract as a target, the fallback function
  9. // does not get called => this.balance > 0 and thus the attacker wins
  10. function onlyNonZeroBalance() {
  11. require(this.balance != 0);
  12. youWin = true;
  13. }
  14. // throw if any ether is received
  15. function() payable {
  16. revert();
  17. }
  18.  
  19. }
Add Comment
Please, Sign In to add comment