Welcome to the future of decentralized fantasy sports! This project is a fully on-chain fantasy sports marketplace built on the high-performance Stellar network using Soroban smart contracts.
By utilizing Stellar's ultra-low fees, sub-second consensus times, and Soroban's robust Rust-based smart contract environment, this platform enables completely transparent, trustless, and decentralized fantasy contest creation, entry fee collection, and reward distribution.
The core of this marketplace is a secure, warning-free, and thoroughly tested Soroban smart contract written in Rust. It serves as a decentralized game master that:
- Creates Contests: Managers/creators can spin up fantasy contests with specific entry fees, token assets (e.g., USDC, XLM wrapped tokens), and descriptive metadata.
- Collects Entry Fees: Players join contests trustlessly. The contract pulls entry fees from the players' accounts and holds them securely in its own address as an escrow prize pool.
- Declares Winners & Distributes Rewards: Once the real-world sports events finish, the creator submits the winner. The smart contract immediately transfers the entire prize pool escrow directly to the winner's Stellar wallet address.
The project follows a standard Soroban workspace layout:
dream11/
├── Cargo.toml # Workspace cargo configuration
├── README.md # Project documentation and developer guide
└── contracts/
└── fantasy_sports/
├── Cargo.toml # Smart contract cargo dependencies
└── src/
├── lib.rs # Core smart contract code
└── test.rs # Complete test suite (100% pass)
The contract implements four fundamental functions:
| Function | Access | Description |
|---|---|---|
create_contest |
Creator Signature Required | Initializes a new contest by defining its unique ID, entry fee, details, and the token used. |
join_contest |
Participant Signature Required | Escrows the entry fee from the participant into the contract and adds it to the contest's prize pool. |
declare_winner |
Creator Signature Required | Resolves the contest by validating the winner and distributing 100% of the escrowed pool to their address. |
get_contest |
Public Getter | Returns the current state (prize pool, participants, status) of any contest. |
Ensure you have the following installed on your machine:
- Rust & Cargo (v1.75+)
- Target WASM build chain:
rustup target add wasm32-unknown-unknown
- Stellar CLI (formerly Soroban CLI):
cargo install --locked stellar-cli --features opt
The smart contract includes a comprehensive test suite in contracts/fantasy_sports/src/test.rs which compiles cleanly and tests full flows, edge cases, and safety checks.
Run the tests using the Makefile:
make testTo compile the contract into optimized, deployable WebAssembly byte code:
make buildThe compiled contract will be saved at:
target/wasm32-unknown-unknown/release/fantasy_sports.wasm
First, configure your Stellar CLI testnet identity:
stellar keys generate --network testnet aliceDeploy the compiled WASM file:
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/fantasy_sports.wasm \
--source alice \
--network testnetThis will return a Contract ID (e.g., CD...). Save this address!
To create a contest via CLI:
stellar contract invoke \
--id <YOUR_CONTRACT_ID> \
--source alice \
--network testnet \
-- \
create_contest \
--contest_id 1 \
--creator alice \
--token <USDC_TOKEN_ADDRESS> \
--entry_fee 10000000 \
--details "Match-Week-1-Premier-League"We are building the premier decentralized home for fantasy sports and we would love your help!
Please see our full Contributing Guide for detailed instructions on how to get started.
Please also review our Code of Conduct before participating to help us keep our community open and inclusive.
Let's make fantasy sports transparent and fun together! ⚽🏀🏏