Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.0;
- contract buytickets{
- address buyer;
- uint public tickets;
- uint constant price = 1 ether;
- mapping (address => uint) public ticketsbought;
- function buytickets() public {
- tickets = 100;
- buyer = msg.sender;
- }
- function BuyTickets(uint amount) public payable{
- if(amount>tickets || msg.value != (amount*price)){
- throw;
- }
- ticketsbought[msg.sender] += amount;
- tickets -= amount;
- if(tickets == 0){
- selfdestruct(buyer);
- }
- }
- function () public payable{
- BuyTickets(1);
- }
- }
Add Comment
Please, Sign In to add comment