Prediction market platform with on-chain settlement, internal token and limit order book
TruthStake allows users to trade event outcomes through conditional tokens. The platform combines an off-chain backend for managing market catalog, users and orders with on-chain smart contracts for settlement, token exchange and market resolution
USDT (external stablecoin)
|
TokenExchange (1:1 swap, 5% fee)
|
SystemToken (SYS, internal token)
|
MarketFactory (split/merge/resolve/redeem)
|
ConditionalTokens (ERC-1155 outcome tokens)
|
Exchange (on-chain limit order book)
Python backend (ASGI). Users, wallets, off-chain orders, market catalog, comments, notifications. PostgreSQL, JWT authorization, integration tests
Solidity smart contracts (Hardhat). 6 contracts, all core ones with UUPS upgradeable proxy. Deploy scripts for local network and Sepolia, demo scenarios with trading and resolution. 31 tests
SvelteKit + Tailwind frontend. Market catalog, trading, portfolio, leaderboard, deposit/withdrawal, profile, notifications. Connected to API and smart contracts
Admin panel built with SvelteKit + Tailwind. Dashboard with statistics, market and user management, category CRUD, Oracle for manual market resolution
| Contract | Purpose |
|---|---|
| MockUSDT | Test ERC-20 (6 decimals), replaced with real USDT on mainnet |
| SystemToken | Internal ERC-20, mint/burn through authorized minters (UUPS) |
| TokenExchange | USDT to SYS swap at 1 to 1 rate, 5% fee (UUPS) |
| ConditionalTokens | ERC-1155 outcome tokens with deterministic tokenId (UUPS) |
| MarketFactory | Market lifecycle, split/merge/resolve/redeem, 5% fee (UUPS) |
| Exchange | Limit order book, prices in basis points 0-10000 (UUPS) |
TokenExchange charges 5% on each USDT to SYS swap (in USDT, sent to treasury). MarketFactory charges 5% on winning redeem (in SYS, sent to treasury). Both parameters are configurable by the owner, capped at 10%
Backend — Python, ASGI, PostgreSQL, JWT, bcrypt
Contracts — Solidity, Hardhat, OpenZeppelin UUPS, TypeScript tests
Web Client — SvelteKit, TypeScript, Tailwind CSS, Lightweight-charts
Admin Panel — SvelteKit 2, Svelte 5, TypeScript, Tailwind CSS
Local development requires Node.js 18+, Python, Docker (for PostgreSQL)
- Start PostgreSQL and the backend from truthstake-api on port 8000
- Start Hardhat node and deploy contracts from truthstake-contracts
- Start the web client from truthstake-web on port 5173
- Optionally start the admin panel from truthstake-admin on port 5174
Detailed setup instructions for each component are available in the corresponding repository README