---
# System prepended metadata

title: Quick Start

---

---
title: Building a Subgraph on Arbitrum One
---

This guide will explain how to create, deploy, and publish your Arbitrum subgraph to The Graph's decentralized network.

Arbitrum is an EVM-compatible L2. You can test your dapp by deploying to [Arbitrum testnet](https://docs.arbitrum.io/for-devs/concepts/public-chains#what-arbitrum-testnet-chains-are-available). You can find Arbitrum documentation [here](https://docs.arbitrum.io/) and leverage the block explorer [here](https://arbiscan.io/).

Popular Arbitrum dapps using subgraphs on The Graph include:
-[Premia](https://thegraph.com/explorer/subgraphs/8SxuHUYYBLHs1UkgFFYNaS7MgrEiAMbDyt5YzwZsSa6R?view=Overview&chain=arbitrum-one)
-[Camelot](https://thegraph.com/explorer/subgraphs/8zagLSufxk5cVhzkzai3tyABwJh53zxn9tmUYJcJxijG?view=Overview&chain=arbitrum-one)
-[Dolomite](https://thegraph.com/explorer/subgraphs/DF4dkCD1NNxuqF3tovPpQG1VgkxsaGjr5TXJTtsKZH7D?view=Overview&chain=arbitrum-one)

After completion, you will be able to query data from your subgraph using GraphQL with 100,000 free queries per month.

This guide is written assuming that you have:

- A smart contract address on Arbitrum
- A basic understanding of GraphQL

## 1. Create an account Subgraph Studio

Go to the [Subgraph Studio](https://thegraph.com/studio/), connect your wallet, and create an account.

Creating an account will require you to verify your email address.

## 2. Create a subgraph on Subgraph Studio

Go to the [Subgraph Studio](https://thegraph.com/studio/) and connect your wallet.

Once connected, you can begin by clicking “create a subgraph.” Select Arbitrum and click continue.

## 3. Install the Graph CLI

The Graph CLI is written in JavaScript and you will need to have either `npm` or `yarn` installed to use it.

On your local machine, run one of the following commands:

Using [npm](https://www.npmjs.com/):

```sh
npm install -g @graphprotocol/graph-cli
```

Using [yarn](https://yarnpkg.com/):

```sh
yarn global add @graphprotocol/graph-cli
```

## 4. Initialize your Subgraph

> You can find commands for your specific subgraph on the subgraph page in [Subgraph Studio](https://thegraph.com/studio/).

The command to initialize your subgraph will like the following:

```sh
graph init --studio example-subgraph
```

When you initialize your subgraph, the CLI tool will ask you for the following information:

- Protocol: choose the protocol your subgraph will be indexing data from. Since Arbitrum is an EVM-compatible network, you will need to choose Ethereum here.
- Subgraph slug: create a name for your subgraph. Your subgraph slug is an identifier for your subgraph.
- Directory to create the subgraph in: choose a local directory.
- Ethereum network: specify Arbitrum One.
- Contract address: Locate the smart contract address you’d like to query data from.
- ABI: If the ABI is not autopopulated, you will need to input it manually as a JSON file. 
- Start Block: it is suggested that you input the start block to save time while your subgraph indexes blockchain data. You can locate the start block by finding the block where your contract was deployed.
- Contract Name: input the name of your contract.
- Index contract events as entities: it is suggested that you set this to true as it will automatically add mappings to your subgraph for every emitted event.
- Add another contract(optional): you can add another contract. If you do not have another contract, you can skip this step by pressing enter.

Initialize your subgraph from an existing contract by running the following command:

```sh
graph init --studio <SUBGRAPH_SLUG>
```

See the following screenshot for an example for what to expect when initializing your subgraph:

[Add screenshot here]

## 5. Write your Subgraph

The previous commands create a scaffold subgraph that you can use as a starting point for building your subgraph. When making changes to the subgraph, you will mainly work with three files:

- Manifest (`subgraph.yaml`) - The manifest defines what data sources your subgraph(s) will index.
- Schema (`schema.graphql`) - The GraphQL schema defines what data you wish to retrieve from the subgraph.
- AssemblyScript Mappings (`mapping.ts`) - The mapping file translates data from your data sources to the entities defined in the schema.

For more information on how to write your subgraph, see [Creating a Subgraph](/developing/creating-a-subgraph).

## 6. Deploy to the Subgraph Studio

Once your subgraph is written, run the following commands:

```sh
$ graph codegen
$ graph build
```

- Authenticate and deploy your subgraph. The deploy key can be found on the Subgraph page in Subgraph Studio.

```sh
$ graph auth --studio <DEPLOY_KEY>
$ graph deploy --studio <SUBGRAPH_SLUG>
```

You will be asked for a version label. It's strongly recommended to use [semver](https://semver.org/) for versioning like `0.0.1`. That said, you are free to choose any string as version such as:`v1`, `version1`, `asdf`.

## 7. Test your subgraph

You can test your subgraph by making a sample query in the playground section.

The logs will tell you if there are any errors with your subgraph. The logs of an operational subgraph will look like this:

![Subgraph logs](/img/subgraph-logs-image.png)

If your subgraph is failing, you can query the subgraph health by using the GraphiQL Playground. Note that you can leverage the query below and input your deployment ID for your subgraph. In this case, `Qm...` is the deployment ID (which can be located on the Subgraph page under **Details**). The query below will tell you when a subgraph fails, so you can debug accordingly:

```graphql
{
  indexingStatuses(subgraphs: ["Qm..."]) {
    node
    synced
    health
    fatalError {
      message
      block {
        number
        hash
      }
      handler
    }
    nonFatalErrors {
      message
      block {
        number
        hash
      }
      handler
    }
    chains {
      network
      chainHeadBlock {
        number
      }
      earliestBlock {
        number
      }
      latestBlock {
        number
      }
      lastHealthyBlock {
        number
      }
    }
    entityCount
  }
}
```

## 8. Publish Your Subgraph to The Graph’s Decentralized Network

Once your subgraph has been deployed to the Subgraph Studio, you have tested it out, and are ready to put it into production, you can then publish it to The Graph Network.

In the Subgraph Studio, click on your subgraph. On the subgraph’s page, you will be able to click the publish button on the top right.

Select the network you would like to publish your subgraph to. It is recommended to publish subgraphs to Arbitrum One to take advantage of the [faster transaction speeds and lower gas costs](/arbitrum/arbitrum-faq).

Before you can query your subgraph, Indexers need to begin serving queries on it. In order to streamline this process, you can curate your own subgraph using GRT.

At the time of writing, it is recommended that you curate your own subgraph with 10,000 GRT to ensure that it is indexed and available for querying as soon as possible.

To save on gas costs, you can curate your subgraph in the same transaction that you published it by selecting this button when you publish your subgraph to The Graph’s decentralized network:

![Subgraph publish](/img/publish-and-signal-tx.png)

## 9. Query your Subgraph

Now, you can query your subgraph by sending GraphQL queries to your subgraph’s Query URL, which you can find by clicking on the query button.

You can query from your dapp if you don't have your API key via the free, rate-limited temporary query URL that can be used for development and staging.

For more information about querying data from your subgraph, read more [here](/querying/querying-the-graph/).