Adapters
Overview
Adapters are smart contracts that integrate with specific bridges and are used by other contracts—such as Message Controllers, Asset Controllers, and others—that need to communicate across chains. Lucid develops and deploys these adapter contracts across all chains supported by both Lucid and the corresponding bridge.
Adapter contracts are permissionless, meaning anyone can call them to relay a message to a supported chain, as long as an adapter contract exists for that target chain.
Functionality
An adapter's primary role is to relay and receive messages to and from the bridge. These messages are typically sent by a contract on the same chain, such as a Message Controller.
The adapter:
- Repackages the message to include the original
msg.sender(typically the Message Controller) and the destination address (usually the Message Controller on the destination chain) - Does not inspect or modify the message content; it supports arbitrary
bytes[]data - Uses the bridge to relay the message to the corresponding adapter on the destination chain
On the destination chain, the adapter:
- Unpacks the message to recover the original
msg.senderfrom the source chain and the intended destination address - Forwards the original message to the destination contract
Fees
The protocol charges a relay fee for processing cross-chain messages. This fee is applied on top of the bridge fee charged by the underlying messaging layer.
By default, the protocol fee is set to 30% of the bridge fee.
Example:
If the underlying bridge (e.g., LayerZero) requires a fee of 0.0001 ETH to send a message, the protocol adds a 30% fee (0.00003 ETH).
The user will therefore pay a total of 0.00013 ETH, all denominated in the chain's native token (ETH).
Note that fees are always paid in the native token of the chain.
Interfaces
Public Functions
Each adapter implements the following public functions:
relayMessage
function relayMessage( uint256 destChainId, address destination, bytes memory options, bytes calldata message ) external payable returns (bytes32)Sends a message to the Bridge, paying any fees to the bridge and deducting the protocol fee. Any excess fees are returned to the refundAddress.
Input Params:
| Type | Name | Description |
|---|---|---|
| uint256 | destChainId | The destination chain ID. |
| address | destination | The destination address. |
| bytes | options | Additional params to be used by each adapter. Usually the refund address and the gas limit. |
| bytes | message | The message to be relayed. |
The function returns a bytes32 transferId for the bridges that support it.
View Functions
Each adapter implements the following view functions:
isChainSupported
function isChainIdSupported(uint256 chainId) public view returns (bool);Checks if a given chain ID is supported by the adapter.
trustedAdapters()
function trustedAdapters(uint256 chainId) external view returns (address);Returns the contract address of the Adapter for a given chain id. Will return address(0) if an adapter doesn't exist on that chain.
isTrustedAdapter()
function isTrustedAdapter(uint256 chainId, address adapter) external view returns (bool);Returns true if the given adapter is a trusted adapter for the specified chain ID

