> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobula.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy an Indexer (Subgraph) on Polygon with The Graph

> Step-by-step instructions for deploying a subgraph on Polygon using The Graph for optimized blockchain data indexing.

Deploying a subgraph on Polygon with Mobula’s infrastructure is a simple process. This guide will walk you through the steps to get your subgraph up and running on the Polygon network.

### What you’ll need

* Basic knowledge of The Graph and subgraphs.
* Your subgraph project files
* The Graph CLI installed
* A Mobula API key (for authentication)

### Walkthrough

<Steps>
  <Step title="Prepare Your Subgraph">
    Make sure your subgraph is set up for Polygon. Modify your `subgraph.yaml` file to point to Polygon-specific contracts and events. If you don’t have a subgraph yet, you can clone the Uniswap V2 subgraph template and adjust it for Polygon:

    ```bash theme={null}
    git clone https://github.com/MobulaFi/univ2-subgraph-polygon
    ```
  </Step>

  <Step title="Install Dependencies">
    Ensure that The Graph CLI is installed:

    ```bash theme={null}
    npm install -g @graphprotocol/graph-cli
    ```
  </Step>

  <Step title="Build Your Subgraph">
    Compile your subgraph prior to deployment:

    ```bash theme={null}
    graph codegen && graph build
    ```
  </Step>

  <Step title="Create the Subgraph">
    Use the following command to deploy your subgraph:

    ```bash theme={null}
    graph create --node https://subgraph.mobula.io:8020
    ```
  </Step>

  <Step title="Deploy to Mobula's Polygon Node">
    Use the following command to deploy your subgraph:

    ```bash theme={null}
    graph deploy --node https://subgraph.mobula.io:8020 --ipfs https://subgraph.mobula.io:5001 --network polygon
    ```
  </Step>

  <Step title="Authenticate">
    When prompted, enter your Mobula API key for authentication. For more information on obtaining and using your API key, refer to the [authentication section](https://docs.mobula.io/indexing-stream/authentification).
  </Step>

  <Step title="Monitor Deployment">
    Once deployment is complete, you’ll receive a URL to track your subgraph’s indexing progress and status.
  </Step>
</Steps>

### Best Practices

* Keep your subgraph regularly updated to maintain compatibility with the latest Polygon network changes.
* Thoroughly test your subgraph on a testnet before deploying to the mainnet.
* Continuously monitor your subgraph's performance and optimize queries for better efficiency.

### Troubleshooting

If you encounter issues during deployment:

* Carefully review your `subgraph.yaml` configuration.
* Confirm that you’re using the correct network name and Mobula node URLs.
* Make sure your API key is valid and has the required permissions.

Need Assistance? Our support team is available to assist with any questions or deployment issues you may encounter.

<CardGroup>
  <Card title="Support" icon="Telegram" href="https://t.me/mobuladevelopers">Telegram</Card>
  <Card title="Support" icon="Slack" href="https://join.slack.com/t/mobulaapi/shared_invite/zt-29zrrpjnl-I0tyD73sy7zKy8q~KLL3Ug">Slack</Card>
  <Card title="Support" icon="Discord" href="https://discord.gg/JVT7xKm3AD">Discord</Card>
  <Card title="Email Support" icon="envelope" href="mailto:contact@mobulalabs.org">Email</Card>
</CardGroup>
