Skip to content

Commit

Permalink
made some updates to this page after feedback (#678)
Browse files Browse the repository at this point in the history
* made some updates to this page after feedback

* Update website/pages/en/quick-start.mdx

Co-authored-by: Benoît Rouleau <[email protected]>

* Update website/pages/en/quick-start.mdx

It doesn't, great catch!

Co-authored-by: Benoît Rouleau <[email protected]>

* Update website/pages/en/quick-start.mdx

* lint

* lint

---------

Co-authored-by: Benoît Rouleau <[email protected]>
Co-authored-by: azf20 <[email protected]>
  • Loading branch information
3 people authored May 29, 2024
1 parent 66053e4 commit 030ed60
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions website/pages/en/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@ Ensure that your subgraph will be indexing data from a [supported network](/deve

This guide is written assuming that you have:

- A smart contract address on the network of your choice
- GRT to curate your subgraph
- A crypto wallet
- A smart contract address on the network of your choice

## 1. 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”.
Once your wallet is connected, you can begin by clicking “Create a Subgraph." It is recommended to name the subgraph in Title Case: "Subgraph Name Chain Name."

## 2. 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.
The Graph CLI is written in TypeScript and you will need to have `node` and either `npm` or `yarn` installed to use it. Check that you have the most recent CLI version installed.

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

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

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

Using [yarn](https://yarnpkg.com/):
Expand All @@ -36,7 +35,13 @@ Using [yarn](https://yarnpkg.com/):
yarn global add @graphprotocol/graph-cli
```

## 3. Initialize your Subgraph
## 3. Initialize your subgraph from existing contract

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

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

> You can find commands for your specific subgraph on the subgraph page in [Subgraph Studio](https://thegraph.com/studio/).
Expand All @@ -53,17 +58,11 @@ When you initialize your subgraph, the CLI tool will ask you for the following i
- 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

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:

![Subgraph command](/img/subgraph-init-example.png)

## 4. Write your Subgraph
## 4. 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:

Expand Down Expand Up @@ -93,7 +92,7 @@ You will be asked for a version label. It's strongly recommended to use [semver]

## 6. Test your subgraph

You can test your subgraph by making a sample query in the playground section.
In Subgraph Studio's playground environment, you can test your subgraph by making a sample query.

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

Expand Down Expand Up @@ -143,26 +142,26 @@ If your subgraph is failing, you can query the subgraph health by using the Grap
}
```

## 7. Publish Your Subgraph to The Graph’s Decentralized Network
## 7. Publish your subgraph to The Graph’s Decentralized Network

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

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

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).

The (upgrade Indexer)[/sunrise/#about-the-upgrade-indexer] will begin serving queries on your subgraph regardless of subgraph curation, and will provide you with 100,000 free queries per month.
The (upgrade Indexer)[/sunrise/#about-the-upgrade-indexer] will begin serving queries on your subgraph regardless of subgraph curation, and it will provide you with 100,000 free queries per month.

For a higher quality of service and stronger redundancy, you can curate your subgraph to attract more Indexers. At the time of writing, it is recommended that you curate your own subgraph with at least 3,000 GRT to ensure 3-5 additional Indexers begin serving queries on your subgraph.

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)

## 8. Query your Subgraph
## 8. 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.
If you don't have your API key, you can query via the free, rate-limited development query URL, which can be used for development and staging.

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

0 comments on commit 030ed60

Please sign in to comment.