Production-Ready Backend for Tokenized Ride-Sharing on Binance Smart Chain
The PTDT Settlement API is a complete backend solution enabling ride-hailing platforms to:
- Pay drivers in PTDT Token (BEP-20) directly to their wallets
- Convert PTDT to local fiat on-demand (JazzCash, Flutterwave, M-Pesa)
- Operate independently without central authority or intermediaries
- Scale globally with one unified codebase
- Track earnings in real-time with analytics
docker-compose up -d
curl http://localhost:3000/api/v1/healthnpm install
cp .env.example .env
npm run devnpm run build
npm startPOST /api/v1/quote- Generate ride quote in PTDTGET /api/v1/quote/:quoteId- Check quote validity
POST /api/v1/pay- Execute PTDT paymentGET /api/v1/pay/:txId- Check transaction status
POST /api/v1/payout- Initiate driver payoutGET /api/v1/payout/:withdrawalId- Check payout status
GET /api/v1/operator/me- Get operator dashboardGET /api/v1/operator/stats- Get operator statistics
GET /api/v1/analytics/network- Network-level metricsGET /api/v1/analytics/operator/:operatorId- Operator metrics
GET /api/v1/health- API health checkPOST /api/v1/webhook/payment- Payment webhooksPOST /api/v1/webhook/settlement- Settlement webhooksPOST /api/v1/webhook/payout- Payout webhooks
┌──────────────────┐
│ Your Ride-Hailing App │
└───────────┬───────┘
│
┌───────────────┐
│ PTDT Settlement API │
└──────┬────────┘
│
┌───────────┐ ┌──────────┐
│ PostgreSQL DB │ │ BSC Blockchain │
│ Local Data │ │ PTDT Token │
└───────────┘ └──────────┘
| Component | Technology |
|---|---|
| Runtime | Node.js 20+ |
| Framework | Express.js 4.18+ |
| Language | TypeScript 5.1+ |
| Database | PostgreSQL 15+ |
| Blockchain | ethers.js 6.7+ |
| Validation | Joi 17.10+ |
| Logging | Winston 3.10+ |
| Security | Helmet 7.0+, JWT |
| Container | Docker & Docker Compose |
# Blockchain Configuration
BSC_RPC_URL=https://bsc-dataseed1.binance.org:443
PTDT_CONTRACT_ADDRESS=0x66c6Fc5E7F99272134a52DF9E88D94eD83E89278
PTDT_DECIMALS=18
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/ptdt_settlement
# API Configuration
PORT=3000
NODE_ENV=development
JWT_SECRET=your-secret-key-here-min-32-chars
# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000 # 15 minutes
RATE_LIMIT_MAX_REQUESTS=100
# Fiat Payment Providers
YOUR_LOCAL_API_KEY=your-key
YOUR_LOCAL_MERCHANT_ID=your-id
FLUTTERWAVE_API_KEY=your-key
M_PESA_API_KEY=your-key
# Logging
LOG_LEVEL=info
LOG_DIR=./logs
# CORS
CORS_ORIGIN=*✅ Convert ride fare to PTDT amount ✅ Real-time PTDT pricing ✅ Apply promotional discounts ✅ Quote expiration handling
✅ Direct PTDT transfer to driver wallet ✅ Automatic fee distribution ✅ Transaction verification ✅ Failure handling & rollback
✅ Multiple withdrawal methods (WALLET, FIAT) ✅ JazzCash, Flutterwave, M-Pesa integration ✅ Automatic PTDT burn ✅ Payout tracking
✅ PKR, KES, NGN, USD support ✅ Real-time exchange rates ✅ Regional payment gateways
✅ Network metrics (total rides, volume) ✅ Operator dashboard (stats, revenue) ✅ Driver earnings (balance, transactions) ✅ Real-time data aggregation
✅ JWT authentication ✅ API key validation ✅ Rate limiting (100 req/15min) ✅ Request logging & audit trail ✅ Input validation (Joi) ✅ SQL injection prevention (Prisma) ✅ HTTPS/TLS support ✅ Error sanitization
✅ Health checks (API, DB, blockchain) ✅ Webhook verification ✅ Transaction confirmation ✅ Error boundary protection ✅ Graceful shutdown handling
# Build image
docker build -t ptdt-api .
# Run container
docker run -p 3000:3000 \
-e DATABASE_URL=postgresql://... \
-e JWT_SECRET=... \
ptdt-api- Connect GitHub repo
- Set environment variables
- Deploy automatically
- Create new Web Service
- Connect GitHub repo
- Set build command:
npm run build - Set start command:
npm start
- Create EC2 instance
- Install Node.js
- Clone repository
- Install dependencies
- Configure environment
- Start with PM2 or systemd
curl http://localhost:3000/api/v1/healthcurl -X POST http://localhost:3000/api/v1/quote \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"rideFare": 100,
"currency": "PKR",
"discount": 5
}'curl -X POST http://localhost:3000/api/v1/pay \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"quoteId": "QT_1234567890",
"riderWallet": "0x...",
"driverWallet": "0x...",
"amountPtdt": 10.5
}'- START_HERE.md - Quick start guide
- INTEGRATION_GUIDE.md - How to integrate with your app
- DEPLOYMENT.md - Production deployment guide
- QUICK_REFERENCE.md - API endpoint reference
- SECURITY.md - Security best practices
- GitHub Issues: Report bugs and request features
- Email: dev@ptdt.taxi
- Documentation: Check docs folder
MIT License - See LICENSE file
Status: ✅ Production Ready
Version: 0.1.0
Last Updated: January 27, 2026