1---2name: cross-chain-bridge3description: Build cross-chain messaging and asset bridging — lock-and-mint, liquidity networks, and message verification4---56## When to activate78- Building token bridges between EVM chains9- Implementing cross-chain messaging protocols10- Designing wrapped asset mechanisms (wrapped ETH on Polygon, etc.)11- Integrating existing bridges (LayerZero, Wormhole, Axelar)12- Building cross-chain NFT bridges1314## When NOT to use1516- For single-chain applications17- For centralized exchange transfers18- For off-chain cross-database synchronization1920## Instructions21221. **Choose bridge pattern.** Lock-and-mint (canonical), liquidity network (fast), or message-passing (general).232. **Select verification.** Validators (centralized), optimistic (fraud proofs), or light client (trustless but expensive).243. **Implement lock side.** Deposit contract, event emission, nonce tracking, replay protection.254. **Implement mint side.** Verification of source chain event, mint/claim function, replay protection.265. **Handle edge cases.** Source chain reorgs, validator downtime, stuck transactions, partial fills.276. **Security.** Multi-sig for validators, rate limiting, maximum bridge amounts, emergency pause.287. **Testing.** Simulate both chains with Foundry. Test reorg scenarios, validator failures, concurrent bridges.2930## Example3132```33Lock-and-Mint Bridge Flow:3435Source Chain (Ethereum):361. User deposits 1 ETH to Bridge contract372. Bridge emits LockedEvent(user, amount, destinationChain, nonce)383. Relayer picks up event3940Destination Chain (Polygon):414. Relayer submits proof of LockedEvent425. Verifier confirms event authenticity (validator signatures)436. Bridge mints 1 WETH on Polygon to user447. User can redeem WETH back to ETH via reverse flow45```