Skip to content

mdzor/TON-lottery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TON Lottery Smart Contract

Blueprint Tests

A decentralized lottery system on TON blockchain where users can participate by depositing TON coins.

Features

  • 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

Contract Methods

Internal Messages

  • op=1: Deposit TON (min 1 TON)
  • op=2: Distribute prize (owner only)
  • op=3: Transfer ownership (owner only)

Get Methods

  • get_owner(): Current owner address
  • get_total_deposited(): Total TON in pool
  • get_total_tickets(): Total tickets issued
  • get_user_chances(address): User's ticket count

Usage Example

// 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()
});

Todo

  • Handle random number generation within the contract instead of owner input
  • Make minimum deposit amount configurable by owner
  • Add pause/unpause functionality for deposits

About

simple lottery built on TON

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published