From fb497d496b7b74d207b44e6d1e3934c71ae99ef5 Mon Sep 17 00:00:00 2001 From: Idalith Bustos Date: Wed, 23 Oct 2024 16:59:53 -0700 Subject: [PATCH 1/7] Cookbook --- website/pages/en/cookbook/_meta.js | 1 + .../en/cookbook/transfer-to-the-graph.mdx | 158 ++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 website/pages/en/cookbook/transfer-to-the-graph.mdx diff --git a/website/pages/en/cookbook/_meta.js b/website/pages/en/cookbook/_meta.js index 9232d85d9f30..4deedfffd880 100644 --- a/website/pages/en/cookbook/_meta.js +++ b/website/pages/en/cookbook/_meta.js @@ -10,4 +10,5 @@ export default { derivedfrom: 'Subgraph Best Practice 2: Manage Arrays with @derivedFrom', 'immutable-entities-bytes-as-ids': 'Subgraph Best Practice 3: Using Immutable Entities and Bytes as IDs', 'avoid-eth-calls': 'Subgraph Best Practice 4: Avoid eth_calls', + 'transfer-to-the-graph': '', } diff --git a/website/pages/en/cookbook/transfer-to-the-graph.mdx b/website/pages/en/cookbook/transfer-to-the-graph.mdx new file mode 100644 index 000000000000..770304ba3b82 --- /dev/null +++ b/website/pages/en/cookbook/transfer-to-the-graph.mdx @@ -0,0 +1,158 @@ +--- +title: Tranfer to The Graph +--- + +Learn how to quickly upgrade for your subgraphs from any platform to [The Graph's decentralized network](https://thegraph.com/networks/). + +## Benefits of Switching to The Graph + +- Use the same subgraph that your apps already use with zero-downtime migration +- Increase reliability from a global network supported by 100+ Indexers +- Receive lightning-fast support for subgraphs 24/7, with an on-call engineering team + +## Upgrade Your Subgraph to The Graph in 3 Easy Steps + +1. [Set Up Your Studio Environment](/cookbook/transfer-to-the-graph/#1-set-up-your-studio-environment) +2. [Deploy Your Subgraph to Studio](/cookbook/transfer-to-the-graph/#2-deploy-your-subgraph-to-studio) +3. [Publish to The Graph Network](/cookbook/transfer-to-the-graph/#publish-your-subgraph-to-the-graphs-decentralized-network) + +## 1. Set Up Your Studio Environment + +### Install the Graph CLI⁠ + +On your local machine, run the following commands: + +Using [npm](https://www.npmjs.com/): + +```sh +graph init --product subgraph-studio +``` + +### Create a Subgraph in Subgraph Studio + +1. Go to [Subgraph Studio](https://thegraph.com/studio/) and connect your wallet. +2. Click "Create a Subgraph". It is recommended to name the subgraph in Title Case: "Subgraph Name Chain Name". + +> Note: After publishing, the subgraph name will be editable but requires signing each time, so name it properly. + +For additional information on subgraph creation and the Graph CLI, see [Creating a Subgraph](/developing/creating-a-subgraph). + +### Authenticate Your Subgraph + +In The Graph CLI, use the auth command seen in Subgraph Studio: + +```sh +graph auth --studio ` +``` + +## 2. Deploy Your Subgraph to Studio + +In The Graph CLI, run the following command: + +```sh +graph deploy --studio --ipfs-hash ` +``` + +> Note: There is no coding required, simply use the **IPFS provided by your current host**. You’ll be prompted to enter a version. eg. v0.0.1. + +## 3. Publish Your Subgraph to The Graph Network + +![publish button](https://edgeandnode.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fa7d6afae-8784-4b15-a90e-ee8f6ee007ba%2F2f9c4526-123d-4164-8ea8-39959c8babbf%2FUntitled.png?table=block&id=37005371-76b4-4780-b044-040a570e3af6&spaceId=a7d6afae-8784-4b15-a90e-ee8f6ee007ba&width=1420&userId=&cache=v2) + +### Query Your Subgraph + +> 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. + +You can start querying any subgraph by sending a GraphQL query into the subgraph’s query URL endpoint, which is located at the top of its Explorer page in Subgraph Studio. + +#### Example + +[CryptoPunks Ethereum subgraph](https://thegraph.com/explorer/subgraphs/HdVdERFUe8h61vm2fDyycHgxjsde5PbB832NHgJfZNqK) by Messari: + +The query URL for this subgraph is: + +`https://gateway-arbitrum.network.thegraph.com/api/`**\[api-key]**`/subgraphs/id/HdVdERFUe8h61vm2fDyycgxjsde5PbB832NHgJfZNqK` + +Now, you simply need to fill in **your own API Key** to start sending GraphQL queries to this endpoint. + +### Getting your own API Key + +You can create API Keys in Subgraph Studio under the “API Keys” menu at the top of the page: + +![API keys](https://lh7-us.googleusercontent.com/docsz/AD_4nXdz7H8hSRf2XqrU0jN3p3KbmuptHvQJbhRHOJh67nBfwh8RVnhTsCFDGA_JQUFizyMn7psQO0Vgk6Vy7cKYH47OyTq5PqycB0xxLyF4kSPsT7hYdMv2MEzAo433sJT6VlQbUAzgPnSxKI9a5Tn3ShSzaxI?key=fnI6SyFgXU9SZRNX5C5vPQ) + +### Sample Query + +This query shows the most expensive CryptoPunks sold. + +```graphql +{ + trades(orderBy: priceETH, orderDirection: desc) { + priceETH + tokenId + } +} +``` + +Passing this into the query URL returns this result: + +``` +{ + "data": { + "trades": [ + { + "priceETH": "124457.067524886018255505", + "tokenId": "9998" + }, + { + "priceETH": "8000", + "tokenId": "5822" + }, +// ... +``` + +