Skip to content

Interface

bridge

function bridge(BridgeReq calldata bridgeReq) external returns (bytes32)

Performs a cross-chain transfer of tokens from the source chain to the destination chain.

Parameters

struct BridgeReq
NameTypeDescription
amountuint256amount of tokens to transfer
tokenaddressaddress of the token to transfer
feeTokenaddressaddress of the token to pay the fee
receiveraddressaddress of the receiver on the destination chain
fallbackReceiveraddressaddress of the fallback receiver on the dst chain in case of failure execution layer. A bridge token will simply be sent to this address, no function will be called on it
dstChainSelectoruint64selector of the destination chain
dstChainGasLimituint32gas limit for the destination chain
messagebytesmessage to send to the destination chain

_lancaBridgeReceive

function _lancaBridgeReceive(LancaBridgeMessage calldata message) internal

To receive messages on the destination chain, your contract must inherit from the LancaBridgeClient contract. Within this client contract, the lancaBridgeReceive function is invoked, which enforces that _lancaBridgeReceive can only be called by the LancaBridge contract, ensuring secure and authorized processing.

Parameters

struct LancaBridgeMessage
NameTypeDescription
idbytes32a unique identifier for the bridge message, used for tracking and preventing replay attacks by ensuring that the same message is not processed multiple times
senderaddressthe address of the sender on the source chain who initiated the cross-chain transfer
tokenaddressthe address of the token being transferred across chains
amountuint256the amount of tokens involved in the transfer
srcChainSelectoruint64the identifier of the source chain from which the message originates
databytesadditional data that may include instructions or parameters required for further processing of the transfer on the destination chain

getFee

function getFee(uint64 dstChainSelector, uint256 amount, address feeToken, uint32 dstChainGasLimit) public view returns (uint256)

Parameters

NameTypeDescription
dstChainSelectoruint64selector of the destination chain
amountuint256amount of tokens to transfer
feeTokenaddressaddress of the token to pay the fee
dstChainGasLimituint32gas limit for the destination chain

getBridgeFeeBreakdown

function getBridgeFeeBreakdown(uint64 dstChainSelector, uint256 amount, address feeToken, uint32 dstChainGasLimit) public view returns (uint256, uint256, uint256)

Parameters

NameTypeDescription
dstChainSelectoruint64selector of the destination chain
amountuint256amount of tokens to transfer
feeTokenaddressaddress of the token to pay the fee
dstChainGasLimituint32gas limit for the destination chain

Types

BridgeReq

    struct BridgeReq {
        uint256 amount;
        address token;
        address feeToken;
        address receiver;
        address fallbackReceiver;
        uint64 dstChainSelector;
        uint32 dstChainGasLimit;
        bytes message;
    }

LancaBridgeMessage

    struct LancaBridgeMessage {
        bytes32 id;
        address sender;
        address token;
        uint256 amount;
        uint64 srcChainSelector;
        bytes data;
    }