SimpleTokenMediator

xERC20s through Glacis.

The SimpleTokenMediator is a GlacisClient whose purpose is to transport xERC20 tokens across chains. By using the SimpleTokenMediator for xERC20, you can easily add additional bridges through a single interface & define advanced security rules based off of token payloads.

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

The constructor arguments for the SimpleTokenMediator are identical to an ownable GlacisClient:

  • The address of GlacisRouter

  • The default GMP quorum for this contract to effectively receive a message

  • The owner of the contract

    constructor(
        address _glacisRouter,
        uint256 _quorum,
        address _owner
    ) GlacisClient(_glacisRouter, _quorum) {
        _transferOwnership(_owner);
    }

Configuration

Similar to the GlacisClient, routes and quorum must be configured properly to build your firewall. You can check the GlacisClient page for more information.

The SimpleTokenMediator must also know which token it is sending across chains, which can be set with the setXERC20 function.

function setXERC20(address _xERC20Token) public onlyOwner {
    xERC20Token = _xERC20Token;
}
Parameter Name
Parameter Description

address _xERC20Token

The address of your xERC20 that this SimpleTokenMediator should bridge

The xERC20 that you control ought to also give this newly deployed SimpleTokenMediator burn & mint abilities.

The Send Function

Sending a token across chains is similar to sending a token via Glacis client, where the adapaters and fees are still defined.

function sendCrossChain(
    uint256 chainId,
    bytes32 to,
    address[] memory adapters,
    CrossChainGas[] memory fees,
    address refundAddress,
    uint256 tokenAmount) 
public payable virtual returns (bytes32, uint256)
function sendCrossChainRetry(
    uint256 chainId,
    bytes32 to,
    address[] memory adapters,
    CrossChainGas[] memory fees,
    address refundAddress,
    bytes32 messageId,
    uint256 nonce,
    uint256 tokenAmount) 
public payable virtual returns (bytes32, uint256)
Parameter Name
Parameter Description

uint256 chainId

The Glacis chain ID of the blockchain that you wish to send a token to

bytes32 to

The address of the destination contract that you are sending a token to

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. Its rules are the same as in the GlacisRouter

address refundAddress

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

uint256 tokenAmount

The amount tokens to send to the destination chain

By default, these messages are retriable. All messages return a bytes32 messageID and a uint256 nonce.

Errors

Error Name
Error Description

SimpleTokenMediator__DestinationChainUnavailable()

Occurs when the destination chain has no remote counterpart

Last updated