XY Finance
  • Getting Started
  • XY Token
  • Supported Blockchains/Bridges/DEXs
  • Fee Structure
    • 🌉yBridge Fee Information
    • 🌉(Legacy) XY Bridge Fee Information
  • products
    • Bridge Aggregator : XY Finance
      • Gasless Transaction
    • Bridge : yBridge
      • Yield Farming
      • Omnichain Settlement
      • Consensus
    • Refuel
    • Proxy Bridge
    • Cross Chain Infrastructure
  • Bridge Aggregator Integration
    • XY Finance API (Multiple Bridges Aggregator)
      • 1️⃣Get Quote
      • 2️⃣Get Allowance
      • 3️⃣Build Approval Transaction
      • 4️⃣Build Swap Transaction
      • 5️⃣Get Cross-Chain Status
      • 6️⃣Get MinimumSwapAmount
      • ✔️Recommended Tokens
      • ✅Supported Blockchains/Bridges/DEXs
      • 📩Error Message
      • 💰Monetization / Take Fees
      • 📄Change Log
    • XY Finance Widget (iframe)
      • (Legacy) XY Finance Widget (iframe)
    • XY Finance Widget (NPM)
      • 1️⃣Install the Widget
      • 2️⃣Configure the Widget
      • 3️⃣Customize the Theme
      • 📘Widget API Reference
      • 📄Change Log
    • Custom-Built Link
    • Token Listing
  • Single Bridge Integration
    • yBridge API
      • 1️⃣Get Quote
      • 2️⃣Get Allowance
      • 3️⃣Build Approval Transaction
      • 4️⃣Build Swap Transaction
      • 5️⃣Get Cross-Chain Status
      • 🚰Get Pool Liquidity
      • 💲Get Fee Structure
      • ✔️Recommended Tokens
      • ✅Supported Blockchains
      • 📩Error Message
      • 📄Change Log
    • yBridge Contract Integration
      • Integrate YBridge Contract
        • Bridge Example
        • Latest Upgrade ( 2024/07/17 )
        • Migrate from V2 to V3
      • Integrate YBridgeVault Contract
        • Maximum Available Liquidity
        • Migrate from V2 to V3
      • (Legacy) Integrate X Swap Contract
        • (Legacy) Bridge Example
      • (Legacy) Integrate Y Pool Contract
        • (Legacy) Maximum Available Liquidity
    • xAsset Bridge
      • How to Develop Under XY Standards
        • Function Interface for Token Contract
      • How to Deposit / Withdraw Liquidity
        • Direct Contract Interaction
        • Through the Explorer
      • Set up Your Own Validator
  • SMART CONTRACT
    • Addresses
      • Ethereum (chain id : 1)
      • BNB Chain (chain id : 56)
      • Polygon (chain id : 137)
      • Cronos (chain id : 25)
      • Avalanche (chain id : 43144)
      • Kucoin Community Chain (chain id : 321)
      • Arbitrum (chain id : 42161)
      • Optimism (chain id : 10)
      • Astar (chain id : 592)
      • Kaia (chain id : 8217)
      • zkSync Era (chain id : 324)
      • Polygon zkEVM ( chainid : 1101)
      • Linea (chain id : 59144)
      • Base (chain id : 8453)
      • Mantle ( chain id : 5000)
      • Scroll (chain id : 534352 )
      • Blast (chain id : 81457)
      • X Layer (chain id : 196)
      • Taiko (chain id : 167000)
      • Cronos zkEVM (chain id : 388)
      • Abstract (chain id : 2741)
      • Berachain (chain id : 80094)
      • Numbers (chain id : 10507)
      • Treasury
      • (Suspended)Fantom
      • (Suspended)ThunderCore
      • (Suspended)Moonriver
    • Audit Reports
    • Privileged Roles Management
  • Document
    • Terms of Use
    • AML and CFT Compliance Statement
    • Integration Terms and Brand Guidelines
    • Product Update
  • FAQ
    • How to Speed up Pending Transactions
    • How to add a custom RPC to my wallet
  • Contact Us
    • Telegram
    • Medium
    • Twitter
    • Discord
Powered by GitBook
On this page
  • Function: mint
  • Accessing the Minter Role
  • Function: burn

Was this helpful?

  1. Single Bridge Integration
  2. xAsset Bridge
  3. How to Develop Under XY Standards

Function Interface for Token Contract

Function: mint

Your contract should include the mint function. Here is the signature:

function mint(
    address to,
    uint256 amount
) external onlyMinter;

This function creates new tokens and adds them to the total supply. The parameters are:

  • address to: The address to receive the newly minted tokens.

  • uint256 amount: The amount of tokens to be minted and sent to the designated address.

Here is a brief implementation example of the mint function using OpenZeppelin's ERC20 library:

// Using OpenZeppelin's ERC20
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    // ...
    function mint(address to, uint256 amount) public onlyMinter {
        _mint(to, amount);
    }
}

The onlyMinter modifier restricts access to the mint function to authorized minters only, ensuring control over the creation of new tokens.

This mint function is key to the effective operation of cross-chain transfers within our system. By minting tokens on the destination chain that correspond tokens burnt on the source chain, the mint function ensures that total token supply remains consistent across all chains

Accessing the Minter Role

In order to use the mint function, you will need to provide our relay contract with permission to pass the onlyMinter check. This necessitates the inclusion of a function in your contract that enables the assignment of the minter role.

Possible options are:

  1. Mapping for Minters: Use a mapping in your contract to track the minter access of addresses.

  2. Grant Role Function: Use a function in your contract that allows a specific role, such as an owner or admin, to grant the minter role. This can be done using a role-based access control library like OpenZeppelin's Access Control library.

Function: burn

Your contract should also implement a burn function for token destruction. We expect this function will burn/remove a certain amount of tokens. We currently support the two interfaces for burn function:

XYERC20 (V1)

function burn(
    uint256 amount
) external;

This burn function should destroy a specified amount of tokens from the msg.sender's balance. The parameter is:

  • uint256 amount: The number of tokens to be burnt or destroyed.

Here is a brief implementation of the burn function using OpenZeppelin's ERC20 library:

// Using OpenZeppelin's ERC20
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    // ...
    function burn(uint256 amount) external {
        _burn(msg.sender, amount);
    }
}

In this example, the _burn function, a part of OpenZeppelin's ERC20 library, is used to burn tokens. It deducts the amount from msg.sender's balance and reduces the total supply of tokens accordingly.

XYERC20 (V2)

function burn(
    address account,
    uint256 amount
) external onlyMinter;

This burn function should destroy a specified amount of tokens from the account's balance. The parameters are:

  • address account: The address of the account from which the tokens will be burned.

  • uint256 amount: The number of tokens to be burnt or destroyed.

Make sure you add the onlyMinter modifier or such access control function to protect this burn function, and you will need to provide our relay contract with permission to pass the onlyMinter check as well.


The burn function empowers your contract to maintain the integrity of the token's supply when tokens are sent across different blockchains.

PreviousHow to Develop Under XY StandardsNextHow to Deposit / Withdraw Liquidity

Last updated 1 year ago

Was this helpful?