The SDK offers convenience functions to make bridges that handle all the low level logic of fetching/committing quotes and making the correct blockchain transactions needed.
amount
& token
specify how much of which token should be bridged.chainIn
& chainOut
specify the origin (chainIn
) and destination (chainOut
) chain.depositor
specifies the address that will send the funds on the origin chain.recipient
specifies the address that will receive the funds on the destination chain.mode
specifies if the fees should be added on top of the amount
or subtracted from it. Learn more about the bridge modesgasBoost.amountNative
specifies the amount of native tokens that should be sent to the recipient address on top of the bridged tokens.getChainAdapter
is mandatory.
false
is returned, the bridge will be aborted.bridge
function will poll the Rhino API until the bridge has been confirmed as completed. By default the polling will be aborted after a default timeout of 10 minutes. With this property you can specify a different timeout.
bridge
function will fetch the current bridge and swap tokens (if needed) config from the Rhino API. If you already fetched those configs manually for some other purpose you can pass it into this property to avoid the extra network requests.
bridge
function will return a result object with nullable data
and error
properties. If the bridge was successful, the data
property will contain:
depositTxHash
: The hash of the transaction on the origin chain that sent the funds to the bridge contract.withdrawTxHash
: The hash of the transaction on the destination chain that sent the funds to the recipient address.error
property will contain the exact error that happened and potentially some additional properties to provide more context to the error. For example, if the given route is not supported you might receive a bridge result like this: