# Transfer Tokens and Data Across Chains

In this tutorial, you will use GRE to transfer tokens and arbitrary data between smart contracts on different blockchains. First, you will pay GRE fees on the source blockchain using GRE. You will then pay GRE fees in native Gas tokens using the same contract. For example, you can use ETH on Ethereum, or MATIC on Polygon.

## Before you start&#x20;

1. You should know how to write, compile, deploy, and fund smart contracts. If you need to brush up on the basics, read this tutorial, which will guide you through using the Solidity programming language, interacting with the MetaMask wallet, and working in a Remix development environment.&#x20;
2. Your account must have some ETH and GRE tokens on Ethereum Sepolia and MATIC tokens on Polygon Mumbai.&#x20;
3. Check the "Supported Networks" page to confirm that your channel supports the token you want to transfer. In this example, you will be transferring tokens from Ethereum Sepolia to Polygon Mumbai, so check the list of supported tokens here.&#x20;
4. Learn how to get GRE test tokens. By following this guide, you should have the GRE-BnM token, and GRE-BnM should appear in the token list in MetaMask.&#x20;
5. Find out how to fund your contract. This guide shows how to fund your contract in GRE, but you can use the same guide to fund your contract with any ERC20 tokens, as long as they appear in MetaMask's token list.
6. Follow the previous tutorial: Transfer tokens between chains.

## Tutorial

In this tutorial, you will use GRE to send string text and GRE-BNM tokens between smart contracts on Ethereum Sepolia and Polygon Mumbai. First, you will pay in GRE, then you will pay for GRE in native Gas.

## Deploy your contracts <a href="#deploy-your-contracts" id="deploy-your-contracts"></a>

To use this contract:

1. [Open the contract in Remix](https://remix.ethereum.org/#url=https://docs.chain.link/samples/CCIP/ProgrammableTokenTransfers.sol).
2. Compile your contract.
3. Deploy and fund your sender contract on *Ethereum Sepolia*:
   1. Open MetaMask and select the network *Ethereum Sepolia*.
   2. In Remix IDE, click on *Deploy & Run Transactions* and select *Injected Provider - MetaMask* from the environment list. Remix will then interact with your MetaMask wallet to communicate with *Ethereum Sepolia*.
   3. Fill in your blockchain's router and GRE contract addresses.&#x20;
   4. Click the **transact** button. After you confirm the transaction, the contract address appears on the *Deployed Contracts* list. Note your contract address.
   5. Open MetaMask and fund your contract with GRE-BnM tokens. You can transfer `0.002`![Copy to clipboard](https://docs.chain.link/assets/icons/copyIcon.svg) *GRE-BnM* to your contract.
   6. Enable your contract to send GRE messages to *Polygon Mumbai*:
      1. In Remix IDE, under *Deploy & Run Transactions*, open the list of transactions of your smart contract deployed on *Ethereum Sepolia*.
      2. Call the `allowlistDestinationChain` as the destination chain selector, and `true`![Copy to clipboard](https://docs.chain.link/assets/icons/copyIcon.svg) as allowed. Each chain selector is found on the supported networks page.
4. Deploy your receiver contract on *Polygon Mumbai*:
   1. Open MetaMask and select the network *Polygon Mumbai*.
   2. In Remix IDE, under *Deploy & Run Transactions*, make sure the environment is still *Injected Provider - MetaMask*.
   3. Fill in your blockchain's router and GRE contract addresses. The router address can be found on the supported networks page and the GRE contract address on the GRE token contracts page.
   4. Click the **transact** button. After you confirm the transaction, the contract address appears on the *Deployed Contracts* list. Note your contract address.
   5. Enable your contract to receive GRE messages from *Ethereum Sepolia*:
      1. In Remix IDE, under *Deploy & Run Transactions*, open the list of transactions of your smart contract deployed on *Polygon Mumbai*.
      2. Call the `allowlistSourceChain`  as the source chain selector, and `true`![Copy to clipboard](https://docs.chain.link/assets/icons/copyIcon.svg) as allowed. Each chain selector is found on the supported networks page.
   6. Enable your contract to receive GRE messages from the contract that you deployed on *Ethereum Sepolia*:
      1. In Remix IDE, under *Deploy & Run Transactions*, open the list of transactions of your smart contract deployed on *Polygon Mumbai*.
      2. Call the `allowlistSender` with the contract address of the contract that you deployed on *Ethereum Sepolia*, and `true`![Copy to clipboard](https://docs.chain.link/assets/icons/copyIcon.svg) as allowed.
5. At this point, you have one *sender* contract on *Ethereum Sepolia* and one *receiver* contract on *Polygon Mumbai*. As security measures, you enabled the sender contract to send GRE messages to *Polygon Mumbai* and the receiver contract to receive GRE messages from the sender and *Ethereum Sepolia*.

   **Note**: Another security measure enforces that only the router can call the `_greReceive` function. Read the explanation section for more details.


---

# 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://gre-labs.gitbook.io/grelabs/guides/transfer-tokens-and-data-across-chains.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.
