This is a Cosmos App project bootstrapped with create-cosmos-app.
First, install the packages and run the development server:
yarn && yarn devOpen http://localhost:3000 with your browser to see the result.
To point the application to your lottery contract, you need to modify the configuration in config/lottery.ts:
// config/lottery.ts
export const FREEDOM_LIST: string[] = [
'your-contract-address-here',
];
export const PRIMARY_RUNNING_GAME = FREEDOM_LIST[0];Replace 'your-contract-address-here' with your deployed contract address. The PRIMARY_RUNNING_GAME constant is used throughout the application to reference the active lottery contract.
You can also add multiple contract addresses to the FREEDOM_LIST array if you want to support multiple lotteries. The first address in the list will be used as the primary game.
The smart contract implementation for this lottery system can be found in the cw-sphinx repository. This repository contains the CosmWasm smart contract code that powers the lottery functionality.
Sphinx UI is a lottery application built on the Cosmos blockchain. The application consists of two main user interfaces:
-
Player Interface (
/)- Home page showing the current lottery state
- Requires wallet connection to interact
- Displays game state and play button when connected
- Players can view active lotteries and participate
-
Admin Interface (
/admin)- Create new lottery contracts (
/admin/create) - Manage existing lotteries (
/admin/[id]) - Monitor lottery states and execute draws
- Create new lottery contracts (
-
Play Interface (
/play/[id])- Dedicated page for participating in specific lotteries
- Purchase tickets and view lottery details
- Claim winnings when applicable
- Connect wallet on the home page
- View active lottery state
- Click play button to participate
- Purchase tickets using the specified token denomination
- Wait for lottery completion
- Claim winnings if selected as winner
- Navigate to admin portal
- Create new lottery with parameters:
- Contract Owner address
- Ticket Cost Amount
- Token Denomination
- Duration
- House Fee
- Monitor lottery state
- Execute lottery draw when in CHOOSING state
- Track winner and claim status
The lottery contract operates in three states:
- OPEN: The lottery is accepting ticket purchases
- CHOOSING: The lottery is closed for purchases and waiting for admin to execute the draw
- CLOSED: The lottery has been executed and has a winner
Players can:
- Purchase tickets while the lottery is OPEN
- Claim their winnings if they are the winner and the lottery is CLOSED