Skip to content

Mosss-OS/stablepay

Repository files navigation

StablePay

Unified P2P Remittance + Merchant POS on Algorand

StablePay is a dual-mode blockchain payment application built on the Algorand blockchain. The application targets two primary user segments: (1) diaspora workers sending cross-border remittances, and (2) Indian SME merchants accepting stablecoin payments at point-of-sale. Both modes use USDC as the settlement currency and run on Algorand for near-zero fees and 3.6-second finality.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                    StablePay Architecture                        │
├─────────────────────────────────────────────────────────────────┤
│  ┌─────────────┐    ┌─────────────┐    ┌─────────────────────┐  │
│  │   React     │───▶│  FastAPI   │───▶│  Algorand Network   │  │
│  │  Frontend   │    │  Backend   │    │  (algod + indexer)  │  │
│  │   (UI)      │    │  (API)     │    │  Smart Contracts    │  │
│  └─────────────┘    └─────────────┘    └─────────────────────┘  │
│        │                  │                       │               │
│        ▼                  ▼                       ▼               │
│  ┌─────────────┐    ┌─────────────┐    ┌─────────────────────┐  │
│  │    CLI      │    │   ML/Fraud  │    │   USDC ASA (ASA)    │  │
│  │  (Click)    │    │  Detection  │    │   Escrow Contract   │  │
│  └─────────────┘    └─────────────┘    └─────────────────────┘  │
└─────────────────────────────────────────────────────────────────┘

Tech Stack

Layer Technology
Blockchain Algorand TestNet/MainNet
Smart Contracts Algorand Python (AlgoKit 3.0)
Backend Python 3.11+ / FastAPI
Frontend React 18 + TypeScript + Vite
Database SQLite / PostgreSQL
Payments USDC (ASA ID: 10458941 TestNet / 31566704 MainNet)

Features

P2P Remittance Mode

  • Create/import Algorand wallets with AES-256 encryption
  • Fiat on-ramp simulation (INR → USDC via CoinGecko rates)
  • Escrow-based transfers with 72-hour claim window
  • Recipient confirmation triggers atomic fund release
  • Mock UPI off-ramp for INR settlement simulation

Merchant POS Mode

  • Generate QR codes for USDC payments
  • Real-time settlement via Algorand Indexer polling
  • GST invoice generation (18% IGST simulation)
  • Merchant dashboard with daily settlement summaries

Security & Compliance

  • ML-based fraud detection (Isolation Forest)
  • KYC flagging for transfers > 1,000 USDC
  • FEMA compliance (250,000 USD limit simulation)
  • Smart contract escrow for trustless payments

Prerequisites

  • Python 3.11+ for backend and CLI
  • Node.js 20+ for React frontend
  • Docker Desktop for AlgoKit LocalNet
  • AlgoKit 3.0+ (pipx install algokit)
  • Git for version control

Quick Start

1. Clone the Repository

git clone https://github.com/Mosss-OS/stablepay.git
cd stablepay

2. Setup Frontend

cd frontend
npm install
npm run dev

3. Setup Backend (Coming Soon)

cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
cp ../.env.example .env
# Configure your Algorand credentials in .env
uvicorn main:app --reload

4. Start AlgoKit LocalNet

algokit localnet start
algokit localnet status  # Confirm running

5. Deploy Smart Contracts

cd contracts
python deploy.py --network localnet

CLI Commands

Command Description
stealth wallet create Generate new Algorand wallet
stealth wallet import --mnemonic '...' Import wallet via mnemonic
stealth wallet balance --address ADDR Show ALGO + USDC balances
stealth send --mode p2p --to ADDR --amount 50 Initiate P2P transfer
stealth pos invoice --amount 1200 --currency INR Generate QR invoice
stealth pos confirm --invoice-id ID Poll indexer for payment
stealth tx history --address ADDR --days 7 Transaction history
stealth contracts deploy --network testnet Deploy smart contracts

API Endpoints

Method Path Description Auth
POST /wallets/create Create new wallet -
POST /wallets/import Import wallet -
GET /wallets/{address}/balance Get USDC balance -
POST /transfers/initiate Create escrow transfer JWT
POST /transfers/{id}/release Release escrowed funds JWT
POST /transfers/{id}/reclaim Reclaim expired escrow JWT
GET /transfers/{id}/status Get transfer status JWT
POST /invoices/create Generate QR invoice JWT
GET /invoices/{id}/poll Poll for payment JWT
GET /invoices/{id}/receipt Get GST receipt JWT
GET /fraud/check ML fraud risk score JWT
POST /fraud/retrain Retrain ML model Admin
GET /rates/usdc-inr Current exchange rate -
GET /analytics/volume 7-day transaction volume JWT

Smart Contract Addresses (TestNet)

Contract App ID Explorer
EscrowContract TBD Lora

Project Structure

stealth/
├── contracts/              # Algorand Python smart contracts
│   ├── escrow.py           # EscrowContract (ARC-4)
│   ├── payment_sig.py      # PaymentSig (stateless)
│   ├── deploy.py           # Deployment script
│   └── tests/              # Contract tests
├── backend/                # FastAPI backend
│   ├── main.py             # App entry point
│   ├── routers/            # API endpoints
│   ├── services/           # Business logic
│   ├── cli.py              # Click CLI
│   └── tests/              # Backend tests
├── frontend/               # React + TypeScript
│   ├── src/
│   │   ├── pages/          # Route pages
│   │   ├── components/     # UI components
│   │   └── hooks/          # Custom React hooks
│   └── package.json
├── docker-compose.yml      # Full stack deployment
├── .env.example            # Environment template
└── README.md

Development Status

Completed

  • Frontend UI scaffolding (React + TypeScript + Tailwind)
  • Mode switcher (P2P / POS)
  • Wallet creation/import UI
  • P2P transfer flow UI
  • POS terminal UI with QR generation
  • Transaction history view
  • Merchant dashboard
  • Fraud review page
  • Analytics dashboard
  • GST invoice component
  • Compliance indicators (KYC, FEMA)

In Progress

  • Backend API (FastAPI)
  • Algorand smart contracts
  • Algorand indexer integration
  • Real wallet operations
  • CLI implementation

TODO

  • EscrowContract deployment
  • Atomic group transactions
  • Real-time indexer polling
  • ML fraud detection model
  • CoinGecko rate integration
  • UPI off-ramp simulation
  • Integration tests
  • TestNet deployment

Demo Video

Coming soon - 5-minute Loom demo of P2P + POS flows

License

MIT License - see LICENSE file for details.

Hackathon

Built for AlgoBharat Hack Series 3.0
Track: Future of Finance — Stablecoin Payments
Prize Pool: USD 30,000 + Acceleration Support


For questions on Algorand development: developer.algorand.org
AlgoBharat Discord: discord.com/invite/xnrb3yne8

About

STEALTH (StablePay) - Unified P2P Remittance + Merchant POS on Algorand. USDC-powered cross-border payments with escrow smart contracts, fraud detection, and GST compliance for India.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors