// You'll have to handle balances yourself, lets assume you have them in an object like the one below which is an example. var balances = { "cainy393" : 0.7, "raoulbtc" : 2.1, "admin" : 1.2 }; function startANewRaffle(){ var ticketsRemaining = 1000; var ticketPrice = 0.01; // In mBTC var prize = 10; // In mBTC var tickets = []; // Announce a new raffle has started and display the above variables. } function buyTickets(user, numberOfTickets){ if(numberOfTickets <= ticketsRemaining && balances[user] >= ticketPrice * numberOfTickets){ ticketsRemaining = ticketsRemaining - numberOfTickets; for(var i=0;i