GlacisTokenMediator

Your gateway to cross-chain token activity.

The GlacisTokenMediator smart contract acts as the on-chain interface for all token cross-chain activity with Glacis.

You can discover the source smart contract GlacisTokenMediator.sol in this repository.

The Route Function

The main function in GlacisTokenMediator is route, which sends a cross-chain message and/or tokens. Using the GlacisTokenMediator to send tokens will always have retryable be enabled.

function route(
        uint256 chainId,
        bytes32 to,
        bytes memory payload,
        address[] memory adapters,
        GlacisCommons.CrossChainGas[] memory fees,
        address refundAddress,
        address token,
        uint256 tokenAmount
  ) payable returns (bytes32, uint256)

Internally this function is in charge of populating GlacisTokenData, adding it to the payload and finally routing it to the GlacisRouter

Here is a detailed description of function parameters.

Parameter NameParameter Description

uint256 chainId

The Glacis ID of the blockchain that you wish to send a message and/or tokens to

bytes32 to

The address of the destination contract that you are sending a message and/or tokens to

bytes memory payload

The payload (message) of data that you wish to send to the destination contract

address[] memory adapters

An array of adapters to send the message over, such as an Axelar adapter. Can be an address if you wish to use an adapter that Glacis does not use, otherwise it can be a GMP ID stored as an address

GlacisRouter.CrossChainGas[] memory fees

An array of fees that correspond to the amount provided to each adapter. This is a parallel array to the adapters parameter. The sum of the "nativeCurrencyValue" must be equal to the value sent with this function

address refundAddress

The address to which excess native currency is sent to if an adapter deems that the user overpaid

address token

The address of the XERC20 token you wish to send to the destination contract

uint256 tokenAmount

The amount of XERC20 tokens you wish to send to the destination contract

The Retry Route

An additional route is provided, which doesn't send a new message and/or tokens. Instead, it allows resending of a previous message and/or tokens so long as it receives identical input.

function routeRetry(
        uint256 chainId,
        bytes32 to,
        bytes memory payload,
        address[] memory adapters,
        GlacisCommons.CrossChainGas[] memory fees,
        address refundAddress,
        bytes32 messageId,
        uint256 nonce,
        address token,
        uint256 tokenAmount)
  public payable virtual returns (bytes32)

This route cannot be used for original cross-chain messages. Instead, it is used to retry a cross-chain message with an identical message ID and identical data (but potentially through a different GMP). This can be helpful in cases where a message is somehow lost by a GMP's consensus mechanism or its relayers. An identical message would be sent, and whichever message arrives after the first will revert.

Two additional parameters are required with this function:

Parameter NameParameter Description

bytes32 messageId

The Glacis message ID of the original message

uint256 nonce

The nonce of the message, which can be retrieved in the original message's event log

Only the original message sender can retry a message, no other address can do it on their behalf. Also note that identical data must be provided.

Errors

It also includes the following errors, some of which you may encounter:

Error NameError Description

GlacisTokenMediator__OnlyTokenRouterAllowed

Occurs when routing, and the from address of the receiving payload is not the same token router on the remote chain

Last updated