Skip to content

Juls95/finoma

Repository files navigation

Finoma — Prediction Markets dashboard: flight and airport markets, outcome probabilities, A0GI pools, and wallet connect

Finoma

Flying now on markets — AI-assisted prediction markets for flight and airport outcomes, settled on 0G Galileo Testnet (Chain ID 16602) with data from FlightRadar24 and inference from 0G Compute.

This repository is a pnpm monorepo: Next.js frontend, Express/TypeScript API, and Foundry smart contracts.


Features (implemented)

Area What ships today
Markets Airport (Yes/No delay-style) and flight status (OnTime / Delayed / Rescheduled / Cancelled), seeded demo markets + create market from flight search
AI 0G Compute–backed analysis, proof hash surfaced in UI; creation tx link where available
Chain PredictionMarket.sol — multi-outcome pools, placeBet, withdrawBet before end, resolveMarket (resolver), claimPayout
Data FR24 flight summary, live-style status (UTC day window), delay stats; Resolve (test) uses yesterday’s data for manual resolution
UX Wallet connect, Polymarket-style share/payout hints, pool totals from chain, bet tx links, resolution countdown (UTC), live status Refresh

Settlement token on testnet is A0GI.


Using Finoma with your wallet (0G Galileo Testnet)

Finoma runs on 0G Galileo. You use your own browser wallet (e.g. MetaMask, Rabby, or any wallet that supports injected EVM connections) to sign bets, withdrawals, and claims. The app does not custody funds.

1. Install a compatible wallet

Install an EVM wallet browser extension if you do not already have one. Finoma’s frontend uses the standard injected provider (same flow as “Connect wallet” on other dApps).

2. Add the 0G Galileo Testnet network

If the site asks you to switch networks, approve the switch when prompted.

To add the network manually (e.g. MetaMask: Settings → Networks → Add network → Add a network manually), use:

Field Value
Network name 0G Galileo Testnet (or any label you prefer)
RPC URL https://evmrpc-testnet.0g.ai
Chain ID 16602 (MetaMask: enter decimal 16602)
Currency symbol A0GI
Block explorer URL (optional) https://chainscan-galileo.0g.ai

Save the network and select it before using Finoma.

3. Get testnet A0GI (gas and bets)

On Galileo, A0GI is the native token: you need it for transaction gas and for staking in markets (bets are sent as native value).

  1. Open the 0G testnet faucet: https://faucet.0g.ai
  2. Connect the same wallet address you will use in Finoma (or paste your address if the faucet asks for it).
  3. Request test tokens per the faucet rules (limits and cooldowns are set by 0G).
  4. Wait for the transfer to confirm, then check your balance in the wallet while Galileo is selected.

If the faucet or policy changes, check 0G documentation for the current testnet funding method.

4. Open Finoma and connect

  1. Open the hosted Finoma URL (or your local http://localhost:3000 if you run the stack yourself).
  2. Click Connect / connect wallet.
  3. Approve the connection in your extension.
  4. If prompted, switch to chain ID 16602 (Galileo).

You should see your shortened address when connected. Use Refresh or reload if the balance UI looks stale after funding.

5. What you pay for in the app

Action What you need
Place a bet A0GI balance ≥ bet amount + gas
Withdraw a bet (before market ends) Small amount of A0GI for gas
Claim after a resolved market you won Gas only (payout is from the contract)

Gas costs are paid in A0GI on Galileo, not in a separate test “USDC” unless the deployment explicitly adds one (this stack uses native A0GI for pools).

6. If something fails

  • Wrong network — Wallet must show Chain ID 16602 while using Finoma.
  • Insufficient funds — Top up via the faucet; keep a little extra for gas.
  • Transaction reverted — Market may have ended, outcome invalid, or contract address mismatch: a self-hosted frontend must use the same NEXT_PUBLIC_PREDICTION_MARKET_ADDRESS as the deployment you interact with.
  • Explorer — Inspect txs and contracts at https://chainscan-galileo.0g.ai.

Repository layout

Tracked source and config (build artifacts and local secrets are not committed — see .gitignore):

finoma/
├── frontend/           # Next.js 14 app (Finoma UI)
├── backend/            # Express API — markets, FR24, 0G Compute, viem chain calls
├── contracts/          # Foundry — PredictionMarket.sol, INFTAgentRegistry.sol
├── package.json        # Workspace scripts (pnpm)
├── pnpm-workspace.yaml
├── railway.toml        # Example Railway build/start (compiles backend, runs compiled entrypoint)
└── README.md

Authoritative env shape: backend variables are validated in backend/src/config/env.ts. Frontend public variables are read in frontend/src/lib/config.ts.


Prerequisites

  • Node.js ≥ 20
  • pnpm ≥ 9 (packageManager is pinned in root package.json)
  • Foundry — to build/test/deploy contracts/
  • API keys: FR24 (Explorer plan), 0G Compute, and a Galileo-funded wallet for the backend signer

Quick start (local)

  1. Clone and install

    pnpm install
  2. Configure environment (via shell export or your editor/hosting “Variables” UI — do not commit secrets):

    • Backend: set the variables listed below; the server loads from the current working directory and adjacent paths (see backend/src/index.ts).
    • Frontend: set NEXT_PUBLIC_* values the same way for dev (Next.js reads them from the environment).
  3. Compile backend

    pnpm run build:backend
  4. Run

    pnpm run dev:backend    # API: port from `BACKEND_PORT` or `PORT`, default 3001
    pnpm run dev:frontend   # http://localhost:3000

    Or pnpm run dev to start both (background backend).

  5. Contracts (optional local iteration)

    cd contracts && forge build && forge test

    Deployed contract addresses must match the values you configure for the backend and frontend.

Health check: GET /api/health


Environment variables (short list)

Backend — full validation and defaults: backend/src/config/env.ts.

Variable Role
FR24_API_KEY, FR24_BASE_URL, FR24_RATE_LIMIT_RPM FlightRadar24
ZEROG_API_KEY, ZEROG_MODEL_ID 0G Compute
ZEROG_CHAIN_RPC_URL, ZEROG_CHAIN_ID, ZEROG_CHAIN_PRIVATE_KEY Galileo signer
ZEROG_PREDICTION_MARKET_ADDRESS, ZEROG_INFT_REGISTRY_ADDRESS Contracts
BACKEND_PORT / PORT Server port (many hosts set PORT)
NEXT_PUBLIC_APP_URL Allowed browser origin(s) for CORS; comma-separated for multiple frontend URLs

Frontend — consumed in frontend/src/lib/config.ts:

Variable Role
NEXT_PUBLIC_ZEROG_RPC_URL, NEXT_PUBLIC_CHAIN_ID Wallet RPC
NEXT_PUBLIC_PREDICTION_MARKET_ADDRESS, NEXT_PUBLIC_INFT_REGISTRY_ADDRESS Contracts
NEXT_PUBLIC_API_BASE_URL Backend origin (no trailing slash)

Deployment

  • Backend (e.g. Railway)

    • Use repository root as the service root so railway.toml applies: install pnpm deps, run the backend build script, then start the compiled server (see railway.toml for the exact command).
    • Configure the same backend variables in the host’s environment UI. Set NEXT_PUBLIC_APP_URL to your real frontend origin(s).
  • Frontend (e.g. Vercel)

    • Set project root to frontend (or equivalent).
    • Set all NEXT_PUBLIC_* variables; point NEXT_PUBLIC_API_BASE_URL at your public API URL.

0G Galileo (reference)

Item Value
Network 0G Galileo Testnet
Chain ID 16602
RPC https://evmrpc-testnet.0g.ai
Explorer https://chainscan-galileo.0g.ai

Scripts (root)

Command Description
pnpm run dev:frontend Next.js dev server
pnpm run dev:backend API with tsx watch
pnpm run build Backend TypeScript compile + frontend production build
pnpm run build:backend Backend compile only (output under backend/, gitignored)
pnpm run start Production API via backend package from monorepo root
pnpm run lint Frontend + backend lint
pnpm run test Backend Jest

Security

  • Do not commit secrets, API keys, or private keys. Keep them in your host’s secret store or local tooling only.
  • Rotate any credential that may have been exposed.
  • The backend signer is privileged as contract owner/resolver on typical testnet deployments — protect ZEROG_CHAIN_PRIVATE_KEY.

License / status

Private project unless otherwise noted. Adjust this section when you publish an explicit license.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors