Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# XRPL Testnet Accounts
# Get from faucet: https://xrpl.org/xrp-testnet-faucet.html
XRPL_OPERATOR_ADDRESS=
XRPL_ISSUER_ADDRESS=
# EVM Operator Account
EVM_OPERATOR_ADDRESS=

# Admin API Key (generate a secure random string for production)
ADMIN_API_KEY=dev-admin-key
100 changes: 16 additions & 84 deletions .foreman/requirements.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,16 @@
# MITATE UI Migration Requirements

## Background

MITATE is an XRPL-powered prediction market for the JFIIP hackathon (demo day: Feb 24, 2026). The initial implementation is complete with:
- Backend API (Hono + SQLite + xrpl.js)
- XRPL integration (Escrow, Issued Currency, Trust Lines, DEX, Multi-Sign, Memo)
- Basic frontend (apps/web) with GemWallet integration

A team member created a new UI design in `apps/mock/` with superior design and new features. This migration integrates that UI with our existing backend while adding new capabilities.

## Goals

1. Replace `apps/web` with the new UI from `apps/mock/`
2. Add multi-outcome market support (not just YES/NO)
3. Implement weighted betting system (user attributes affect bet weight)
4. Integrate with existing XRPL backend
5. Keep Japanese UI language
6. Use XRP as currency (not JPYC from mock)

## Non-Goals

- Admin panel UI (use API/CLI for market management)
- Mobile app
- Mainnet deployment (Testnet only for hackathon)
- JPYC or other stablecoins

## Features to Migrate from apps/mock

### UI Components
- Site header with wallet connection
- Market listing page with filter bar (category, status)
- Market detail page with outcomes list
- Bet panel with amount input and quick select
- My Page (portfolio with positions)
- Market card component with category badges

### New Features to Implement
1. **Multi-Outcome Markets** — Support 2-5 outcomes per market (not just YES/NO)
2. **Weighted Betting** — User attributes (region, expertise, experience) multiply bet effectiveness
3. **Attribute System** — Users can register verified attributes that grant weight bonuses
4. **Category System** — Markets belong to categories (政治, 経済, 地域, etc.)

## Technical Constraints

- Keep bun as package manager
- Keep GemWallet as wallet (no other wallets)
- Keep XRP as currency (convert JPYC references)
- Keep existing API structure in apps/api
- Must work with existing XRPL transaction builders

## API Changes Required

### Markets
- Add `outcomes` field (array of {id, label, probability})
- Add `category` and `categoryLabel` fields
- Change from hardcoded YES/NO to dynamic outcomes

### Users/Attributes
- New endpoint: GET/POST /users/:address/attributes
- Store verified attributes per wallet address
- Calculate weight score from attributes

### Bets
- Update to reference outcome ID (not just "YES"/"NO")
- Store weight multiplier applied at bet time
- Calculate effective amount (amount × weight)

## Acceptance Criteria

1. Homepage shows market list with category filter
2. Market detail shows all outcomes with probabilities
3. Users can connect GemWallet and see their address
4. Users can place bets on any outcome with XRP
5. Bet amounts are multiplied by user's weight score
6. Portfolio page shows user's positions
7. All XRPL transactions work (escrow, tokens, etc.)

## Tech Stack

- Frontend: Next.js 14+ (App Router), Tailwind CSS, shadcn/ui
- Backend: Hono, SQLite, xrpl.js
- Wallet: GemWallet (@gemwallet/api)
- XRPL: Testnet
# Migrate mitate from XRPL to EVM (no backward compatibility)

## Goal
Replace all XRPL logic with EVM logic across the project.

## Hard requirements
1. Branch `evm` must be used.
2. Remove all XRPL/XRLP logic, dependencies, adapters, configs, env vars, docs, and tests.
3. No backward compatibility layer.
4. Replace with EVM implementations only.
5. Keep the project buildable and tests passing.

## Deliverables
- Fully migrated codebase on EVM
- Updated docs and configuration for EVM
- Clean test/build pass
80 changes: 36 additions & 44 deletions DEMO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# MITATE Demo Guide

**Hackathon:** JFIIP Demo Day — February 24, 2026
**Duration:** 3 minutes
**Audience:** Judges evaluating XRPL feature usage
**Hackathon:** JFIIP Demo Day — February 24, 2026
**Duration:** 3 minutes
**Audience:** Judges evaluating EVM feature usage

---

Expand All @@ -29,13 +29,10 @@ Create `apps/api/.env`:
PORT=3001
NODE_ENV=development
DATABASE_PATH=/data/mitate.db
XRPL_RPC_URL=https://s.altnet.rippletest.net:51234
XRPL_WS_URL=wss://s.altnet.rippletest.net:51233
XRPL_NETWORK_ID=1
EVM_RPC_URL=https://sepolia.infura.io/v3/YOUR_KEY

# Get from testnet faucet: https://faucet.altnet.rippletest.net/accounts
XRPL_OPERATOR_ADDRESS=rYourOperatorAddress...
XRPL_ISSUER_ADDRESS=rYourIssuerAddress...
# Operator wallet address (0x...)
EVM_OPERATOR_ADDRESS=0xYourOperatorAddress...

ADMIN_API_KEY=your-secure-admin-key
```
Expand All @@ -52,9 +49,10 @@ curl http://localhost:3001/health

### 3. Fund Wallets

Get testnet XRP for operator wallet:
Get testnet ETH for operator wallet from an EVM testnet faucet:
```bash
curl -X POST https://faucet.altnet.rippletest.net/accounts
# Example: Sepolia faucet
# https://sepoliafaucet.com
```

---
Expand All @@ -81,9 +79,9 @@ Click "Test Open" button next to the Draft market.
### Step 3: Place Bets (User Flow)

1. Go to `http://localhost:3000`
2. Connect GemWallet (must be on Testnet)
2. Connect MetaMask (must be on Testnet)
3. Click a market → Select outcome → Enter amount
4. Click "予測する" → Sign in GemWallet
4. Click "予測する" → Sign in MetaMask

### Step 4: Close Market (Admin UI)

Expand Down Expand Up @@ -112,9 +110,9 @@ Response includes payout transactions to sign:
"payouts": [
{
"id": "pay_xxx",
"userId": "rWinnerAddress...",
"amountDrops": "15000000",
"payoutTx": { /* Payment tx to sign */ }
"userId": "0xWinnerAddress...",
"amountWei": "15000000000000000",
"payoutTx": { /* ETH transfer tx to sign */ }
}
]
}
Expand Down Expand Up @@ -176,15 +174,15 @@ curl http://localhost:3001/api/markets/YOUR_MARKET_ID/payouts
|----------|--------|-------------|
| `/api/users/:address/bets` | GET | List user's bets |
| `/api/users/:address/attributes` | GET | Get user attributes |
| `/balance/:address` | GET | Get XRP balance |
| `/balance/:address` | GET | Get ETH balance |

---

## Demo Script (3 Minutes)

### Opening (0:00 - 0:20)

> "MITATE is a prediction market powered entirely by XRPL. It uses 6 native XRPL features — no smart contracts, pure XRPL."
> "MITATE is a prediction market powered by EVM. It uses native EVM features — ETH transfers, calldata, and multi-sign governance."

**Show:** Homepage with markets

Expand All @@ -195,26 +193,23 @@ curl http://localhost:3001/api/markets/YOUR_MARKET_ID/payouts
> "Let's bet on the Miyagi governor election."

**Actions:**
1. Connect GemWallet
2. Select market → Select outcome → Enter 5 XRP
1. Connect MetaMask
2. Select market → Select outcome → Enter 0.01 ETH
3. Sign transaction

> "My bet is recorded on XRPL with a memo containing the market and outcome."
> "My bet is recorded on-chain with calldata containing the market and outcome."

---

### Show XRPL Features (1:00 - 2:00)
### Show EVM Features (1:00 - 2:00)

> "Six XRPL features power this:"
> "Three EVM features power this:"

1. **Escrow** — "Bets locked with time-based deadline"
2. **Issued Currency** — "Each outcome has its own token"
3. **Trust Lines** — "Users opt-in to hold outcome tokens"
4. **DEX** — "Trade positions before resolution"
5. **Multi-Sign** — "Resolution requires committee approval"
6. **Memo** — "All transactions carry structured data"
1. **ETH Transfer** — "Bets sent directly to operator with deadline enforced by block_number"
2. **calldata** — "All transactions carry structured market and outcome data"
3. **Multi-Sign** — "Resolution requires committee approval"

**Show:** Transaction on XRPL Explorer
**Show:** Transaction on EVM Explorer

---

Expand All @@ -228,32 +223,29 @@ curl http://localhost:3001/api/markets/YOUR_MARKET_ID/payouts

### Closing (2:50 - 3:00)

> "MITATE proves XRPL's native primitives can power a complete prediction market — all verifiable on-chain."
> "MITATE proves EVM's native primitives can power a complete prediction market — all verifiable on-chain."

---

## XRPL Features Summary
## EVM Features Summary

| Feature | Usage |
|---------|-------|
| **Escrow** | Time-locked XRP pool for bets |
| **Issued Currency** | Outcome tokens per market |
| **Trust Line** | Required to hold outcome tokens |
| **DEX** | Secondary trading of positions |
| **ETH Transfer** | Native ETH pool for bets and payouts |
| **calldata** | Structured audit trail on all transactions |
| **Multi-Sign** | Resolution governance |
| **Memo** | Structured audit trail on all transactions |

---

## Troubleshooting

### "temREDUNDANT" Error
- Payment going to self (operator == bettor)
- Fix: Ensure `XRPL_OPERATOR_ADDRESS` is set and different from user
### "Nonce too low" Error
- Transaction sent with stale nonce
- Fix: Refresh MetaMask account or reset account nonce in MetaMask settings

### "LastLedgerSequence" Error
- Transaction expired before signing
- Fix: Try again quickly, or check network latency
### "Transaction underpriced" Error
- Gas price too low
- Fix: Increase gas price or use EIP-1559 fee estimation

### Market Stuck in Draft
- Run `POST /api/markets/:id/test-open` to open
Expand All @@ -274,5 +266,5 @@ curl http://localhost:3001/api/markets/YOUR_MARKET_ID/payouts
| `apps/api/.env` | API configuration |
| `apps/api/src/services/bets.ts` | Bet placement logic |
| `apps/api/src/services/payouts.ts` | Payout calculation |
| `apps/api/src/xrpl/tx-builder.ts` | XRPL transaction builders |
| `apps/api/src/evm/tx-builder.ts` | EVM transaction builders |
| `apps/web/app/admin/page.tsx` | Admin dashboard |
Loading