Integration
Smart contract integration
sendToL2(
uint256 chainId,
address recipient,
uint256 amount,
uint256 amountOutMin,
uint256 deadline,
address relayer,
uint256 relayerFee
)
The
relayer
and relayerFee
is only used if a 3rd party is relaying the transfer on the user's behalf (ie the relayer is paying for transaction fee). You can set the relayer
to the zero address and relayerFee
to 0
if you are not using a relayer (majority of integrations do not use a relayer).swapAndSend(
uint256 chainId,
address recipient,
uint256 amount,
uint256 bonderFee,
uint256 amountOutMin,
uint256 deadline,
uint256 destinationAmountOutMin,
uint256 destinationDeadline
)
Note: Do not set
destinationAmountOutMin
and destinationDeadline
when sending to L1 because there is no AMM on L1, otherwise the computed transferId will be invalid and the transfer will be unbondable. These parameters should be set to 0
when sending to L1.send(
uint256 chainId,
address recipient,
uint256 amount,
uint256 bonderFee,
uint256 amountOutMin,
uint256 deadline
)
Note: There are no hTokens on L1 so sending L2 hUSDC to L1 means you'll receive USDC on L1.
Note: Do not set
amountOutMin
and deadline
when sending to L1 because there is no AMM on L1, otherwise the computed transferId will be invalid and the transfer will be unbondable. These parameters should be set to 0
when sending to L1.When sending native asset from source chain (ie ETH on Ethereum, Optimism, Arbitrum, or XDAI on Gnosis Chain, or MATIC on Polygon), set the transaction
value
to match the amount
parameter.swapAndSend
(on L2 AMM Wrapper) on the source chain swaps your canonical token (eg USDC) to hTokens (eg hUSDC) and burns the hTokens and then you receive the canonical tokens (eg USDC) on the destination chain.send
on (on L2 Bridge) is for only dealing with hTokens. The send
method on the source chain takes your hTokens (ie hUSDC), burns the hTokens and then you receive hTokens (eg hUSDC) on the destination chain.swapAndSend is what you'd want to use most of the time since the canonical tokens are what users are interested in.
Some good examples you can check out as a reference are:
The L1 Bridge addresses, L2 Bridge addresses, L2 AMM wrapper addresses, and other Hop contract addresses can be found on this link:
Last modified 2mo ago