Wormhole Adapter

Lucid has developed an adapter that integrates with the Wormhole messaging bridge to send and receive cross-chain messages.

Fees

Wormhole supports on-chain fee quoting, which the adapter contract uses to estimate the total fees required for a message.

When sending or exporting a transaction from the Lucid App, Lucid automatically calculates the necessary fees, including any applicable protocol fees.

Wormhole also refunds any excess gas fees that are sent. Using the on-chain quote function, the Wormhole Adapter contract determines whether any excess Ether was included and refunds it to the refundAddress specified in the options field.

Interfaces

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 through the Wormhole bridge, deducting the protocol fee and paying the required bridge fee.

  • The Ether value sent by the calling contract must include both the Wormhole fee and the Lucid protocol fee.

  • Any excess fees are refunded to the refundAddress and the refundChainId specified in the Options struct.

  • Returns a bytes32 value representing the sequenceId (cast from a uint256) as generated by Wormhole.

Input Params:

Type
Name
Description

uint256

destChainId

The destination chain ID.

address

destination

The destination address.

bytes

options

Additional params to be used by the adapter, an abi encoded Options struct (see below)

bytes

message

The message to be relayed.

    /// @notice Options to be used when sending a message to Wormhole
    struct Options {
        address refundAddress;
        uint256 refundChainId;
        uint256 gasLimit;
    }

quoteMessage

function quoteMessage(uint256 chainId, uint256 gasLimit, bool includeFee) external view returns (uint256)

Calculates the total fee required to send a message using Wormhole’s on-chain quoting mechanism. Returns the estimated fee amount in Ether.

Input Params:

Type
Name
Description

uint256

chainId

The destination chain ID

uint256

gasLimit

The gas limit required for the execution in the destination chain

bool

includeFee

Whether to include the protocol fee in the calculation

Last updated