A decentralized lottery system on TON blockchain where users can participate by depositing TON coins.
- Users deposit TON (1 TON = 1 ticket)
- Automatic chance calculation based on deposit amount
- Owner-controlled prize distribution
- Random winner selection based on weighted chances
- Full prize pool distribution to winner
- Ownership transfer capability
op=1
: Deposit TON (min 1 TON)op=2
: Distribute prize (owner only)op=3
: Transfer ownership (owner only)
get_owner()
: Current owner addressget_total_deposited()
: Total TON in poolget_total_tickets()
: Total tickets issuedget_user_chances(address)
: User's ticket count
// Deposit 1 TON
await contract.send({
value: toNano('1'),
body: beginCell().storeUint(1, 32).endCell()
});
// Distribute prize (owner only)
await contract.send({
value: toNano('0.05'),
body: beginCell()
.storeUint(2, 32)
.storeUint(ticketNumber, 32)
.endCell()
});
- Handle random number generation within the contract instead of owner input
- Make minimum deposit amount configurable by owner
- Add pause/unpause functionality for deposits