Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. pragma solidity ^0.5.1;
  2.  
  3. // Our first contract is a faucet!
  4. contract Faucet {
  5. event Withdrawal(address indexed to, uint amount);
  6. event Deposit(address indexed from, uint amount);
  7. address owner;
  8.  
  9. constructor() public{
  10. owner = msg.sender;
  11. }
  12.  
  13. // Give out ether to anyone who asks
  14. function withdraw(uint withdraw_amount) public {
  15.  
  16. // Limit withdrawal amount
  17. require(withdraw_amount <= 0.1 ether);
  18. require(address(this).balance >= withdraw_amount,
  19. "Insufficient balance in faucet for withdrawal request");
  20. // Send the amount to the address that requested it
  21. msg.sender.transfer(withdraw_amount);
  22. emit Withdrawal(msg.sender, withdraw_amount);
  23. }
  24.  
  25. // Accept any incoming amount
  26. function () external payable {
  27. emit Deposit(msg.sender, msg.value);
  28. }
  29.  
  30. //destructor
  31. function destroy() view public{
  32. require(msg.sender == owner);
  33. //selfdestruct(owner);
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement