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.

function route(
  uint256 chainId,
  address to,
  bytes memory payload,
  uint8[] memory gmps,
  uint256[] memory fees,
  bool retriable,
  address token,
  uint256 tokenAmount
  ) public payable virtual returns (bytes32)

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

address 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

uint8[] memory gmps

An array of GMP Ids that you wish the message to send over (identical messages will be sent over with the same message ID, which helps with redundancy)

uint8[] memory fees

An array of fees to pay for each GMP to be used

bool retriable

Whether to allow the message to be retried (stores owner of the message ID on-chain, slightly more gas expensive)

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,
  address to,
  bytes memory payload,
  uint8[] memory gmps,
  uint256[] memory fees,
  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.


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

Error NameError Description


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

Last updated