StarkLotto is a decentralized lottery game built on Starknet and Stellar, offering secure and transparent on-chain draws. It uses Cairo smart contracts on Starknet and Rust/Soroban smart contracts on Stellar, with a single unified Next.js frontend that supports both chains.
π Testnet Version: π https://starklotto-eta.vercel.app/
starklotto/
βββ packages/
β βββ snfoundry/ # Cairo smart contracts (Starknet)
β βββ soroban/ # Rust/Soroban smart contracts (Stellar)
β βββ nextjs/ # Unified Next.js frontend (both chains)
- Dual-chain lottery β play on Starknet or Stellar from the same interface.
- Cairo contracts on Starknet: Lottery, ERC20 token (STRKP), Vault, NFT tickets, Randomness.
- Soroban contracts on Stellar: Lottery, StellarPlay token (STLP), Vault β commit-reveal randomness.
- Chain-agnostic frontend β a
ChainAdapterabstraction layer decouples UI from chain-specific logic. - Wallet support β Argent / Braavos (Starknet), Freighter / Albedo (Stellar).
- NFT tickets β each Starknet ticket is minted as an ERC721.
- Progressive prize tiers β 1 match: 1% Β· 2: 4% Β· 3: 10% Β· 4: 15% Β· 5 (Jackpot): 70%.
- PWA-ready frontend with i18n (i18next) and TailwindCSS + DaisyUI.
| Tool | Version |
|---|---|
| Starknet-devnet | v0.4.0 |
| Scarb | v2.11.4 |
| Snforge | v0.41.0 |
| Cairo | v2.11.4 |
| RPC | v0.8.0 |
| Tool | Version |
|---|---|
| Rust | stable (1.78+) |
| stellar-cli | v0.22+ |
| wasm32 target | rustup target add wasm32-unknown-unknown |
| Tool | Version |
|---|---|
| Node.js | LTS (compatible with Next.js 15) |
| Yarn | v3.2.3 |
git clone https://github.com/FutureMindsTeam/starklotto.git
cd starklottoNote: To contribute, branch off
Devbefore making changes:git checkout -b feature/your-feature Dev
yarn install# Starknet (packages/snfoundry/)
cp packages/snfoundry/.env.example packages/snfoundry/.env
# Stellar (packages/soroban/)
cp packages/soroban/.env.example packages/soroban/.env
# Frontend (packages/nextjs/)
cp packages/nextjs/.env.example packages/nextjs/.env.localKey variables for the frontend:
# Starknet
NEXT_PUBLIC_DEVNET_PROVIDER_URL=http://127.0.0.1:5050
NEXT_PUBLIC_SEPOLIA_PROVIDER_URL=
# Stellar
NEXT_PUBLIC_STELLAR_NETWORK=testnet
NEXT_PUBLIC_STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org
NEXT_PUBLIC_STELLAR_SOROBAN_RPC_URL=https://soroban-testnet.stellar.org
NEXT_PUBLIC_STELLAR_LOTTERY_CONTRACT=
NEXT_PUBLIC_STELLAR_TOKEN_CONTRACT=
NEXT_PUBLIC_STELLAR_VAULT_CONTRACT=yarn chainyarn deploy # Deploy (clears previous)
yarn deploy:no-reset # Deploy (keeps previous)yarn startOpen http://localhost:3000.
yarn compileyarn testrustup target add wasm32-unknown-unknownyarn stellar:buildyarn stellar:testyarn stellar:fmt# 1. Set up your Stellar account in stellar-cli
stellar keys generate default --network testnet
# 2. Fund the account (testnet only)
stellar keys fund default --network testnet
# 3. Deploy contracts
yarn stellar:deploy:testnetAfter deploying, copy the contract IDs into packages/nextjs/.env.local:
NEXT_PUBLIC_STELLAR_LOTTERY_CONTRACT=C...
NEXT_PUBLIC_STELLAR_TOKEN_CONTRACT=C...
NEXT_PUBLIC_STELLAR_VAULT_CONTRACT=C...yarn stellar:deploy:mainnet| Contract | Description |
|---|---|
Lottery.cairo |
Draw management, ticket purchase, prize distribution |
StarkPlayERC20.cairo |
Platform token (STRKP) with mint/burn/prize roles |
StarkPlayVault.cairo |
STRK β STRKP conversion with fee management |
LottoTicketNFT.cairo |
ERC721 NFT per ticket |
MockRandomness.cairo |
Randomness oracle integration |
| Contract | Description |
|---|---|
lottery/ |
Draw management with commit-reveal randomness |
token/ |
StellarPlay token (STLP), SEP-0041 compatible |
vault/ |
XLM β STLP conversion with fee management |
The frontend uses a chain-adapter pattern to remain agnostic of the underlying blockchain:
Page / Component
β
useLotteryBuyTickets (unified hook)
β parallel pattern
useBuyTickets useStellarBuyTickets
(Starknet hooks) (Stellar hooks)
β
ChainAdapter interface
β
Starknet contracts Stellar Soroban contracts
Key directories:
| Path | Description |
|---|---|
services/chain-adapter/ |
ChainAdapter interface, Starknet and Stellar adapters |
hooks/scaffold-stark/ |
Starknet-specific hooks |
hooks/scaffold-stellar/ |
Stellar-specific hooks |
hooks/useLottery*.ts |
Unified hooks (chain-agnostic) |
hooks/useChainAdapter.ts |
Assembles the write adapter for the active chain |
context/ChainContext.tsx |
Global chain selector (Starknet / Stellar) |
services/web3/stellar/ |
Stellar wallet connectors and Soroban RPC helpers |
contracts/deployedContracts.ts |
Auto-generated Starknet contract addresses |
contracts/stellarContracts.ts |
Stellar contract IDs (from env vars) |
- Fork the repository.
- Create a branch off
Dev:
git checkout -b feature/new-feature Dev- Make your changes and commit:
git commit -m "feat: description of change"- Push and open a Pull Request targeting
Dev.
- Discord: FutureMinds Community
- X: @futureminds_7
- Telegram: Starklotto Contributors
This repo uses Yarn as package manager.
| Command | Description |
|---|---|
yarn install |
Install all JS dependencies |
yarn start |
Start the Next.js dev server |
yarn format |
Format all code (Cairo + TypeScript) |
yarn format:check |
Check formatting without writing changes |
yarn next:lint |
Run Next.js linter |
yarn next:check-types |
TypeScript type check |
yarn prepare |
Install Husky git hooks |
| Command | Description |
|---|---|
yarn compile |
Compile Cairo contracts with Scarb |
yarn test |
Run Snforge test suite |
yarn chain |
Start local Starknet devnet |
yarn deploy |
Deploy contracts (clears previous) |
yarn deploy:no-reset |
Deploy contracts (keeps previous) |
yarn verify |
Verify contracts with Walnut |
| Command | Description |
|---|---|
yarn stellar:build |
Compile Soroban contracts to WASM |
yarn stellar:test |
Run Soroban unit tests |
yarn stellar:fmt |
Format Rust code |
yarn stellar:fmt:check |
Check Rust formatting without writing |
yarn stellar:deploy:testnet |
Deploy contracts to Stellar Testnet |
yarn stellar:deploy:mainnet |
Deploy contracts to Stellar Mainnet |
| Command | Description |
|---|---|
yarn start |
Start development server on localhost:3000 |
yarn test:nextjs |
Run Vitest test suite |
yarn vercel |
Deploy to Vercel |
yarn vercel:yolo |
Force deploy to Vercel (ignoring errors) |