Composable Bridging
Use Across to bridge + execute a transaction
What is Composable Bridging:?
You can instruct Across to execute a transaction upon filling your deposit on the destination chain. This transaction would be executed atomically with the fill transaction.
NOTE: The transaction that gets executed on the destination chain must be non-reverting otherwise user deposits may risk getting locked.
How does it work?
When a relayer fills your deposit by calling fillRelay()
on the destination SpokePool, if the deposit has a message attached, then the SpokePool will attempt to call handleAcrossMessage()
on your recipient address and pass in the following params:
Requirements
The deposit
message
is not emptyThe
recipient
address is a contract on the destinationChainId that implements a publichandleAcrossMessage(address,uint256,bool,address,bytes)
function, and this function must be non-revertingThe additional gas cost to execute the above function is compensated for in the deposit's
relayerFeePct
Detailed instructions
Construct your
message
Use the Across API to get an estimate of the
relayerFeePct
you should set for your message and recipient combinationCall
deposit()
passing in your messageOnce the relayer calls
fillRelay()
on the destination, your recipient'shandleAcrossMessage
will be executed
Example: Implementing a Bridge and Unwrap
Imagine that I want to bridge ETH from Ethereum to Optimism and receive ETH, not wrapped WETH on Optimism
I will deploy the following contract on Optimism which unwraps received WETH into ETH and sends to a designated
owner
EOA
Call Across-API’s /suggested-fees endpoint with params
?token=0xWETH-on-ethereum-address&destinationChainId=10&amount= x&originChainId=1&recipient=
MyUnwrapper.address&message=0x1234
Here we set
message
to something useless but not-zero so that the destinationSpokePool
ultimately callshandleAcrossMessage
onMyUnwrapper
Last updated