This is a Node.js + Express backend that demonstrates JWT-based authentication and ERC-4337 Account Abstraction for gasless blockchain transactions. The system uses Biconomy's infrastructure to sponsor gas fees and submit UserOperations via bundlers. This is a prototype/demo system built for hackathon and internship review purposes, showcasing modular backend architecture and blockchain integration patterns. It is not intended for production use.
Account Abstraction: Leverages ERC-4337 to provide a seamless user experience through smart contract wallets.
Gasless Transactions: Integrated Biconomy Paymaster and Bundlers to sponsor user transactions, removing the barrier of entry for gas fees.
Programmable Wallets: Robust management of user accounts and transaction records via MongoDB.
Dual-Token Auth: Implements stateless JWT Authentication with a secure Access/Refresh token rotation strategy.
Advanced Safety (Demos):
- ML-Driven Fraud Detection: Simulated machine learning analysis to flag suspicious on-chain activity.
- Biometric Verification: Mocked biometric flows to demonstrate high-assurance identity verification.
Resilient Infrastructure: Basic Rate Limiting to prevent brute-force attacks and API abuse.
Type-Safe Validation: Strict input enforcement using Zod schemas to ensure data integrity before it reaches the controller.
Observable Systems: Structured, multi-level logging powered by Winston, capturing detailed service-level events and HTTP requests.
Graceful Lifecycle Management: Automated handling of SIGTERM/SIGINT signals to ensure database connections close cleanly and no data is lost during deployments.
The backend consists of four primary layers:
Authentication Layer: JWT-based stateless authentication with access and refresh tokens. Tokens are verified via middleware on protected routes.
Blockchain Layer: Ethers.js handles RPC interactions. Biconomy SDK manages Account Abstraction wallets, UserOperation construction, and Paymaster/Bundler submission for gasless transactions.
ML Mock Service: A demo service that simulates fraud detection and biometric verification responses. No real machine learning models or biometric cryptography are executed.
Database Layer: MongoDB stores user credentials, wallet addresses, transaction history, and session metadata.
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB with Mongoose ODM
- Authentication: JSON Web Tokens (jsonwebtoken)
- Blockchain: Ethers.js, Biconomy SDK (Account Abstraction)
- Validation: Zod
- Logging: Winston
- Security: Helmet, express-rate-limit, bcrypt
- User submits email and password
- Password is hashed with bcrypt
- Server-side wallet is generated (custodial)
- User record is stored in MongoDB
- Access and refresh tokens are issued
- User credentials are validated
- Biometric verification is simulated via mock service
- JWT access token (short-lived) and refresh token (long-lived) are returned
- Client sends refresh token
- Server validates token signature and expiry
- New access token is issued
- Refresh token is reusable and not rotated
Logout is client-side only. Tokens are stateless and not blacklisted. Users must delete tokens locally.
Smart contract wallets are deployed using Biconomy's Account Abstraction infrastructure. Wallets are controlled by server-generated private keys (custodial model for demo purposes).
- User initiates a transaction request
- Backend constructs an ERC-4337 UserOperation
- UserOperation includes target address, calldata, and gas estimates
- Backend signs the UserOperation with the wallet's private key
- UserOperation is sent to Biconomy Paymaster for gas sponsorship
- Paymaster signs the operation, agreeing to cover gas costs
- Signed UserOperation is submitted to Biconomy Bundler
- Bundler includes the operation in an on-chain bundle transaction
- Transaction hash and status are returned to the client
Both fraud detection and biometric verification are implemented as demo mock services. These services simulate ML model responses with hardcoded logic and do not perform real analysis.
Fraud Detection: Returns mock risk scores and flags based on transaction amount thresholds. No real anomaly detection or machine learning models are used.
Biometric Verification: Simulates biometric authentication success/failure. No actual biometric data is processed or verified. This is used purely to unblock frontend authentication flows.
The backend uses Winston for structured logging:
- HTTP request logs (method, path, status, response time)
- Service-level logs (blockchain operations, auth events)
- Error logs with stack traces
- Logs are output to console and can be configured for file or external service output
This backend has several important limitations:
Mocked Services:
- Fraud detection uses hardcoded logic, not real ML models
- Biometric verification is completely simulated
- No actual biometric cryptography or liveness detection
Custodial Wallets:
- Private keys are generated and stored server-side
- Backend signs all transactions on behalf of users
- This is not suitable for production; users should control their own keys
Stateless Auth Limitations:
- No token blacklisting or revocation
- Logout is purely client-side
- Refresh tokens are reusable and never rotated
- Compromised tokens remain valid until expiry
Incomplete Features:
- OTP verification is scaffolding only
- Push notifications are not implemented
- Activity logs and audit trails are partial
- Some security settings endpoints return mock data
Production Gaps:
- No rate limiting on sensitive operations
- Basic input validation only
- No comprehensive error monitoring
- No secrets rotation strategy
To move this system toward production readiness:
- Real ML Integration: Implement actual fraud detection models with training pipelines
- Non-Custodial Wallets: Support user-controlled private keys or social recovery mechanisms
- Token Rotation: Implement refresh token rotation and blacklisting
- Enhanced Security: Add 2FA, session management, and anomaly detection
- Biometric SDK: Integrate real biometric verification services
- Monitoring: Add APM, error tracking, and alerting infrastructure
- Testing: Comprehensive unit, integration, and end-to-end test coverage
- Documentation: Full API documentation with request/response schemas
- Node.js (v16 or higher)
- MongoDB (local or Atlas)
- Biconomy API keys
- Blockchain RPC URL (e.g., Alchemy, Infura)
npm installnpm run devnpm startThis is a demonstration backend built for educational and portfolio purposes. It showcases blockchain integration patterns and backend architecture but is not production-ready. The fraud detection and biometric verification features are mocked. Wallets are custodial. This system should not be used to handle real funds or sensitive user data without significant security enhancements.