Decentralized P2P stablecoin exchange · Zero fees · Forex-linked rates · Solana Mainnet
Live: https://dexstablecoin.github.io/DEXStablecoin.com/
StableX DEX là sàn giao dịch P2P phi tập trung chuyên về stablecoin fiat:
| Token | Pegged to | Thanh toán |
|---|---|---|
| eJPY | Yên Nhật (JPY) | USDT / eUSDC |
| eCNY | Nhân dân tệ (CNY) | USDT / eUSDC |
| eUSDC | USD | USDC / eUSDC |
- Giá tỷ giá lấy live từ Forex (open.er-api.com) — cập nhật mỗi 30 phút
- WebSocket push real-time tới frontend
- Auto-delivery token sau khi xác nhận on-chain
- Giới hạn: 1,000 USDT/giao dịch · 50,000 USDT/ngày
GitHub Pages (frontend)
│
│ WebSocket + HTTP API
▼
Cloudflare Tunnel (trycloudflare.com)
│
│ localhost:8080
▼
server.js (Node.js · máy local)
│
├── Forex API (open.er-api.com)
├── Solana RPC (mainnet-beta)
└── SQLite / db.json
DEX_Stablecoin_Project/ ← Backend (chạy local, KHÔNG push GitHub)
├── server.js ← Express + WebSocket server
├── db.json ← Lịch sử giao dịch
├── daily_volume.json ← Volume theo ngày
├── wallet.enc ← Keypair ví sàn (mã hóa AES-256)
├── setup-wallet.js ← Tool tạo wallet.enc
└── node_modules/
DEXStablecoin.com/ ← Frontend repo (GitHub Pages)
├── index.html ← Toàn bộ frontend
├── server.js ← Copy từ backend (tham khảo)
├── mobile.html ← Mobile PWA
└── README.md
- Node.js 18+
- npm
- cloudflared
cd ~/DEX_Stablecoin_Project
npm installnode setup-wallet.jsTerminal 1 — Backend server:
cd ~/DEX_Stablecoin_Project
node server.js
# Nhập mật khẩu ví khi được hỏiXác nhận server OK:
✅ Keypair loaded: ETVg4M1...
[FOREX] ✅ open.er-api.com → eJPY=159.68, eCNY=6.92
🚀 Server: http://localhost:8080
Terminal 2 — Cloudflare Tunnel:
cloudflared tunnel --url http://localhost:8080 2>&1 | grep trycloudflareCopy URL xuất hiện, ví dụ:
https://bosnia-designs-desert-pubs.trycloudflare.com
Terminal 3 — Cập nhật URL và deploy:
# Thay URL_MỚI bằng URL vừa copy ở trên
sed -i "s|https://.*trycloudflare\.com|https://URL_MỚI|g" ~/DEXStablecoin.com/index.html
cd ~/DEXStablecoin.com
git add index.html
git commit -m "fix: update tunnel URL"
git push origin mainChờ 1-2 phút → vào https://dexstablecoin.github.io/DEXStablecoin.com/
| Method | Endpoint | Mô tả |
|---|---|---|
| GET | /api/status |
Trạng thái server |
| GET | /api/orders |
Danh sách lệnh bán |
| GET | /api/forex |
Tỷ giá Forex hiện tại |
| GET | /api/forex-rates |
Tỷ giá + giới hạn giao dịch |
| GET | /api/history |
20 giao dịch gần nhất |
| GET | /api/balance/:address |
Số dư ví Solana |
| POST | /api/calc-order |
Tính toán lệnh mua |
| POST | /api/prepare-payment-tx |
Tạo transaction thanh toán |
| POST | /api/broadcast-tx |
Broadcast + xác nhận on-chain |
| Event | Hướng | Mô tả |
|---|---|---|
INIT |
Server → Client | Dữ liệu khởi tạo (orders, forex, history) |
ORDER_BOOK |
Server → Client | Cập nhật order book |
FOREX_UPDATE |
Server → Client | Tỷ giá mới |
NEW_TX |
Server → Client | Giao dịch mới |
DELIVERY |
Server → Client | Trạng thái giao token |
USER_COUNT |
Server → Client | Số người dùng online |
REGISTER |
Client → Server | Đăng ký session ví |
PING |
Client → Server | Keepalive |
| Token | Mint Address |
|---|---|
| eJPY | HwbwHTKkze4hzF4SSz1Tj3cAb5f2qXd2e8gbFTPXUcj3 |
| eCNY | ABetScri1grGy52wxmq6PGC9kG9B7Z6PVx74B4DQxzUt |
| eUSDC | 6VwnrGyk8XutR8ZM444Lyq8geo2hAcAtB7vMXf7LHTAJ |
| USDT | Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB |
| USDC | EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v |
Server tự động thử các nguồn theo thứ tự ưu tiên:
- open.er-api.com — Free, không cần API key
- fxratesapi.com — Fallback
- fawazahmed0/currency-api — CDN fallback
- Hardcode fallback (eJPY=150, eCNY=7.2)
Cập nhật mỗi 30 phút. Reset daily volume lúc 00:00 UTC.
| Phase | Trạng thái | Nội dung |
|---|---|---|
| Phase 1 | ✅ Live | DEX Web3, Solana, eJPY/eCNY/eUSDC, phí 0% |
| Phase 2 | 🔜 Sắp tới | Open seller listing, Liquidity pool, Limit orders |
| Phase 3 | 📋 Planned | Ethereum bridge, BNB Chain, Cross-chain swap |
| Phase 4 | 🔮 Future | Native token SBX, DAO governance, Mobile app |
- Private key ví sàn được mã hóa AES-256-GCM với PBKDF2 (210,000 iterations)
- Không bao giờ commit
wallet.enc,db.json,.ngrok_tokenlên GitHub - File
.gitignoređã loại trừ các file nhạy cảm
MIT © StableX DEX Team