/Developers. · 02.

Choosing a bridge: the Router and the Bridge enum

One argument selects LayerZero, Axelar or same-chain execution. What the Router does with it, what it refuses, and which routes are coming.

iLayer.io~6 min5 chapters
Bridge enumLzRouterAxRouter
/Router./Bridge enum.OrderHubOrderSpokeMessage/send.RouterwhitelistLAYERZEROAXELARNULL · localCCIPACROSSEVERCLEARsoonUnsupportedBridgingRoute()
/Router.OrderHubOrderSpokeMessage/send.RouterwhitelistLAYERZEROAXELARNULL · localCCIPACROSSEVERCLEARsoonUnsupportedBridgingRoute()

Hub and Spoke do not know how to cross a chain. They hand a Message to a Router and say which bridge to use. That single enum argument is the whole bridge decision an integrator makes, and it can be changed per order without touching code. Dapps can pick a provider or let the user pick.

enum Bridge { NULL, LAYERZERO, AXELAR, CCIP, ACROSS, EVERCLEAR, WORMHOLE }

struct Message {
  Bridge  bridge;       // which bridge to use
  uint32  chainId;      // destination chain id
  bytes32 destination;  // receiver on the destination chain
  bytes   payload;      // arbitrary data to deliver
  bytes   extra;        // bridge-specific extra data
  bytes32 sender;
}
/01 · Chapter.

What a Router is

The BaseRouter is an interface for a generic cross-chain message router: callers pass a Message, pay any required fee, and if the chosen bridge is supported on this chain the router emits MessageBroadcasted. Otherwise it reverts with UnsupportedBridgingRoute().

Only whitelisted contracts may call it (NotWhitelisted otherwise). That protects the privileged messaging infrastructure from attackers and keeps the event log free of noise. On each chain a Router supporting one or both of the current bridges is deployed.

/02 · Chapter.

LAYERZERO: the LzRouter

The LzRouter extends LayerZero’s OApp. It maps standard chain ids to LayerZero EIDs, sends messages, estimates the native fee for a call, and on arrival dispatches the payload to the target’s onMessageReceived hook. If no EID is configured for a chain it reverts with UnsupportedLzChain(). Use it on any chain LayerZero supports.

/03 · Chapter.

AXELAR: the AxRouter

The AxRouter maps chain ids to Axelar chain names, keeps a peer router address per remote chain, and dispatches incoming messages to the right contract. It refuses unknown chains with UnsupportedAxChain() and refuses messages that do not come from the configured peer with InvalidPeer(). Use it on any chain Axelar supports.

An AxLzRouter exists too: one contract that supports both, for chains where both bridges are live.

/04 · Chapter.

NULL: same-chain execution

The NullRouter does not bridge. If message.chainId equals block.chainid it delivers the payload immediately to the target; otherwise it reverts. Every router supports the null route, so an integrator gets same-chain order flow, the same RFQ, the same custody model, with the same code path. Set source and destination chain id to the same value and pick NULL.

/05 · Chapter.

Coming routes

The enum already reserves CCIP, ACROSS, EVERCLEAR and WORMHOLE. Chainlink CCIP and Across are next on the roadmap. Because the choice is an argument, adding a route means deploying a router, not migrating integrators.

/Read next.

Example: LP on Aave from another chain.

Next: a complete order that turns WETH on Base into an Aave position on Arbitrum.

All posts