> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt
> Use this file to discover all available pages before exploring further.

# BridgeSync

> How BridgeSync monitors and indexes bridge events from L1 and L2 networks, and how it provides data to AggSender and Bridge Service

## What BridgeSync Does

BridgeSync monitors bridge contracts on both L1 and L2 networks, captures every bridge-related event, and organizes the data into a local database. It provides the data foundation that other AggKit components depend on: AggSender uses it for certificate construction, and Bridge Service uses it to serve API responses.

**Key responsibilities:**

* **Event monitoring**: Real-time monitoring of bridge contract events on L1 and L2
* **Data indexing**: Comprehensive indexing of bridge and claim transactions
* **State management**: Maintains bridge transaction history and status
* **Reorg handling**: Manages blockchain reorganizations and maintains data integrity
* **API support**: Provides data to Bridge Service APIs

## Why Indexing Matters

Bridge claim verification and status queries require access to bridge transaction history. Without an index, each query would require expensive, slow queries to blockchain nodes or onchain contract calls. BridgeSync captures events as they occur and makes them instantly queryable.

AggSender depends on BridgeSync's data to build certificates: it needs the list of bridge exits and imported bridge exits for each epoch. Bridge Service depends on it to respond to transaction status requests and proof generation queries.

## Architecture

## How BridgeSync Works

### Event Processing Workflow

### Bridge Event Types

#### BridgeEvent

Emitted when assets or messages are bridged from a network:

```solidity theme={null}
event BridgeEvent(
    uint8 leafType,              // 0 = asset, 1 = message
    uint32 originNetwork,        // Source network ID
    address originAddress,       // Sender address
    uint32 destinationNetwork,   // Destination network ID
    address destinationAddress,  // Recipient address
    uint256 amount,              // Amount (for assets)
    bytes metadata,              // Additional data
    uint32 depositCount          // Index in Local Exit Tree
);
```

#### ClaimEvent

Emitted when assets or messages are claimed on a network:

```solidity theme={null}
event ClaimEvent(
    uint256 globalIndex,         // Global transaction index
    uint32 originNetwork,        // Source network ID
    address originAddress,       // Original sender
    address destinationAddress,  // Claim recipient
    uint256 amount               // Claimed amount
);
```

### Data Processing Pipeline

## Integration with Other Components

### AggSender Integration

BridgeSync provides the bridge exit and imported bridge exit data that AggSender packages into certificates:

**Data provided:**

* Bridge exits (outbound transactions from the L2)
* Imported bridge exits (inbound claims to the L2)
* Transaction proofs and metadata
* Block range information for certificate scope

### Bridge Service Integration

BridgeSync is the primary data source for Bridge Service API endpoints:

All Bridge Service endpoints query BridgeSync's local database for transaction data.
