The Erbie-BSC Relayer is a cross-chain bridge service that facilitates token transfers between the Erbie Chain and Binance Smart Chain (BSC). It monitors events on the Erbie Chain, processes them, and executes corresponding transactions on BSC.
- Event Monitoring: Listens for
TokenLocked
events on Erbie Chain - Cross-Chain Transactions: Processes transactions on BSC based on Erbie Chain events
- Transaction Status Tracking: Monitors and updates the status of cross-chain transactions
- Automatic Retry Mechanism: Retries failed transactions up to 3 times
- Event Acknowledgement: Listens for
CrossedSuccess
events on BSC to confirm transaction completion
The relayer consists of several key components:
- Erbie Chain Listener: Monitors the Erbie Chain for
TokenLocked
events - BSC Processor: Executes token minting on BSC when tokens are locked on Erbie Chain
- BSC Listener: Monitors BSC for
CrossedSuccess
events to acknowledge completed transactions - Database Service: Stores and manages transaction data and status
- Retry Mechanism: Automatically retries failed transactions
- Node.js (v14 or higher)
- Yarn package manager
- PostgreSQL database
- Access to Erbie Chain and BSC RPC endpoints
- Private key with sufficient funds for BSC transactions
-
Clone the repository:
git clone https://github.com/yourusername/erbie-bsc-relayer.git cd erbie-bsc-relayer
-
Install dependencies:
yarn install
-
Create a
.env
file based on the provided example:cp .env.example .env
-
Configure your environment variables in the
.env
file:# ErbieChain Configuration ERBIE_RPC_URL=https://rpc.erbie.io ERBIE_BRIDGE_ADDRESS=0x... # BSC Configuration BSC_RPC_URL=https://bsc-dataseed.binance.org/ BSC_LLA_CONTRACT_ADDRESS=0x... BSC_PRIVATE_KEY=your_private_key_here # Database Configuration DATABASE_URL=postgres://username:password@localhost:5432/erbie_bsc_relayer
-
Compile TypeScript:
yarn tsc
Start the relayer service:
node dist/index.js
The service will:
- Connect to the database and sync the schema
- Start listening for
TokenLocked
events on Erbie Chain - Start listening for
CrossedSuccess
events on BSC - Initialize the retry mechanism for failed transactions
Run the test suite with:
yarn test
The tests use an in-memory SQLite database for testing database operations.
src/
index.ts
- Main entry pointconfig.ts
- Configuration managementdbService.ts
- Database models and operationserbieListener.ts
- Erbie Chain event listenerbscProcessor.ts
- BSC transaction processorbscListener.ts
- BSC event listener__tests__/
- Test files
- Enhanced Error Handling: Implement more robust error handling and recovery mechanisms
- Logging System: Add a structured logging system for better monitoring and debugging
- Metrics Collection: Implement metrics collection for monitoring service performance
- API Endpoints: Add REST API endpoints for querying transaction status
- Admin Dashboard: Create a web interface for monitoring and managing transactions
- Gas Price Management: Implement dynamic gas price adjustment for BSC transactions
- Multi-token Support: Extend support for multiple token types
- Security Enhancements: Add additional security measures for private key management
MIT