Bridge
Bridge
This page explains how to bridge the Branded Stablecoins from one chain to another to a specified recipient address.
Transaction Flow
Wallet A
has some balance of theBoringVault
token onchain A
.In order to bridge the
BoringVault
token fromchain A
tochain B
,Wallet A
must callTeller.bridge(...)
function.The
bridge
function ispayable
, meaning it must be called with an accompanyingvalue
field to send the native coin of the blockchain as a bridge fee payment.To determine how much
value
to send in this transaction, use theTeller.previewFee
function, which has an identical interface to thebridge
function.
Take the
uint256 fee
return value from thepreviewFee
query, then send the fee as thevalue
field of the transaction when callingbridge
.Once the
Teller.bridge(...)
function succeeds, theBoringVault
token will arrive atchain B
after some delay, depending on which cross chain messaging protocol is being used for the implementation.
Functions
struct BridgeData {
uint32 chainSelector;
address destinationChainReceiver;
ERC20 bridgeFeeToken;
uint64 messageGas;
bytes data;
}
function previewFee(
uint256 shareAmount,
BridgeData calldata data
) external view returns (uint256 fee) {
return _quote(shareAmount, data);
}
function bridge {
uint256 shareAmount,
BridgeData calldata data
} public payable requiresAuth returns (bytes32 messageId)
shareAmount
The amount of
BoringVault
tokens you wish to bridge.
BridgeData data
chainSelector
Identifier of the chain, but note that this is not equivalent to a chainId. This identifier depends on what crosschain bridging protocol is being used for the
BoringVault
token.For LayerZero implementation, the
chainSelector
must use LayerZeroEndpoint ID
s.For Hyperlane implementation, the
chainSelector
must use HyperlaneDomain Identifier
s.
destinationChainReceiver
The address that will receive the bridged funds.
bridgeFeeToken
The token you are using to pay the bridging fee.
Must be
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
in order to indicate that the native token of the chain is being used to pay the bridging fees.
messageGas
The gas limit enforced upon the transaction that lands on the destination chain. This should be between 300K to 500K gas for most usecases.
data
Can be arbitrary data, but should be empty bytes
""
for most usecases. Exists for potential future backwards compatibility with the receiving function on the destination contract.
See Example Code
Last updated