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:
Next, configure your environment by updating the `hardhat.config.ts` file with your mnemonic phrase and RPCs:
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?