LogoLogo
  • ⏩Introduction
    • Hyperlane Introduction
    • Getting started
    • Why Should You Use Hyperlane?
  • Permissionless Interoperability
    • Overview
    • Deploy Hyperlane
    • Warp Routes
      • Deploy a Warp Route
      • Deploy a UI for your Warp Route
    • Modular Rollup Interoperability
  • Build With Hyperlane
    • Quickstarts
      • Messaging
      • Accounts
      • Queries
      • hyperlane-quickstart repo
    • Guides
      • Finding my messages
      • Automatically pay for interchain gas
      • Manually pay for interchain gas
      • Choosing an interchain gas paymaster contract
      • Unit testing
      • Specifying an ISM
      • V2 migration guide
    • Explorer
      • Debugging messages
      • Configuring PI Chains
      • REST API
      • GraphQL API
    • Troubleshooting/Developer FAQ
    • Example apps
  • APIs and SDKs
    • Messaging API
      • Send
      • Receive
    • Accounts API
    • Queries API
    • Warp Route API
    • Interchain gas paymaster API
    • Hyperlane App Framework
      • Example usage
        • HelloWorld
        • Interchain Token
      • Solidity SDK
        • HyperlaneConnectionClient
        • Router
      • NodeJS SDK
        • RPC Providers
        • Deployment
        • Interchain testing
        • Quoting gas payments
        • App Abstraction
    • Hooks API
      • Contract addresses
  • Protocol
    • Overview
    • Mailbox
    • Interchain security modules
      • Interface
      • Multisig ISM
      • Routing ISM
      • Aggregation ISM
      • Optimistic ISM
      • Wormhole ISM
      • Hook ISM
      • CCIP-Read ISM
    • Interchain gas payments
    • Staking and slashing
    • Agents
      • Validators
      • Relayers
      • Watchtowers
    • Warp Routes
    • Implementation Guide
  • Operators
    • Validators
      • Guide
      • AWS setup
      • Monitoring and alerting
    • Relayers
      • Guide
      • Message filtering
    • Agent keys
      • Hexadecimal keys
      • AWS KMS keys
    • Agent configuration
      • Configuration reference
    • Running with docker compose
  • Resources
    • FAQ
    • Glossary
    • Contract addresses
      • Permissionless Deployment Contract Addresses
    • Domain identifiers
      • Permissionless Domain Identifiers
    • Default ISM settings
    • Coming Soon: Hyperlane v3
    • Token sources & faucets
    • Latencies
    • Github
    • Discord
    • Website
Powered by GitBook
On this page
  1. APIs and SDKs
  2. Hyperlane App Framework
  3. Example usage

Interchain Token

An interchain ERC20 token contract

PreviousHelloWorldNextSolidity SDK

Last updated 2 years ago

**** **** app is an interchain ERC20 token contract using the

The shows an example Interchain Token, an ERC20 that can travel between any Hyperlane chain, also called a HypERC20.

The changes to the vanilla OpenZeppelin ERC20 contract are minimal. It has a transferRemote() function that burns the specified amount of tokens on the sending chain and mints the equivalent amount on the receiving chain.

Contract

Its implements a transferRemote method which burns tokens and dispatches corresponding messages.

/**
 * @notice Transfers `_amount` of tokens from `msg.sender` to `_recipient` on the `_destination` chain.
 * @dev Burns `_amount` of tokens from `msg.sender` on the origin chain and dispatches
 *      message to the `destination` chain to mint `_amount` of tokens to `recipient`.
 * @param _destination The identifier of the destination chain.
 * @param _recipient The address of the recipient on the destination chain.
 * @param _amount The amount of tokens to be sent to the remote recipient.
 */
function transferRemote(
    uint32 _destination,
    address _recipient,
    uint256 _amount
) external payable {
    _burn(msg.sender, _amount);
    _dispatchWithGas(
        _destination,
        Message.format(_recipient, _amount),
        gasAmount,
        msg.value,
        msg.sender
    );
}

It also requires a _handle method which mints tokens upon receiving messages.

/**
 * @dev Mints tokens to recipient when router receives transfer message.
 * @param _origin The identifier of the origin chain.
 * @param _message The encoded remote transfer message containing the recipient address and amount.
 */
function _handle(
    uint32 _origin,
    bytes32,
    bytes memory _message
) internal override {
    (address recipient, uint256 amount) = abi.decode(
        _message,
        (address, uint256)
    );
    _mint(recipient, amount);
}
ERC20 Token
App framework.
hyperlane-token repo
contract