Bridging Tokens with UIP

This guide walks you through building a simple dApp that utilizes UIP to bridge tokens across different EVM-based blockchains. We will deploy an ExampleToken smart contract and use a Hardhat task to transfer tokens between chains.

Prerequisites

Before you begin, ensure you have the following:

  • Familiarity with Solidity and Hardhat.

  • Node.js and npm installed.

  • Native coins.

Environment Setup

First, clone the repository and install dependencies:

git clone https://github.com/Entangle-Protocol/UIP-examples.git
cd UIP-examples/Token/FT/EVM
npm install

Next, configure your environment by updating the `hardhat.config.ts` file with your mnemonic phrase and RPCs:

Note: In this guide, we deploy the ExampleToken on Ethereum Sepolia and Polygon Amoy for demonstration purposes only. You can choose any networks that best suit your requirements.

ethereum_sepolia: {
    url: "your_rpc",
    accounts: { mnemonic: "your mnemonic here", },
    chainId: 11155111
}
polygon_amoy: { 
    url: "your_rpc",
    accounts: { mnemonic: "your mnemonic here", },
    chainId: 80002
}

Deploying Contracts

Once your environment is set up, deploy the ExampleToken to Ethereum Sepolia and Polygon Amoy:

Setting Origins

Before sending tokens, you need to set the token contract from another chain as an origin.

Run the following Hardhat task to set an origin:

You need to run this task for both networks.

Sending Tokens via Bridge

To transfer tokens from Ethereum Sepolia to Polygon Amoy, use the Hardhat task:

This task:

  • Fetches the ExampleToken contract.

  • Sets the origin address if not already set.

  • Calls the `bridge` function to send tokens.

Keep in mind that token has 18 decimals.

Verifying Transactions

Check the logs to ensure the transaction is successful. You should see an output similar to:

To verify the received tokens, check the destination chain’s block explorer.

Summary

This guide demonstrated how to deploy and interact with a cross-chain token bridging contract using UIP. With this setup, you can seamlessly transfer assets across different EVM-compatible blockchains.

Last updated

Was this helpful?