How burninggasontheblock/ebrobridge works
Project Type & Purpose
• This project is a blockchain smart contract system focused on cross-chain token transfers.
• The primary purpose is to enable users to lock ERC-20 tokens on Ethereum (using SickBridgeETH) and then mint equivalent wrapped tokens on Polygon (using WrappedToken) ensuring secure transfers via nonce tracking and ECDSA signature verification.
Main Components
• Ethereum Network:
• SickBridgeETH Contract: Handles token locking. It interacts with an ERC-20 token through the transferFrom function, emits a TokensLocked event (including a unique nonce and a provided signature), and manages administrative control.
• Polygon Network:
• WrappedToken Contract: Handles token minting. This contract verifies an admin signature (via ECDSA) and checks that the nonce has not been reused before minting tokens to the user.
Relationships & Interactions
• When tokens are locked on the Ethereum network:
• The SickBridgeETH contract receives tokens from the user.
• It increments a nonce and emits a TokensLocked event containing the lock details (user, amount, nonce, and signature).
• An off-chain process (or admin tool) then processes the event, signs a message containing the transaction’s details, and, on the Polygon network, the WrappedToken contract is called.
• The WrappedToken contract verifies the signature and nonce before minting the wrapped tokens on Polygon, emitting a TokensMinted event afterward.
Architectural Patterns & Design Principles
• Separation of Concerns: Each network runs its own dedicated smart contract for its specific role (locking vs. minting).
• Event-Driven Interaction: Events (TokensLocked and TokensMinted) drive the state change between networks.
• Security: Use of nonce management prevents replay attacks while ECDSA signature validation ensures that only authorized operations are performed.
• Dependency Management: The project leverages established libraries (OpenZeppelin for secure ERC-20 handling and ECDSA operations) ensuring correctness and security.