Guest User

Untitled

a guest
Jan 23rd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. pragma solidity ^0.4.0;
  2.  
  3. contract buytickets{
  4. address buyer;
  5. uint public tickets;
  6. uint constant price = 1 ether;
  7.  
  8. mapping (address => uint) public ticketsbought;
  9.  
  10. function buytickets() public {
  11. tickets = 100;
  12. buyer = msg.sender;
  13. }
  14.  
  15. function BuyTickets(uint amount) public payable{
  16. if(amount>tickets || msg.value != (amount*price)){
  17. throw;
  18. }
  19. ticketsbought[msg.sender] += amount;
  20. tickets -= amount;
  21.  
  22. if(tickets == 0){
  23. selfdestruct(buyer);
  24. }
  25. }
  26.  
  27. function () public payable{
  28. BuyTickets(1);
  29. }
  30.  
  31. }
Add Comment
Please, Sign In to add comment