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
| Name | Type | Description |
|---|---|---|
| amount | uint256 | amount of tokens to transfer |
| token | address | address of the token to transfer |
| feeToken | address | address of the token to pay the fee |
| receiver | address | address of the receiver on the destination chain |
| fallbackReceiver | address | address 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 |
| dstChainSelector | uint64 | selector of the destination chain |
| dstChainGasLimit | uint32 | gas limit for the destination chain |
| message | bytes | message to send to the destination chain |
_lancaBridgeReceive
function _lancaBridgeReceive(LancaBridgeMessage calldata message) internalTo 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
| Name | Type | Description |
|---|---|---|
| id | bytes32 | a unique identifier for the bridge message, used for tracking and preventing replay attacks by ensuring that the same message is not processed multiple times |
| sender | address | the address of the sender on the source chain who initiated the cross-chain transfer |
| token | address | the address of the token being transferred across chains |
| amount | uint256 | the amount of tokens involved in the transfer |
| srcChainSelector | uint64 | the identifier of the source chain from which the message originates |
| data | bytes | additional 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
| Name | Type | Description |
|---|---|---|
| dstChainSelector | uint64 | selector of the destination chain |
| amount | uint256 | amount of tokens to transfer |
| feeToken | address | address of the token to pay the fee |
| dstChainGasLimit | uint32 | gas limit for the destination chain |
getBridgeFeeBreakdown
function getBridgeFeeBreakdown(uint64 dstChainSelector, uint256 amount, address feeToken, uint32 dstChainGasLimit) public view returns (uint256, uint256, uint256)Parameters
| Name | Type | Description |
|---|---|---|
| dstChainSelector | uint64 | selector of the destination chain |
| amount | uint256 | amount of tokens to transfer |
| feeToken | address | address of the token to pay the fee |
| dstChainGasLimit | uint32 | gas 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;
}