diff --git a/website/src/pages/en/subgraphs/quick-start.mdx b/website/src/pages/en/subgraphs/quick-start.mdx index 3a79eb078acf..6d1edc9e0927 100644 --- a/website/src/pages/en/subgraphs/quick-start.mdx +++ b/website/src/pages/en/subgraphs/quick-start.mdx @@ -8,7 +8,7 @@ By the end, you'll have: - Initialized a Subgraph from a smart contract - Deployed it to Subgraph Studio for testing -- Published to The Graph Network for decentralized indexing +- Published to The Graph Network for decentralized indexing using Studio or CLI ## Prerequisites @@ -51,7 +51,7 @@ graph --version > You can find commands for your specific Subgraph in [Subgraph Studio](https://thegraph.com/studio/). -The following command initializes your Subgraph from an existing contract and indexes events: +Initialize your Subgraph from an existing contract: ```sh graph init @@ -63,7 +63,7 @@ When you initialize your Subgraph, the CLI will ask you for the following inform - **Subgraph slug**: Create a name for your Subgraph. Your Subgraph slug is an identifier for your Subgraph. - **Directory**: Choose a directory to create your Subgraph in. - **Ethereum network** (optional): You may need to specify which EVM-compatible network your Subgraph will be indexing data from. -- **Contract address**: Locate the smart contract address you’d like to query data from. +- **Contract address**: Locate the smart contract address you'd like to query data from. - **ABI**: If the ABI is not auto-populated, you will need to input it manually as a JSON file. - **Start Block**: You should input the start block where the contract was deployed to optimize Subgraph indexing of blockchain data. - **Contract Name**: Input the name of your contract. @@ -76,38 +76,50 @@ See the following screenshot for an example of what to expect when initializing ### 4. Edit your Subgraph -When making changes to the Subgraph, you will mainly work with three files: +When making changes to the Subgraph, you will primarily work with three files: -- Manifest (`subgraph.yaml`) - defines what data sources your Subgraph will index. -- Schema (`schema.graphql`) - defines what data you wish to retrieve from the Subgraph. -- AssemblyScript Mappings (`mapping.ts`) - translates data from your data sources to the entities defined in the schema. +- Manifest (`subgraph.yaml`): Defines what data sources your Subgraph will index. +- Schema (`schema.graphql`): Defines what data you wish to retrieve from the Subgraph. +- AssemblyScript Mappings (`mapping.ts`): Translates data from your data sources to the entities defined in the schema. -For a detailed breakdown on how to write your Subgraph, check out [Creating a Subgraph](/developing/creating-a-subgraph/). +For a detailed breakdown on how to write your Subgraph, refer to [Creating a Subgraph](/subgraphs/developing/creating/starting-your-subgraph/). -### 5. Deploy your Subgraph +## Path 1: Studio Approach -When you **deploy** a Subgraph, you push it to [Subgraph Studio](https://thegraph.com/studio/), where you can test, stage and review it. A deployed Subgraph's indexing is performed by the [Upgrade Indexer](https://thegraph.com/blog/upgrade-indexer/), which is a single Indexer owned and operated by Edge & Node. A **deployed** Subgraph is free to use, rate-limited, not visible to the public, and meant to be used for development, staging, and testing purposes. +### 5. Build your Subgraph + +Run the following: + +```sh +graph codegen && graph build +``` -Once your Subgraph is written, run the following commands: +### 6. Deploy your Subgraph to Subgraph Studio - ```sh - graph codegen && graph build - ``` +When you **deploy** a Subgraph, you push it to [Subgraph Studio](https://thegraph.com/studio/), where you can test, stage and review it. A deployed Subgraph's indexing is performed by the [Upgrade Indexer](https://thegraph.com/blog/upgrade-indexer/), which is a single Indexer owned and operated by Edge & Node. A **deployed** Subgraph is free to use, rate-limited, not visible to the public, and meant to be used for development, staging, and testing purposes. -Authenticate and deploy your Subgraph. The deploy key can be found on the Subgraph's page in Subgraph Studio. +> [!IMPORTANT] You do not need to use Subgraph Studio to publish your Subgraph to The Graph Network. Studio is only required for testing and staging your Subgraph prior to publishing. + +1. Get your deploy key from the Subgraph page in Studio ![Deploy key](/img/subgraph-studio-deploy-key.jpg) - ```sh +2. Authenticate: - graph auth +```sh - graph deploy - ``` +graph auth +``` -### 6. Review your Subgraph +3. Deploy: -If you’d like to test your Subgraph before publishing it, you can use [Subgraph Studio](https://thegraph.com/studio/) to do the following: +```sh +graph deploy +``` + +### 7. Review in Studio + +Use the Studio to: - Run a sample query. - Analyze your Subgraph in the dashboard to check information. @@ -115,7 +127,7 @@ If you’d like to test your Subgraph before publishing it, you can use [Subgrap ![Subgraph logs](/img/subgraph-logs-image.png) -### 7. Publish your Subgraph to The Graph Network +### 8. Publish to The Graph Network When your Subgraph is ready for a production environment, you can publish it to the decentralized network. Publishing is an onchain action that does the following: @@ -123,20 +135,48 @@ When your Subgraph is ready for a production environment, you can publish it to - It removes rate limits and makes your Subgraph publicly searchable and queryable in [Graph Explorer](https://thegraph.com/explorer/). - It makes your Subgraph available for [Curators](/resources/roles/curating/) to add curation signal. -To publish your Subgraph, click the Publish button in the dashboard and select your network. +1. Click **Publish** in Studio +2. Select network +3. (Recommended) Add curation during the same transaction to save on gas costs: ![Subgraph publish](/img/studio-publish-modal.png) ![Publish a Subgraph on Subgraph Studio](/img/publish-sub-transfer.png) -> It is recommended that you curate your own Subgraph with at least 3,000 GRT to incentivize indexing. +> Curation with 3,000+ GRT is recommended to incentivize indexing. + +## Path 2: CLI Approach + +1. Open the `graph-cli`. +2. Run the following commands to build and publish your Subgraph: `graph codegen && graph build` then `graph publish`. +3. A browser window will prompt you to connect your wallet, add metadata, and publish your Subgraph to the network of your choice. + +![cli-ui](/img/cli-ui.png) -To save on gas costs, you can curate your Subgraph in the same transaction you publish it by selecting this option: +### Custom Options + +You can customize the deployment by uploading to a specific IPFS node and using additional flags: + +``` +USAGE + $ graph publish [SUBGRAPH-MANIFEST] [-h] [--protocol-network arbitrum-one|arbitrum-sepolia --subgraph-id ] [-i ] [--ipfs-hash ] [--webapp-url + ] + +FLAGS + -h, --help Show CLI help. + -i, --ipfs= [default: https://ipfs.thegraph.com/api/v0] Upload build results to an IPFS node. + --ipfs-hash= IPFS hash of the subgraph manifest to deploy. + --protocol-network=