A full-stack payment application built with Next.js, Node.js, and Cairo smart contracts, featuring ChipiPay SDK integration for seamless wallet management and Flutterwave V4 API for fiat processing.
SendPay is a production-ready payment platform that allows users to:
- STRK/USDC to NAIRA in minutes - Fast crypto-to-fiat conversion
- Manage Digital Wallets - Integrated with ChipiPay SDK for Starknet wallet creation
- Withdraw to Bank - Convert digital assets to fiat currency via bank transfers
- Track Transactions - Complete history of all payment activities
- Multi-Currency Support - USD and NGN with real-time exchange rates
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Frontend β β Backend β β Blockchain β
β (Next.js) βββββΊβ (Node.js) βββββΊβ (Starknet) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Cookies β β MongoDB β β ChipiPay SDK β
β (Auth) β β (User Data) β β (Wallets) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Flutterwave β β Apibara β β Smart Contract β
β V4 API β β (Indexer) β β (Cairo) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- User Authentication β ChipiPay SDK β Backend JWT β Frontend Cookies
- Payment Requests β Backend API β Database β QR/Link Generation
- Withdrawals β Smart Contract β Backend Processing β Bank Transfer
- Balance Updates β Blockchain Events β Backend Sync β Frontend Display
- Crypto Transfers β ChipiPay SDK β PIN Authentication β Blockchain Execution
sendpay/
βββ frontend/ # Next.js Frontend Application
β βββ src/
β β βββ app/ # App Router Pages
β β β βββ login/ # Authentication & Onboarding
β β β βββ dashboard/ # User Dashboard & Balance
β β β βββ receive/ # Create Payment Requests
β β β βββ withdraw/ # Withdraw to Bank
β β β βββ history/ # Transaction History
β β βββ components/ # Reusable UI Components
β β β βββ ui/ # shadcn/ui Components
β β β βββ navigation.tsx
β β β βββ theme-provider.tsx
β β βββ lib/ # Utilities & APIs
β β β βββ api.ts # API Client
β β β βββ cookies.ts # Cookie Management
β β β βββ schemas.ts # Zod Validation
β β βββ hooks/ # Custom React Hooks
β βββ package.json
β
βββ backend/ # Node.js Backend API
β βββ src/
β β βββ models/ # Mongoose Schemas
β β β βββ User.ts # User Model
β β β βββ Transaction.ts
β β β βββ BankAccount.ts
β β βββ routes/ # API Endpoints
β β β βββ auth.ts # Authentication
β β β βββ chipipay.ts # ChipiPay Integration
β β β βββ jwks.ts # JWT Key Management
β β β βββ user.ts # User Management
β β β βββ payment.ts # Payment Requests
β β β βββ transaction.ts
β β β βββ withdrawal.ts # Withdrawal Handling
β β β βββ starknet.ts # Blockchain Operations
β β β βββ flutterwave.ts # Payment Gateway
β β βββ services/ # Business Logic
β β β βββ chipipay.service.ts
β β β βββ starknet.service.ts
β β β βββ flutterwave.service.ts
β β β βββ exchange-rate.service.ts
β β βββ middleware/ # Express Middleware
β β β βββ auth.ts # JWT Authentication
β β βββ types/ # TypeScript Interfaces
β βββ indexers/ # Apibara indexers
β β βββ sendpay.indexer.ts
β βββ apibara.config.ts # Apibara config with presets
β βββ package.json
β
βββ contract/ # Cairo Smart Contract
βββ src/
β βββ lib.cairo # Main contract implementation
βββ tests/
β βββ test_sendpay.cairo
βββ Scarb.toml
- Next.js 14 - React framework with App Router
- TypeScript - Type-safe development
- Tailwind CSS - Utility-first CSS framework
- shadcn/ui - Modern component library
- Zod - Schema validation
- React Hooks - State management
- Node.js - JavaScript runtime
- Express.js - Web framework
- TypeScript - Type-safe development
- MongoDB - NoSQL database
- Mongoose - MongoDB ODM
- JWT - Authentication tokens
- Apibara - Indexers for Starknet events
- Starknet - Layer 2 scaling solution
- ChipiPay SDK - Wallet management & gasless transactions
- Cairo - Smart contract language
- Apibara - Event streaming indexers
- MongoDB Atlas - Cloud database
- Flutterwave V4 - Payment gateway
- Environment Variables - Secure configuration
- CORS - Cross-origin resource sharing
- ChipiPay Integration - Real wallet creation via ChipiPay SDK
- Multi-step Onboarding - Personal info + bank details
- Secure Token Management - HTTP-only cookies with expiration
- JWT-based Auth - Custom backend authentication with JWKS endpoints
- Payment Requests - Generate shareable payment links
- QR Code Generation - Mobile-friendly payment options
- Multi-currency - USD and NGN support
- Real-time Exchange Rates - Dynamic currency conversion
- Starknet Wallets - Deployed via ChipiPay SDK
- Balance Tracking - Real-time USDC and STRK balances
- Transaction History - Complete blockchain activity log
- Gasless Operations - ChipiPay handles transaction fees
- Crypto Transfers - Send STRK/USDC with PIN authentication
- Bank Account Management - Multiple account support
- Withdrawal Processing - Digital to fiat conversion
- Transaction Status - Real-time processing updates
- Compliance Ready - KYC/AML integration ready
- Node.js 18+ and npm
- MongoDB Atlas account
- ChipiPay organization account
- Flutterwave account
- Starknet wallet (for testing)
# Database
MONGODB_URI=mongodb+srv://username:[email protected]/sendpay
# ChipiPay Integration
CHIPI_PUBLIC_KEY=your_chipi_public_key
CHIPI_SECRET_KEY=your_chipi_secret_key
# JWT Configuration
JWT_PRIVATE_KEY_PEM=your_jwt_private_key_pem
JWT_PUBLIC_KEY_PEM=your_jwt_public_key_pem
JWT_ISSUER=https://your-backend-url.com
JWT_AUDIENCE=sendpay-users
# Starknet Configuration
STARKNET_NETWORK=mainnet
STARKNET_RPC_URL=https://starknet-mainnet.public.blastapi.io/rpc/v0_7
SENDPAY_CONTRACT_ADDRESS=your_mainnet_contract_address
USDC_MAINNET_ADDRESS=0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8
# Flutterwave V4 Integration
FLUTTERWAVE_CLIENT_ID=your_flutterwave_client_id
FLUTTERWAVE_CLIENT_SECRET=your_flutterwave_client_secret
FLUTTERWAVE_ENCRYPTION_KEY=your_flutterwave_encryption_key
FLUTTERWAVE_CALLBACK_URL=https://yourdomain.com/api/flutterwave/webhook
# Apibara (DNA) β required to run the indexer
DNA_TOKEN=your_apibara_api_key
APIBARA_STREAM_URL=https://mainnet.starknet.a5a.ch
# Optional
COINGECKO_API_KEY=your_coingecko_api_key_here
PORT=3001
NODE_ENV=production
FRONTEND_URL=https://your-vercel-domain.vercel.appNEXT_PUBLIC_API_URL=https://your-backend-url.com/api
NEXT_PUBLIC_STARKNET_NETWORK=mainnet-
Clone Repository
git clone https://github.com/yourusername/sendpay.git cd sendpay -
Backend Setup
cd backend npm install cp .env.example .env # Edit .env with your credentials npm run build npm start
-
Frontend Setup
cd frontend npm install cp .env.example .env.local # Edit .env.local with your API URL npm run build npm start
-
Database Setup
- Create MongoDB Atlas cluster
- Update connection string in backend .env
- Database will auto-create collections
-
Smart Contract Deployment
cd contract scarb build # Deploy to mainnet using your preferred tool
cd backend
npm testcd frontend
npm test- Use Postman or similar tool
- Test endpoints at
https://your-backend-url.com/api - Include JWT token in Authorization header
- Authentication & User Management: JWT-based auth with password hashing
- Onboarding Flow: Bank account setup with Flutterwave verification
- Wallet Creation: ChipiPay integration for Starknet wallet creation
- Payment Requests: Create shareable payment links with QR codes
- Transaction History: Complete tracking with filtering and search
- Smart Contract: Full Cairo contract with withdrawal/deposit functionality
- Blockchain Integration: Starknet.js with Apibara indexers
- Exchange Rates: Real-time USD/NGN conversion
- Frontend Framework: Next.js 14 with TypeScript and shadcn/ui
- Database Models: Complete schemas for User, Transaction, BankAccount
- API Structure: RESTful endpoints with proper error handling
- Mobile-optimized UI with responsive design
- Production deployment ready for both frontend and backend
- Crypto Transfers: STRK/USDC transfer functionality with PIN authentication
- JWKS Endpoints: JWT key management for secure authentication
- Balance Formatting: Proper decimal formatting for crypto balances
- QR Code Integration: Wallet address sharing with QR codes
- Offramp Flow: Complete withdrawal system with Flutterwave integration
- Webhook System: Flutterwave webhook handling for payment status
- Event Indexing: Apibara indexer for real-time blockchain events
- Price Locking: Exchange rate locking for withdrawal consistency
- Transaction Status: Complete lifecycle management
- Onramp Flow: Flutterwave V4 integration for payment processing
- Admin Security: Role-based access control and 2FA
- Production Monitoring: Comprehensive logging and alerting
- Rate Limiting: API abuse prevention
- Backend Infrastructure: Ready for deployment
- Frontend Application: Ready for deployment
- Smart Contract: Fully implemented and tested
- Database Schema: Complete and optimized
- Environment Configuration: Production-ready
- Crypto Transfer System: Fully functional with PIN authentication
- JWT Security: JWKS endpoints for secure token validation
- Balance Management: Real-time crypto balance tracking
- Offramp System: Complete withdrawal flow with Flutterwave
- Event Processing: Real-time blockchain event handling
- Webhook Integration: Flutterwave webhook processing
- Payment Processing: Requires Flutterwave V4 integration completion
- Security Hardening: Admin roles and compliance features needed
- Monitoring & Alerting: Production monitoring system needed
- Multi-language support
- Advanced analytics dashboard
- Mobile app development
- API rate limiting
- Admin panel
- HTTP-only Cookies - XSS protection
- JWT Tokens - Secure authentication
- CORS Configuration - Origin validation
- Input Validation - Zod schema validation
- Environment Variables - Secure configuration
- MongoDB Injection Protection - Mongoose ODM
- Password Hashing - bcrypt with salt rounds
- Signature Verification - ECDSA signatures for withdrawals
POST /api/auth/signup- User registrationPOST /api/auth/login- User loginGET /.well-known/jwk.json- JWT public key for validation
GET /api/user/profile- Get user profilePUT /api/user/profile- Update profileGET /api/user/balance- Get user balanceGET /api/user/bank-accounts- List bank accountsPOST /api/user/bank-accounts- Add bank account
POST /api/payment/receive- Create payment requestGET /api/payment/:reference- Get payment detailsPOST /api/payment/:reference/process- Process paymentGET /api/payment/requests- Get user's payment requests
GET /api/transaction/history- Transaction historyGET /api/transaction/:id- Transaction detailsGET /api/transaction/summary- Transaction summary
POST /api/chipipay/wallet- Get wallet detailsPOST /api/chipipay/transfer- Execute crypto transfersGET /api/chipipay/balance/:address- Get wallet balanceGET /api/starknet/balance/:address- Get blockchain balance
POST /api/withdrawal/signature- Get withdrawal signaturePOST /api/withdrawal/execute- Execute withdrawal
GET /api/flutterwave/banks- Get list of banksPOST /api/flutterwave/bank/add- Add and verify bank accountPOST /api/flutterwave/transfer- Initiate bank transferPOST /api/flutterwave/webhook- Handle webhook notifications
Indexers are run via Apibara CLI, not via HTTP routes. See backend README for scripts.
- Status: β Production ready
- Build Command:
npm run build - Start Command:
npm start - Environment: Production with MongoDB Atlas
- Status: Ready for deployment
- Build Command:
npm run build - Environment Variable:
NEXT_PUBLIC_API_BASE=https://your-backend-url/api
# Database
MONGODB_URI=mongodb+srv://username:[email protected]/sendpay
# ChipiPay Integration
CHIPI_PUBLIC_KEY=your_chipi_public_key
CHIPI_SECRET_KEY=your_chipi_secret_key
# JWT Configuration
JWT_PRIVATE_KEY_PEM=your_jwt_private_key_pem
JWT_PUBLIC_KEY_PEM=your_jwt_public_key_pem
JWT_ISSUER=https://your-backend-url.com
JWT_AUDIENCE=sendpay-users
# Starknet Mainnet
STARKNET_NETWORK=mainnet
STARKNET_RPC_URL=https://starknet-mainnet.public.blastapi.io/rpc/v0_7
SENDPAY_CONTRACT_ADDRESS=your_mainnet_contract_address
USDC_MAINNET_ADDRESS=0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8
# Flutterwave V4
FLUTTERWAVE_CLIENT_ID=your_flutterwave_client_id
FLUTTERWAVE_CLIENT_SECRET=your_flutterwave_client_secret
FLUTTERWAVE_ENCRYPTION_KEY=your_flutterwave_encryption_key
FLUTTERWAVE_CALLBACK_URL=https://yourdomain.com/api/flutterwave/webhook
# Apibara Mainnet
DNA_TOKEN=your_apibara_api_key
APIBARA_STREAM_URL=https://mainnet.starknet.a5a.ch
# Production
NODE_ENV=production
FRONTEND_URL=https://your-vercel-domain.vercel.app
PORT=3001NEXT_PUBLIC_API_BASE=https://your-backend-url/api
NEXT_PUBLIC_STARKNET_NETWORK=mainnetcd backend
npm run build
npm startcd frontend
npm run build
npm start- β ChipiPay Integration: Complete wallet creation and crypto transfer functionality
- β JWKS Endpoints: JWT key management for secure authentication
- β Balance Formatting: Proper decimal formatting for USDC (2 decimals) and STRK (18 decimals)
- β QR Code Integration: Wallet address sharing with QR codes
- β PIN Authentication: Secure crypto transfers with PIN verification
- β Mobile Navigation: Added Logout button to hamburger dropdown
- β Hero Copy: Updated to "STRK/USDC to NAIRA in minutes"
- β Production Logging: Backend now logs correct public URLs
- β Environment Handling: Proper production vs development configs
- β Production Ready: Backend and frontend ready for deployment
- β Apibara Integration: Indexer implemented for real-time event listening
- β Flutterwave Integration: Complete offramp system with webhook handling
- β Price Locking: Exchange rate locking for withdrawal consistency
- β Transaction Lifecycle: Complete status management from creation to completion
- β Documentation: Updated all READMEs to reflect current codebase
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Project Wiki
- Issues: GitHub Issues
- Email: [email protected]
- ChipiPay Team - For the amazing SDK and support
- Starknet Community - For the innovative L2 solution
- Flutterwave Team - For the payment gateway integration
- shadcn/ui - For the beautiful component library
- Next.js Team - For the excellent React framework
Built with β€οΈ by the SendPay Team