A NestJS-based trusted encryption service for the Zeroledger ecosystem, providing encryption/decryption capabilities, blockchain event indexing, and paymaster services.
- Challenge Authentication: Wallet-based authentication system
- Encryption Service: Secure data encryption and decryption with wallet-based authentication
- Paymaster Service: Gas fee sponsorship and transaction execution
- User Metadata Management: User data storage and retrieval
- Sync Service: Service for fast commitments synchronization
- Blockchain Indexer: Real-time event indexing from EVM-compatible blockchains with pub-sub model
- Points Service: Track and update points for users based on onchain activity
- Swagger API Documentation: Interactive API documentation at
/apiendpoint
- NestJS with TypeScript and SWC
- MongoDB with Mongoose for data persistence
- Viem for EVM blockchain interactions
- Jest for unit and e2e testing
- Docker & Docker Compose for development & production
- Swagger for API documentation
- Zod for runtime type validation
- Linters, code formatter, pre-commit and pre-push hooks
- Custom GitHub Actions and quality gate workflow for CI/CD
- Flexible environment configuration with encryption via dotenvx
Interactive API documentation is available at /api endpoint when the service is running.
- Encryption:
/encryption- Data encryption and decryption services - Indexer:
/indexer- Blockchain event indexing and retrieval - Paymaster:
/paymaster- Gas fee sponsorship and transaction execution - Challenge:
/challenge- Authentication challenge generation - User Metadata:
/userMetadata- User data management - Health:
/health- Service health check
npm installThe service requires configuration via environment files in the conf/ directory. All environment variables are documented with comments and mock values in the example files.
-
Create and modify
.envfile inconffolder:cp conf/.example.env conf/.env
-
Update the configuration values in
conf/.env:PORT: Service port (default: 3000)DB_URI: MongoDB connection stringENCRYPTION_PK: Encryption private keyPAYMASTER_PK: Paymaster private keyNETWORK: EVM network name (e.g., "baseSepolia")START_BLOCK: Block number to start indexing fromVAULT_CONTRACT: Vault contract addressFORWARDER_CONTRACT: Forwarder contract addressWS_RPC: WebSocket RPC endpointRPC: HTTP RPC endpointORIGIN: Allowed CORS originCMC_API_KEY: CoinMarketCap API key for gas estimation
-
Create production secrets file:
cp conf/.example.env conf/.prod.secrets.env
-
Update production values in
conf/.prod.secrets.env -
Encrypt production secrets:
npm run env:encrypt
Note: The generated
.prod.secrets.envfile can be publicly shared after encryption. -
Keep the generated
.env.keysfile secure and do not commit it to the repository.
The service uses wallet-based authentication:
- Client requests a challenge number from
GET /challengeendpoint - Client signs the challenge with their wallet
- Client includes the auth jwt in subsequent authenticated requests via cookies & csrf header
# Development mode with hot reload
npm run dev# Development mode with Docker (includes MongoDB)
npm run up.dev# Build the application
npm run build
# Start the application
npm start# Run e2e tests
npm run test.e2e
# Run unit tests
npm test
# Run linting
npm run lint
# Type checking
npm run typechecknpm run dev- Start development server with hot reloadnpm run up.dev- Start with Docker Compose (includes MongoDB)npm run build- Build for productionnpm start- Start production servernpm test- Run unit testsnpm run test.e2e- Run end-to-end testsnpm run lint- Run ESLint with auto-fixnpm run typecheck- Run TypeScript type checkingnpm run clean- Clean build artifacts and databasesnpm run env:encrypt- Encrypt production environment variables
src/
├── app.module.ts # Main application module
├── main.ts # Application bootstrap
├── challenge/ # Authentication challenge system
├── core/ # Core functionality
├── encryption/ # Encryption/decryption services
├── health/ # Health check endpoints
├── indexer/ # Blockchain event indexing
├── paymaster/ # Gas fee sponsorship
├── points/ # Points tracker
├── sync/ # Commitments fast sync service
└── userMetadata/ # User metadata management
Contributions are always welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
See LICENSE file for details.
- Open an issue for bug reports
- Check the API documentation when the service is running