# 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:

```bash
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:

{% hint style="info" %}
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.
{% endhint %}

```java
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:

```
npx hardhat run scripts/deployExampleToken.ts --network ethereum_sepolia
npx hardhat run scripts/deployExampleToken.ts --network 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:

```
npx hardhat setOrigin --destnetwork <other_network_name_as_per_hardhat_config> --network <current_network>
```

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:

```
npx hardhat sendTokens --tochainid 80002 --to <receiver_address_on_Polygon_Amoy> --amount 100 --network ethereum_sepolia
```

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:

{% code overflow="wrap" %}

```
100 tokens sent to chain 80002 to address 0xRecipient from chain 11155111 from address 0xSender
```

{% endcode %}

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.entangle.fi/universal-interoperability-protocol/developer-guides/solidity/bridging-tokens-with-uip.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
