Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.5.1;
- // Our first contract is a faucet!
- contract Faucet {
- event Withdrawal(address indexed to, uint amount);
- event Deposit(address indexed from, uint amount);
- address owner;
- constructor() public{
- owner = msg.sender;
- }
- // Give out ether to anyone who asks
- function withdraw(uint withdraw_amount) public {
- // Limit withdrawal amount
- require(withdraw_amount <= 0.1 ether);
- require(address(this).balance >= withdraw_amount,
- "Insufficient balance in faucet for withdrawal request");
- // Send the amount to the address that requested it
- msg.sender.transfer(withdraw_amount);
- emit Withdrawal(msg.sender, withdraw_amount);
- }
- // Accept any incoming amount
- function () external payable {
- emit Deposit(msg.sender, msg.value);
- }
- //destructor
- function destroy() view public{
- require(msg.sender == owner);
- //selfdestruct(owner);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement