> For the complete documentation index, see [llms.txt](https://docs.ilayer.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ilayer.io/router/layerzero-router.md).

# LayerZero Router

This `LzRouter` contract is a LayerZero-powered implementation of the `Router` contract that lets users send and receive arbitrary payloads across supported chains. It extends LayerZero’s `OApp` base to:

1. Map between standardised chain IDs and LayerZero EIDs
2. Send messages via LayerZero (using the option `Bridge.LAYERZERO`)
3. Estimate the native fee required for a given cross-chain call
4. Receive incoming LayerZero messages and dispatch them to a target contract Implementing a `onMessageReceived` hook

{% @mermaid/diagram content="sequenceDiagram
participant SourceContract
participant LzRouter(A)
participant LzRouter(B)
participant DestContract

```
SourceContract->>LzRouter(A): send(message)
LzRouter(A)-->>LzRouter(A): revert if chain unsupported
LzRouter(A)->>LzRouter(B): relay message
LzRouter(B)-->>DestContract: Invoke onMessageReceived method
```

" %}

***

#### Events

| Event             | Parameters                                                                      | Description                                                                             |
| ----------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| `LzEidUpdated`    | <p><code>uint32 indexed chainId</code><br><code>uint32 indexed lzEid</code></p> | Emitted whenever the owner sets or updates the mapping for a chain’s LayerZero EID.     |
| `MessageRoutedLz` | `MessagingReceipt msg`                                                          | Emitted after successfully sending a LayerZero message; includes the LayerZero receipt. |

***

#### Errors

| Error                        | When It’s Thrown                                                                    |
| ---------------------------- | ----------------------------------------------------------------------------------- |
| `UnsupportedLzChain()`       | In `_sendWithLz`, if no LayerZero EID has been configured for the target `chainId`. |
| `UnsupportedBridgingRoute()` | In `send()`, if the caller specifies any bridge other than `Bridge.LAYERZERO`.      |
