tinyfiles.tv
PLAY TOKENS ONLY, NO REAL MONEY, TINKER TOY, NOT LIVE YET

Tiny tokens have no cash value. You cannot buy them, sell them, or cash them out. You cannot win or lose real money here. Markets are local-only, stored in this browser tab, NOT saved to the server and NOT shared with anyone yet. This is a toy that shows how a prediction market price moves when people buy Yes or No. Refresh equals your balance and positions gone, except local autosave.

YOUR BALANCE
1000 tiny tokens
Portfolio: 0 tokens in play, P and L: 0
🎲
Local-only toy, download to keep your board.

How it works (when it is real)

Everyone trades on the same markets. You buy Yes or No, price moves, you can sell before resolve, and at resolve the winning side pays. For now, you are trading alone, practice your market.

  • Market equals question plus Yes and No pools
  • Trade equals spend tiny tokens, get shares at current price
  • Vote up or down equals rank, not price
  • Resolve equals winning side pays 1 per share

Community, coming soon

Shared state is not connected yet.

🟢 0 traders right now (fake, local toy)
📈 Last trade: —
🏆 Last resolve: —
📜 Rules: Play tokens only. No cash out.

Backend  ·  Template · Proposed · Not connected · Play tokens only

Backend, TinyOdds Backend, Template, Play Tokens Only

Right now TinyOdds is a tinker toy, markets is a local array in this tab, balance is a local number, positions are local, and Refresh equals gone (except local autosave). Price moving is real, it runs in your browser. Disclaimer is the truth: local-only, play tokens only, no real money, no cash value, not saved, not shared. This backend is the map to make it real, still with play tokens only: one shared market, per-market writes, trades as server rows, positions as server rows, votes as server counts, cooldowns, accounts, moderation. Proposed, not connected. If you ever add real money, that is a different product, with licensing, age checks, and legal review. This template does NOT do that.

01 / Files to create
api/tinyodds/market.php    POST /api/tinyodds/market
api/tinyodds/markets.php   GET  /api/tinyodds/markets?sort=vol&tag=
api/tinyodds/trade.php     POST /api/tinyodds/trade
api/tinyodds/vote.php      POST /api/tinyodds/vote
api/tinyodds/resolve.php   POST /api/tinyodds/resolve
api/tinyodds/snapshot.php  GET  /api/tinyodds/snapshot
sql/tinyodds_tables.sql

Keep the tinyfiles PHP pattern: /api/bootstrap.php, json_in() / json_out(), prepared PDO. Play tokens only. No payment provider in this template.

02 / Database tables
tinyodds_markets
  id BIGINT AUTO_INCREMENT PRIMARY KEY
  user_id INT NOT NULL
  question VARCHAR(200) NOT NULL
  body TEXT NOT NULL
  category VARCHAR(20) NOT NULL
  yes_pool DECIMAL(12,2) NOT NULL DEFAULT 100
  no_pool DECIMAL(12,2) NOT NULL DEFAULT 100
  volume DECIMAL(12,2) NOT NULL DEFAULT 0
  resolved VARCHAR(3) NULL  -- Yes, No, or NULL
  created_at DATETIME NOT NULL

tinyodds_positions
  market_id BIGINT NOT NULL
  user_id INT NOT NULL
  yes_shares DECIMAL(12,4) NOT NULL DEFAULT 0
  no_shares DECIMAL(12,4) NOT NULL DEFAULT 0
  spent DECIMAL(12,2) NOT NULL DEFAULT 0
  PRIMARY KEY (market_id, user_id)

tinyodds_trades
  id BIGINT AUTO_INCREMENT PRIMARY KEY
  market_id BIGINT NOT NULL
  user_id INT NOT NULL
  side VARCHAR(3) NOT NULL  -- Yes or No
  tokens DECIMAL(12,2) NOT NULL
  price DECIMAL(5,4) NOT NULL
  shares DECIMAL(12,4) NOT NULL
  created_at DATETIME NOT NULL

tinyodds_votes
  market_id BIGINT NOT NULL
  user_id INT NOT NULL
  value TINYINT NOT NULL
  PRIMARY KEY (market_id, user_id)

tinyodds_balances
  user_id INT PRIMARY KEY
  balance DECIMAL(12,2) NOT NULL DEFAULT 1000
  -- Play tokens only. No cash value. No cash out column.

Market is one shared market. Never store a market per user, store only markets by id, plus positions and trades.

03 / API endpoints
POST /api/tinyodds/market
{ "question": "Will it snow this week?", "body": "...", "category": "weather" }
- auth required, 1 market per hour, Yes and No pools start at 100 each

GET /api/tinyodds/markets?sort=vol&tag=
- returns markets with yes_price, no_price, volume, my position, my vote

POST /api/tinyodds/trade
{ "market_id": 123, "side": "Yes", "tokens": 50 }
- server checks balance, checks market is not resolved
- shares = tokens / current price, pools move, balance drops
- returns { "ok": true, "shares": 82.5, "new_price": 0.61 }

POST /api/tinyodds/vote
{ "market_id": 123, "value": 1 } - vote up or down, ranks market, does NOT move price

POST /api/tinyodds/resolve
{ "market_id": 123, "outcome": "Yes" } - only owner, with source link
- winning shares pay 1 token per share, losing shares pay 0

Trades are server rows, tinyodds_trades, not client counters. Server decides price, balance, and positions. Client never decides its own balance.

04 / Cooldown, moderation and validation
// Cooldown: 1 market per hour, 1 trade per 2s, 1 vote per 2s
// Moderation: no hate / NSFW / spam, no real money markets, mods can remove plus ban user_id
// Validation: question, category, tokens greater than 0, balance enough, else 400
// Play tokens only: no payment, no cash out, no token purchase endpoint

Keep disclaimer until this ships: Tinker toy, not live yet. Play tokens only, no cash value. Refresh equals gone.

05 / Frontend wiring
// markets[] is already local. After posting (debounced 800ms):
// POST /api/tinyodds/market with new market
// Poll GET /api/tinyodds/markets?sort=vol every 5s, apply only new markets
// On load: GET /api/tinyodds/snapshot, load into markets[] plus balance
// Trade: POST /api/tinyodds/trade, then update price and balance from server
// If API fails, fall back to local-only toy plus disclaimer.
Copy snippets into api/tinyodds/ plus sql/tinyodds_tables.sql, no GitHub needed. Shared market, per-market writes, trades as server rows, play tokens only, no payment provider.