A comprehensive bridge transaction indexing and claiming system for the Agglayer ecosystem. This monorepo provides services to monitor, store, expose, and automatically claim bridge transactions across multiple blockchain networks.
The Agglayer Bridge Hub consists of four main packages that work together to provide a complete bridge transaction management solution:
- Commons - Shared TypeScript types and interfaces
- Consumer - Event indexer that syncs bridging transaction data to MongoDB
- API - REST API that exposes bridge transactions and claim proofs
- Auto-Claim - Automated service that claims ready bridge transactions
- Real-time bridge transaction indexing from multiple chains
- RESTful API with OpenAPI documentation
- Automated transaction claiming
- Support for both ASSET and MESSAGE bridge types
- Comprehensive test coverage
- Type-safe development with TypeScript
- Fast development with Bun runtime
COMMONS (Shared Types)
│
┌─────────────────────┼───────┐
│ │ │
▼ ▼ ▼
CONSUMER → MongoDB ← API ← AUTO-CLAIM
(Indexer) (HTTP) (Claimer)
│ │
└─ Aggkit Blockchain
Bridge service
Data Flow: Consumer polls Aggkit Bridge Service for indexed data → Writes to MongoDB → API exposes data → Auto-Claim fetches and submits claims.
For detailed architecture including production cluster setup, cron jobs, and multi-network deployment, see ARCHITECTURE.md (specifically Production Cluster Architecture).
Foundation layer providing shared TypeScript types and interfaces used across all packages.
- TypeScript interfaces for bridge transactions
- Shared enums (transaction status, leaf types)
- API schema definitions
- Type safety across the monorepo
Data ingestion layer that monitors blockchain networks and indexes bridge transactions.
- Monitors bridge smart contracts for deposit/claim events
- Fetches transaction data from Bridge Service API
- Indexes transactions into MongoDB
- Updates claim readiness status
- Maintains token mappings and metadata
Service layer exposing bridge data via REST API with OpenAPI documentation.
- Query bridge transactions with advanced filtering
- Generate claim proofs for ready transactions
- Token metadata and mappings endpoints
- Interactive API documentation via Scalar
- Health check endpoints
API Documentation: Visit /docs endpoint when running the API server to access interactive OpenAPI documentation.
Automation layer that automatically claims ready bridge transactions.
- Polls API for READY_TO_CLAIM transactions
- Fetches merkle proofs for eligible transactions
- Submits claim transactions to destination chains
- Handles ASSET and MESSAGE claim types
- Filters zero-amount MESSAGE transactions
- Bun >= 1.0.0
- MongoDB >= 4.4
- Access to blockchain RPC endpoints
- Aggkit Bridge Service access (for consumer)
# Install dependencies for all packages
bun install# Run all services in development mode (with hot reload)
bun run dev
# Or run individual services
cd packages/api && bun run dev
cd packages/consumer && bun run dev
cd packages/auto-claim && bun run dev# Build all packages
bun run build
# Build specific package
bun run build:api
bun run build:consumer# Run all tests
bun run test
# Run tests for specific package
cd packages/api && bun test
cd packages/consumer && bun test
cd packages/auto-claim && bun testEach package requires specific environment variables. Create .env files in each package directory.
For complete configuration reference including all environment variables, requirements, and examples for each package, see DEPLOYMENT.md - Configuration.
For detailed development workflow including branch strategy, code quality checks, testing guidelines, and contribution process, see CONTRIBUTING.md.
agglayer-bridge-hub-api/
├── packages/
│ ├── commons/ # Shared types and interfaces
│ ├── api/ # REST API server
│ ├── consumer/ # Blockchain indexer
│ └── auto-claim/ # Automated claiming service
├── node_modules/ # Shared dependencies
├── package.json # Root package configuration
├── lerna.json # Lerna monorepo configuration
└── README.md # This file
- Runtime: Bun - Fast JavaScript runtime
- Language: TypeScript - Type-safe development
- Monorepo: Lerna - Package management
- API Framework: Hono - Ultra-fast web framework
- Blockchain: viem - TypeScript Ethereum library
- Database: MongoDB - Document database
- Testing: Bun's built-in test runner
- Build Tool: tsup - TypeScript bundler
When running the API package, visit:
http://localhost:3000/docs
This provides interactive OpenAPI documentation powered by Scalar, where you can:
- Browse all available endpoints
- View request/response schemas
- Test API calls directly in the browser
- Bridge → User bridges tokens (status: BRIDGED)
- Index → Consumer saves to MongoDB
- Ready → Consumer updates (status: READY_TO_CLAIM)
- Claim → Auto-claim fetches proof and submits to chain
- Complete → Consumer updates (status: CLAIMED)
For the complete step-by-step transaction lifecycle with technical details, see ARCHITECTURE.md - Transaction Lifecycle.
All packages include comprehensive test suites. Run tests with:
bun run testFor testing guidelines, coverage requirements, and writing new tests, see CONTRIBUTING.md - Testing Guidelines.
Please read CONTRIBUTING.md for details on our code of conduct, development guidelines, and the process for submitting pull requests.
See DEPLOYMENT.md for production deployment guide.
# Build all packages
bun run build
# Start production services
cd packages/api && bun start
cd packages/consumer && bun start
cd packages/auto-claim && bun startAll packages use @polygonlabs/servercore for structured logging with Sentry integration. Configure SENTRY_DSN environment variable to enable error tracking.
- Private Keys: Never commit private keys. Use secret management systems.
- API Access: Implement rate limiting in production.
- Database: Use authentication and network isolation.
- RPC Endpoints: Use reliable, authenticated RPC providers.
For security vulnerability reporting and bug bounty information, see SECURITY.md.
- Consumer: Processes transactions sequentially per chain
- API: Stateless, can be horizontally scaled
- Auto-Claim: Polls every 30 seconds, single-threaded
- Database: Ensure proper indexing on
status,sourceNetwork,destinationNetwork
Issue: Consumer not indexing transactions
- Check
BRIDGE_SERVICE_URLis accessible - Verify
NETWORK_IDmatches your target network - Check MongoDB connection
Issue: API returning empty results
- Ensure consumer has indexed transactions
- Check MongoDB collections exist
- Verify query parameters
Issue: Auto-claim not claiming transactions
- Check wallet has sufficient gas
- Verify
BRIDGE_HUB_API_URLis correct - Ensure transactions are in READY_TO_CLAIM status
- Check RPC endpoint connectivity
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for the full license text.
For issues and questions:
- Open an issue in the repository
- Check existing documentation
- Review API documentation at
/docsendpoint
Built with modern TypeScript tools and the Bun runtime for optimal performance and developer experience.