Skip to main content
Version: 0.2.x-amarok

Calls

This section contains a full API reference of all public functions & events related to making and tracking xchain calls.


Events

XCalled

event XCalled(bytes32 transferId, uint256 nonce, bytes32 messageHash, struct TransferInfo params, address asset, uint256 amount, address local)

Emitted when xcall is called on the origin domain of a transfer.

Parameters

NameTypeDescription
transferIdbytes32- The unique identifier of the crosschain transfer.
nonceuint256- The bridge nonce of the transfer on the origin domain.
messageHashbytes32- The hash of the message bytes (containing all transfer info) that were bridged.
paramsstruct TransferInfo- The TransferInfo provided to the function.
assetaddress- The asset sent in with xcall
amountuint256- The amount sent in with xcall
localaddress- The local asset that is controlled by the bridge and can be burned/minted

ExternalCalldataExecuted

event ExternalCalldataExecuted(bytes32 transferId, bool success, bytes returnData)

Emitted when a transfer has its external data executed

Parameters

NameTypeDescription
transferIdbytes32- The unique identifier of the crosschain transfer.
successbool- Whether calldata succeeded
returnDatabytes- Return bytes from the IXReceiver

Executed

event Executed(bytes32 transferId, address to, address asset, struct ExecuteArgs args, address local, uint256 amount, address caller)

Emitted when execute is called on the destination domain of a transfer.

execute may be called when providing fast liquidity or when processing a reconciled (slow) transfer.

Parameters

NameTypeDescription
transferIdbytes32- The unique identifier of the crosschain transfer.
toaddress- The recipient TransferInfo.to provided, created as indexed parameter.
assetaddress- The asset the recipient is given or the external call is executed with. Should be the adopted asset on that chain.
argsstruct ExecuteArgs- The ExecuteArgs provided to the function.
localaddress- The local asset that was either supplied by the router for a fast-liquidity transfer or minted by the bridge in a reconciled (slow) transfer. Could be the same as the adopted asset param.
amountuint256- The amount of transferring asset the recipient address receives or the external call is executed with.
calleraddress- The account that called the function.

TransferRelayerFeesIncreased

event TransferRelayerFeesIncreased(bytes32 transferId, uint256 increase, address caller)

Emitted when _bumpTransfer is called by an user on the origin domain both in xcall and bumpTransfer

Parameters

NameTypeDescription
transferIdbytes32- The unique identifier of the crosschain transaction
increaseuint256- The additional amount fees increased by
calleraddress- The account that called the function

SlippageUpdated

event SlippageUpdated(bytes32 transferId, uint256 slippage)

Emitted when forceUpdateSlippage is called by an user on the destination domain

Parameters

NameTypeDescription
transferIdbytes32- The unique identifier of the crosschain transaction
slippageuint256- The updated slippage boundary

Getters

routedTransfers

function routedTransfers(bytes32 _transferId) public view returns (address[])

Gets a list of routers that routed a transfer by transferId.

Parameters

NameTypeDescription
_transferIdbytes32Unique transfer ID of a given transaction

Return Values

NameTypeDescription
[0]address[]Array containing addresses of routers

transferStatus

function transferStatus(bytes32 _transferId) public view returns (enum DestinationTransferStatus)

Gets a transfer's status by transferId. Note - this function MUST be called on the destination chain.

Parameters

NameTypeDescription
_transferIdbytes32Unique transfer ID of a given transaction

Return Values

NameTypeDescription
[0]enumStatus of the transfer

domain

function domain() public view returns (uint32)

Gets the domain identifier of the chain.

Parameters

NameTypeDescription

Return Values

NameTypeDescription
[0]uint32Domain identifier of the chain

Functions

xcall

function xcall(uint32 _destination, address _to, address _asset, address _delegate, uint256 _amount, uint256 _slippage, bytes _callData) external payable returns (bytes32)

Initiates a cross-chain transfer of funds, calldata, and/or various named properties.

For ERC20 transfers, this contract must have approval to transfer the input (transacting) assets. The adopted assets will be swapped for their local (connext-flavored) asset counterparts (i.e. bridgeable tokens) via the configured AMM if necessary. In the event that the adopted assets are local assets, no swap is needed. The local tokens will then be sent via the bridge router. If the local assets are representational for an asset on another chain, we will burn the tokens here. If the local assets are canonical (meaning that the adopted to local asset pairing is native to this chain), we will custody the tokens here.

Parameters

NameTypeDescription
_destinationuint32The destination chain's Domain ID (not equivalent to “Chain ID”). See [Domains] for details TODO
_toaddressThe target address on the destination chain. xcall will send funds to whatever address is specified here regardless of whether it is a contract or EOA. If calldata is provided, xcall will additionally attempt to call xReceive on this contract.
_assetaddressThe contract address of the asset to be bridged. If the xcall is calldata-only (e.g. doesn't bridge any funds), any registered asset can be used here as long as amount: 0.
_delegateaddressAn address on destination domain that has rights to update slippage tolerance, retry transactions, or revert back to origin in the event that a transaction fails at the destination.
_amountuint256The amount of tokens to bridge specified in wei units (i.e. to send 1 USDC, a token with 10^18 decimals, you must specify the amount as 1000000000000000000).
_slippageuint256The maximum slippage a user is willing to take, in BPS, due to the StableSwap Pool(s), if applicable. For example, to achieve 0.03% slippage tolerance this will be 3.
_callDatabytesIn the case of bridging funds only, this should be empty (""). If calldata is sent, then the encoded calldata must be passed here.

Return Values

NameTypeDescription
[0]bytes32bytes32 - The transfer ID of the newly created crosschain transfer.

xcallIntoLocal

function xcallIntoLocal(uint32 _destination, address _to, address _asset, address _delegate, uint256 _amount, uint256 _slippage, bytes _callData) external payable returns (bytes32)

Helper function that xcalls as normal but forces the receipt of the local (Connext-flavored) asset at destination. This function is used typically to generate nextAssets that can be used to LP into the destination chain stableswap. Params and returned data function exactly the same way as xcall.

execute

function execute(struct ExecuteArgs _args) external returns (bytes32)

Called on a destination domain to disburse correct assets to end recipient and execute any included calldata.

Can be called before or after handle [reconcile] is called (regarding the same transfer), depending on whether the fast liquidity route (i.e. funds provided by routers) is being used for this transfer. As a result, executed calldata (including properties like originSender) may or may not be verified depending on whether the reconcile has been completed (i.e. the optimistic confirmation period has elapsed).

Parameters

NameTypeDescription
_argsstruct ExecuteArgs- ExecuteArgs arguments.

Return Values

NameTypeDescription
[0]bytes32bytes32 - The transfer ID of the crosschain transfer. Should match the xcall's transfer ID in order for reconciliation to occur.

bumpTransfer

function bumpTransfer(bytes32 _transferId) external payable

Anyone can call this function on the origin domain to increase the relayer fee for a transfer.

Parameters

NameTypeDescription
_transferIdbytes32- The unique identifier of the crosschain transaction

forceUpdateSlippage

function forceUpdateSlippage(struct TransferInfo _params, uint256 _slippage) external

Allows a user-specified account (delegate in xcall) to update the slippage they are willing to take on destination transfers. MUST be called on the destination chain.

Parameters

NameTypeDescription
_paramsstruct TransferInfoTransferInfo associated with the transfer
_slippageuint256The updated slippage

Interfaces

xReceive

function xReceive(bytes32 _transferId, uint256 _amount, address _asset, address _originSender, uint32 _origin, bytes _callData) external returns (bytes)

Interface that the Connext contracts call into on the _to address specified during xcall. Developers MUST implement this on the destination chain to receive incoming calldata.

Parameters

NameTypeDescription
_transferIdbytes32Unique id of the xchain transaction
_amountuint256Amount of token, if any, passed into the contract in Wei units
_assetaddressAddress of token, if any, passed into the contract
_originSenderaddressAddress of the contract or EOA that called xcall on the origin chain. NOTE: this param will only be populated if the transaction went through the slow path rather than being executed immediately by a Connext router (see TODO for details)
_originuint32Domain ID of the chain that the transaction is coming from
_calldatabytesData, in bytes, that is passed into xcall on the origin chain