Glacis
  • Overview
  • Glacis Core
    • Why Glacis?
    • Getting Started
    • Concepts
      • Architecture
      • Components
      • Features
        • Abstraction
        • Access Control
        • Redundancy
        • Retry Management
        • Routing
        • xERC20s
      • Governance Model
      • Upgrade Model
      • Security Model
    • Messaging Fees
      • Protocol Fees
      • Gas Overhead
    • Troubleshooting
      • Integration Checklist
      • Error Messages
      • FAQ
    • References
      • Smart Contracts
        • GlacisRouter
        • GlacisClient
        • SimpleTokenMediator
      • Supported Chains
      • Supported GMPS
  • Airlift
    • Why Airlift?
    • Supported Chains & Tokens
  • Architecture Overview
    • On-Chain Interface
    • Off-Chain Interface
  • Operation Overview
  • Send & Execute
Powered by GitBook
On this page
  • Configuration
  • The Send Function
  • Errors
  1. Glacis Core
  2. References
  3. Smart Contracts

SimpleTokenMediator

PreviousGlacisClientNextSupported Chains

Last updated 3 months ago

xERC20s through Glacis.

The SimpleTokenMediator is a 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 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

GlacisRouter.CrossChainGas[] memory fees

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

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

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

GlacisClient
SimpleTokenMediator.sol
Axelar
GMP ID
GlacisRouter