Skip to content

DaevMithran/chain11

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Chain11

A fully decentralized fantasy sports platform built for EVM with Chainlink Functions for trustless score oracle and settlement.

Solidity Base Chainlink License


🏏 Features

  • Create Contests β€” Anyone can create a fantasy contest for any cricket match
  • Join & Submit Teams β€” Pick 11 players, captain (2Γ—), vice-captain (1.5Γ—)
  • Automatic Settlement β€” Chainlink fetches scores and calculates winners off-chain
  • Decentralized Prizes β€” Top 3 or Top 10 winners split the pool
  • Gas Optimized β€” Batch operations, compressed contracts, <24KB each
  • Scalable β€” Handles 600+ participants per contest

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Chain11.sol (22KB)                  β”‚
β”‚  β€’ Contest management                            β”‚
β”‚  β€’ Team validation (batched)                     β”‚
β”‚  β€’ Prize distribution                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
                    β–Ό calls
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚            Chain11Oracle.sol (19KB)              β”‚
β”‚  β€’ Chainlink Functions integration               β”‚
β”‚  β€’ Match initialization (squad data)             β”‚
β”‚  β€’ Score fetching (fantasy points)               β”‚
β”‚  β€’ Settlement calculation (off-chain)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
                    β–Ό requests
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Chainlink DON                       β”‚
β”‚  β€’ Fetches match data from Cricket API           β”‚
β”‚  β€’ Fetches final scores                          β”‚
β”‚  β€’ Calculates winners (batched RPC calls)        β”‚
β”‚  β€’ Returns top K winners                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Installation

Prerequisites

node >= 18.0.0
npm >= 9.0.0

Setup

# Clone repository
git clone https://github.com/DaevMithran/chain11.git
cd chain11

# Install dependencies
npm install

# Copy environment template
cp .env.example .env

Environment Variables

# .env
PRIVATE_KEY=                              # Deployer wallet private key
BASE_RPC_URL=https://mainnet.base.org     # Base mainnet RPC
BASESCAN_API_KEY=                         # For contract verification

# Chainlink Functions
CHAINLINK_ROUTER_ADDRESS=0xf9B8fc078197181C841c296C876945aaa425B278
CHAINLINK_DON_ID=0x66756e2d626173652d6d61696e6e65742d310000000000000000000000000000
CHAINLINK_SUBSCRIPTION_ID=                # Your Chainlink subscription ID

# Contract addresses (set after deployment)
ORACLE_ADDRESS=
CORE_ADDRESS=

πŸš€ Quick Start

1. Compile Contracts

npx hardhat compile

2. Run Tests

# All tests
npx hardhat test

# With gas reporting
REPORT_GAS=true npx hardhat test

3. Deploy to Testnet (Base Sepolia)

# Create Chainlink subscription first:
# https://functions.chain.link (Base Sepolia)

# Deploy Oracle
npx hardhat run scripts/deploy-oracle.ts --network base-sepolia

# Deploy Core
export ORACLE_ADDRESS=0x...
npx hardhat run scripts/deploy-core.ts --network base-sepolia

# Link contracts
export CORE_ADDRESS=0x...
npx hardhat run scripts/link-contracts.ts --network base-sepolia

4. Verify Contracts

npx hardhat verify --network base-sepolia $ORACLE_ADDRESS \
  $CHAINLINK_ROUTER_ADDRESS \
  $CHAINLINK_DON_ID \
  $CHAINLINK_SUBSCRIPTION_ID

npx hardhat verify --network base-sepolia $CORE_ADDRESS \
  $ORACLE_ADDRESS

Expected gas costs:

  • Create contest: 200k gas ($0.04)
  • Join & submit team: 59k gas ($0.01) β€” optimized with batch validation
  • Settlement: 300k gas ($0.06) β€” constant, regardless of participants

πŸ’° Tokenomics

Fees

Contest creation: 0.01 ETH
Team entry:       0.01 ETH
Platform fee:     10% of all entries

Prize Distribution

3-9 participants (Top 3):

1st: 50% | 2nd: 30% | 3rd: 20%

10+ participants (Top 10):

1st: 30% | 2nd: 15% | 3rd: 10% | Ranks 4-10: 5% each

Chainlink Costs (per contest)

Match initialization: ~0.3 LINK  (~$1.50)
Score fetching:       ~0.3 LINK  (~$1.50)
Settlement:           ~0.3 LINK  (~$1.50)
Total:                ~0.9 LINK  (~$4.50)

πŸ› οΈ Tools & Technologies Used

Category Tool Version Purpose
Language Solidity 0.8.28 Smart contracts
Framework Hardhat 2.22+ Development environment
Library Viem 2.x Contract interactions
Oracle Chainlink Functions 1.0.0 Off-chain data & compute
Build Terser Latest JS minification
Optimizer Via IR Built-in Code optimization

πŸ“ License

MIT License - see LICENSE for details.

πŸ—ΊοΈ Roadmap

  • Core contract implementation
  • Chainlink Functions integration
  • Test suite
  • Frontend dApp (React)
  • Mobile app (React Native)
  • Multi-sport support

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors