尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證製作者的介紹僅有上面的一句話。 更多詳情請閱讀儲存庫 README。 儲存庫 README ↗
正在載入完整 README。
檢視完整 README ↗FantasyXI is an open-source, non-custodial fantasy football platform built on Stellar Testnet and Soroban smart contracts, integrated with live Fantasy Premier League (FPL) data.
Managers assemble squads, compete in custom multi-gameweek leagues, and deposit entry fees directly into a trustless Soroban escrow smart contract. When competition concludes, prize pools (95% distributed 60/30/10 with a 5% platform fee) are settled and disbursed directly on-chain with zero counterparty risk and zero lost cents.
flowchart TB
subgraph Client Layer
Browser[User Browser / Next.js 16 UI]
Freighter[Freighter Wallet Extension]
end
subgraph Backend Application Layer [Express 5 + TypeScript]
AuthSvc[Auth Service: Email/Pass + Google OAuth]
SquadSvc[Squad Validator & Formations]
LeagueSvc[League & Competition Engine]
FplSvc[FPL Upstream Sync & Normalizer]
FinSvc[Financial State Machine & Accounting]
StellarSvc[Stellar & Soroban Verifier Service]
end
subgraph Data Layer
PostgreSQL[(PostgreSQL + Prisma 7)]
FPL_API[FPL Official Upstream API]
end
subgraph Blockchain Layer [Stellar Testnet]
Horizon[Stellar Horizon API]
SorobanRPC[Soroban RPC Node]
EscrowContract[FantasyXI Escrow Smart Contract\nCB4KIK42P32SZHKG...]
UsdcSAC[USDC Stellar Asset Contract\nCBKWOGJ7CQSVZXIO...]
end
Browser -->|JWT Authenticated API Calls| AuthSvc
Browser -->|Squad Selection & Joins| SquadSvc
Browser -->|Freighter Signs invokeHostFunction| Freighter
Freighter -->|Direct Soroban Invocation: deposit()| EscrowContract
FinSvc --> StellarSvc
StellarSvc -->|Verify Envelope XDR & Status| Horizon
StellarSvc -->|Verify On-Chain Ledger State| SorobanRPC
LeagueSvc --> PostgreSQL
SquadSvc --> PostgreSQL
FinSvc --> PostgreSQL
FplSvc -->|Sync Players & Fixtures| FPL_API
FplSvc --> PostgreSQL
EscrowContract -->|Transfer USDC| UsdcSAC
FantasyXI enforces a strict boundary between Web2 application gameplay and Web3 financial settlements:
league_id.AlreadyDeposited, PayoutExceedsDeposits, AlreadySettled, and NotAuthorized.settle) or full refund (refund).deposit).| Component | Identifier / Address |
|---|---|
| Escrow Smart Contract | CB4KIK42P32SZHKG4JBDCJUV4A4KGCDN6RHOOTIFSBGZHS2IF653VOEA |
| USDC Stellar Asset Contract (SAC) | CBKWOGJ7CQSVZXIOIIPCDAUT6APQYBCEE7QTSGDZZ2RO6D3JYRMKWZNG |
| USDC Classic Asset Issuer | GC43IGCUMQYECKMRKGSJE2RPQPJ2QNHFB6VAHNNBO4NONKK3PVHEXN25 |
| Network Passphrase | Test SDF Network ; September 2015 |
| Soroban RPC Server | https://soroban-testnet.stellar.org |
| Horizon API Server | https://horizon-testnet.stellar.org |
The backend runs a PostgreSQL-backed escrow reconciliation every five minutes. It compares confirmed league transactions and active member deposits with the Soroban USDC escrow balance, and cross-checks indexed deposit, settlement, refund, and claim events. Reports and their findings are stored in ledger_audit_runs / ledger_audit_findings; each report includes Horizon, Soroban, and event-indexer ledger sequences and a SHA-256 hash linked to the previous report. High-severity findings are logged as operational alerts. The auditor is read-only and never applies balance corrections.
Staff can review recent reports at GET /api/v1/admin/ledger-audits (ADMIN or MODERATOR). Configure LEDGER_AUDIT_THRESHOLD_STROOPS to set the global balance alert threshold; the default is 100000 stroops (0.01 USDC). Apply the added Prisma models before deploying the auditor with cd backend && npx prisma db push.
4-4-2, 3-5-2, 3-4-3, 5-3-2, 4-3-3, 5-4-1) with a minimum of 1 GKP, 3 DEF, 2 MID, 1 FWD starting.UPCOMING $\to$ ACTIVE $\to$ COMPLETED or CANCELLED.contracts/src/lib.rs)Written in Rust using the Soroban SDK (soroban-sdk = "22.0.8"), exposing 7 contract functions:
initialize(admin, usdc_token): One-time contract initialization.create_league(creator, league_id, entry_fee): Partitions an isolated league escrow.deposit(participant, league_id): Transfers entry_fee from participant via USDC SAC client into contract storage. Requires participant.require_auth().settle(admin, league_id, winners, platform_treasury, platform_fee): Distributes prize pool to top 3 winners and platform treasury. Enforces PayoutExceedsDeposits and transitions status to Settled atomically.refund(admin, league_id, participants): Refunds entry fees to participants in cancelled competitions.get_league(league_id): View function returning on-chain state (creator, entry_fee, total_deposited, participant_count, status).get_deposit(league_id, participant): View function returning participant deposit amount.Managed by PrizeService:
FantasyXI/
├── backend/ # Node.js + Express + TypeScript Backend
│ ├── prisma/
│ │ ├── schema.prisma # PostgreSQL schema & enum definitions
│ ├── src/
│ │ ├── config/ # Database, Stellar, JWT, and CORS configuration
│ │ ├── controllers/ # HTTP Request handlers (Auth, League, Squad, Financial)
│ │ ├── middleware/ # JWT Authentication & authorization guards
│ │ ├── routes/ # Express v5 API routes (/api/v1/...)
│ │ ├── services/
│ │ │ ├── financial/ # FinancialService, StellarService, SorobanContractClient
│ │ │ ├── fpl/ # Upstream FPL synchronization & normalization
│ │ │ └── league/ # LeagueService, SquadValidator, ScoringService, PrizeService
│ │ ├── scripts/ # Phase 7.6 Live Stellar Testnet verification scripts
│ │ └── tests/ # Comprehensive unit & integration test suites
│ ├── package.json # Scripts & backend dependencies
│ └── tsconfig.json # NodeNext strict TypeScript configuration
├── frontend/ # Next.js 16 + React 19 + TailwindCSS App
│ ├── src/
│ │ ├── app/ # App Router pages (leagues, fixtures, team, profile, etc.)
│ │ ├── components/ # UI components, Pitch visualizer, PlayerCard, PaymentModal
│ │ ├── context/ # AuthContext (JWT session management)
│ │ └── lib/
│ │ ├── api.ts # Axios/Fetch API client wrapper
│ │ └── stellar/ # sorobanDeposit.ts (Freighter + Soroban RPC client)
│ ├── package.json # Frontend dependencies (@stellar/freighter-api, @stellar/stellar-sdk)
│ └── next.config.ts # Next.js configuration (Turbopack)
├── contracts/ # Soroban Escrow Smart Contract (Rust)
│ ├── src/
│ │ └── lib.rs # Escrow contract implementation & Rust unit tests
│ └── Cargo.toml # Rust package configuration (soroban-sdk = "22.0.8")
├── tools/ # Local developer tooling (Stellar CLI binaries)
└── REGULATORY_CONSIDERATIONS.md # Legal, AML, and non-custodial compliance documentation
1.75.0+ with target wasm32-unknown-unknownv14+ running locally or via Dockerv22+ installed for contract simulation / executionEnsure PostgreSQL is running and create a local database:
CREATE DATABASE fantasyxi;
Navigate to backend/ and create your .env file:
cd backend
cp .env.example .env
Configure backend/.env:
PORT=5000
NODE_ENV=development
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/fantasyxi?schema=public"
JWT_SECRET="your-secure-jwt-secret-key-at-least-32-chars"
JWT_EXPIRES_IN="7d"
# Stellar Testnet Configuration
STELLAR_NETWORK=TESTNET
STELLAR_HORIZON_URL="https://horizon-testnet.stellar.org"
STELLAR_SOROBAN_RPC_URL="https://soroban-testnet.stellar.org"
STELLAR_NETWORK_PASSPHRASE="Test SDF Network ; September 2015"
STELLAR_USDC_ASSET_CODE="USDC"
STELLAR_USDC_ISSUER="GC43IGCUMQYECKMRKGSJE2RPQPJ2QNHFB6VAHNNBO4NONKK3PVHEXN25"
STELLAR_USDC_TOKEN_CONTRACT_ID="CBKWOGJ7CQSVZXIOIIPCDAUT6APQYBCEE7QTSGDZZ2RO6D3JYRMKWZNG"
STELLAR_ESCROW_CONTRACT_ID="CB4KIK42P32SZHKG4JBDCJUV4A4KGCDN6RHOOTIFSBGZHS2IF653VOEA"
STELLAR_TREASURY_ADDRESS="GC43IGCUMQYECKMRKGSJE2RPQPJ2QNHFB6VAHNNBO4NONKK3PVHEXN25"
Install dependencies, run database migrations, and generate Prisma client:
npm install
npm run db:migrate
npm run build
Start the backend development server:
npm run dev
Backend API will be running at http://localhost:5000.
The frontend is a Next.js app and should be started from the frontend/ directory using a supported Node.js version.
Requirements:
v20.x or v24.xnpmFrom the repository root:
cd frontend
node -v
npm install
cp .env.example .env.local
Configure frontend/.env.local:
NEXT_PUBLIC_API_URL="http://localhost:5000"
NEXT_PUBLIC_STELLAR_NETWORK="TESTNET"
NEXT_PUBLIC_STELLAR_ESCROW_CONTRACT_ID="CB4KIK42P32SZHKG4JBDCJUV4A4KGCDN6RHOOTIFSBGZHS2IF653VOEA"
NEXT_PUBLIC_STELLAR_SOROBAN_RPC_URL="https://soroban-testnet.stellar.org"
NEXT_PUBLIC_STELLAR_NETWORK_PASSPHRASE="Test SDF Network ; September 2015"
Install dependencies and start the local Next.js development server:
npm install
npm run dev
For the current Next.js setup, npm run dev starts the local development server (using the standard Next.js app setup; in v16 this can use Turbopack under the hood). The frontend will be available at http://localhost:3000.
See backend resilience checks for financial chaos testing, read-replica consistency, Redis Streams fanout, and local k6 load testing.
FantasyXI maintains automated test suites across all architectural layers.
Executes domain rules, scoring, formation constraints, tie-breakers, auth, and payment envelope parsing without live network dependencies:
cd backend
npm test
Output: 118 passed, 0 failed across 33 suites
Executes contract unit tests and invariant checks inside the Soroban simulation environment:
cd contracts
cargo test
Output: 6 passed, 0 failed
test_initialize_and_create_league: Validates partition initialization.test_deposit_and_single_settlement: Proves 95/5 payout mechanics.test_duplicate_deposit_rejected: Reverts with AlreadyDeposited (#6).test_settlement_payout_exceeding_deposits_rejected: Reverts with PayoutExceedsDeposits (#9).test_unauthorized_settlement_rejected: Reverts with NotAuthorized (#10).test_refund_cancelled_league: Proves complete token return upon cancellation.Executes a live on-chain competition (create_league, multi-manager deposit, envelope verification, guard assertions, and settle) against Stellar Testnet:
cd backend
npx tsx src/scripts/provePhase76Lifecycle.ts
Results are saved to backend/phase7.6_testnet_evidence.json.
Verifies strict TypeScript compliance and static page optimization:
cd frontend
npm run build
Output: 13/13 static & dynamic routes compiled with zero errors.
The frontend installs as a PWA (manifest + service worker in frontend/public/). The service worker is only registered in production builds:
cd frontend
npm run build && npm start
/team: the squad is shown read-only with an offline banner. Uncached pages fall back to /offline.html.backendNodenpm install && npm run buildnpm start (Runs compiled code via node dist/server.js without dev tooling)DATABASE_URL: Hosted PostgreSQL connection string.JWT_SECRET: Random 64-character secret.NODE_ENV: productionSTELLAR_* configuration parameters.frontend/.Next.jsnpm run build.nextNEXT_PUBLIC_API_URL: URL of your deployed backend.NEXT_PUBLIC_STELLAR_ESCROW_CONTRACT_ID: CB4KIK42P32SZHKG4JBDCJUV4A4KGCDN6RHOOTIFSBGZHS2IF653VOEAinvokeHostFunction transaction envelopes, matching contract ID, function call, sender public key, and league ID.RATE_LIMIT_REDIS_URL (or REDIS_URL) for shared limits across instances; while Redis is unavailable, a bounded conservative in-process limiter is used. Route thresholds and windows are defined in backend/src/config/rateLimit.ts. The higher webhook tier is enabled only on webhook paths when WEBHOOK_RATE_LIMIT_SECRET matches the X-Webhook-Secret header. Authentication endpoints retain a separate strict IP limiter.requirePermission; the role-to-permission matrix lives in backend/src/config/permissions.ts. Roles are USER (managers), MODERATOR, ADMIN and SERVICE (automated callers). Elevated permissions are re-checked against the database on each request, so demoting an account takes effect immediately. A route audit test fails the build if a non-public endpoint is added without a permission guard.This project is licensed under the ISC License. See the LICENSE file for details.
This section helps contributors configure the Stellar Testnet environment locally to interact with Soroban contracts and the USDC Stellar Asset used by FantasyXI.
Network & endpoints:
https://horizon-testnet.stellar.orghttps://soroban-testnet.stellar.orgTest SDF Network ; September 2015Required environment variables (add these to backend/.env and frontend/.env.local as appropriate):
STELLAR_NETWORK (e.g. TESTNET)STELLAR_HORIZON_URL (e.g. https://horizon-testnet.stellar.org)STELLAR_SOROBAN_RPC_URL (e.g. https://soroban-testnet.stellar.org)STELLAR_NETWORK_PASSPHRASE (e.g. Test SDF Network ; September 2015)STELLAR_USDC_ASSET_CODE (e.g. USDC)STELLAR_USDC_ISSUER (classic issuer public key, e.g. GC43IGCUMQYECKMRKGSJE2RPQPJ2QNHFB6VAHNNBO4NONKK3PVHEXN25)STELLAR_USDC_TOKEN_CONTRACT_ID (SAC contract id, e.g. CBKWOGJ7CQSVZXIOIIPCDAUT6APQYBCEE7QTSGDZZ2RO6D3JYRMKWZNG)STELLAR_ESCROW_CONTRACT_ID (Escrow contract id, e.g. CB4KIK42P32SZHKG4JBDCJUV4A4KGCDN6RHOOTIFSBGZHS2IF653VOEA)Creating & funding testnet accounts:
https://friendbot.stellar.org/?addr=YOUR_PUBLIC_KEYcurl "https://friendbot.stellar.org/?addr=G...YOUR_PUBLIC...KEY"Obtaining testnet USDC:
// install: npm install stellar-sdk
const StellarSdk = require('stellar-sdk');
const server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
const pair = StellarSdk.Keypair.random();
console.log('Public:', pair.publicKey());
console.log('Secret:', pair.secret());
// Fund using Friendbot (curl in shell) then create trustline and optionally request test USDC from issuer-owned faucet.
If you follow the steps above you will be able to fund a testnet account and configure your local environment to interact with the Soroban RPC and the FantasyXI escrow contract on Stellar Testnet.
X-Service-KeySERVICE_API_KEYSname:keySERVICEREGULATORY_CONSIDERATIONS.md for legal classifications, skill-game exemptions, and AML operational considerations.Trustline note: Before receiving USDC or interacting with the USDC SAC, ensure your test account establishes a trustline to the USDC asset (unless using contract-controlled flows that don't require a classic trustline). In the Stellar Laboratory, add an Asset with code USDC and issuer GC43IGCUMQYECKMRKGSJE2RPQPJ2QNHFB6VAHNNBO4NONKK3PVHEXN25 and submit a change-trust operation.
Quick example: fund + trustline via stellar-sdk (Node.js)