Docs
खोज⌘ K
  • Home
  • The Graph के बारे में
  • समर्थित नेटवर्क
  • Protocol Contracts
  • सबग्राफ
    • सबस्ट्रीम
      • टोकन API
        • AI Suite
          • Overview
          • Indexer टूलिंग
            • GraphTally Guide
            • Supported Network Requirements
            • Chain Integration Process Overview
            • नई श्रृंखला एकीकरण
            • संसाधन
              सबग्राफ > विकसित करना

              7 मिनट

              Developer FAQ

              यह पृष्ठ ‘The Graph’ पर निर्माण कर रहे डेवलपर्स के लिए कुछ सामान्य प्रश्नों का सारांश प्रस्तुत करता है।

              सबग्रह संबंधित

              1. What is a Subgraph?

              A Subgraph is a custom API built on blockchain data. Subgraphs are queried using the GraphQL query language and are deployed to a Graph Node using The Graph CLI. Once deployed and published to The Graph’s decentralized network, Indexers process Subgraphs and make them available for Subgraph consumers to query.

              2. What is the first step to create a Subgraph?

              To successfully create a Subgraph, you will need to install The Graph CLI. Review the Quick Start to get started. For detailed information, see Creating a Subgraph.

              3. Can I still create a Subgraph if my smart contracts don’t have events?

              It is highly recommended that you structure your smart contracts to have events associated with data you are interested in querying. Event handlers in the Subgraph are triggered by contract events and are the fastest way to retrieve useful data.

              If the contracts you work with do not contain events, your Subgraph can use call and block handlers to trigger indexing. However, this is not recommended, as performance will be significantly slower.

              4. Can I change the GitHub account associated with my Subgraph?

              No. Once a Subgraph is created, the associated GitHub account cannot be changed. Please make sure to carefully consider this before creating your Subgraph.

              5. How do I update a Subgraph on mainnet?

              You can deploy a new version of your Subgraph to Subgraph Studio using the CLI. This action maintains your Subgraph private, but once you’re happy with it, you can publish to Graph Explorer. This will create a new version of your Subgraph that Curators can start signaling on.

              6. Is it possible to duplicate a Subgraph to another account or endpoint without redeploying?

              You have to redeploy the Subgraph, but if the Subgraph ID (IPFS hash) doesn’t change, it won’t have to sync from the beginning.

              7. How do I call a contract function or access a public state variable from my Subgraph mappings?

              Take a look at Access to smart contract state inside the section AssemblyScript API.

              8. Can I import ethers.js or other JS libraries into my Subgraph mappings?

              AssemblyScript में वर्तमान में मैपिंग्स नहीं लिखी जा रही हैं।

              एक संभावित वैकल्पिक समाधान यह है कि कच्चे डेटा को एंटिटीज़ में स्टोर किया जाए और जो लॉजिक JS पुस्तकालय की आवश्यकता होती है, उसे क्लाइंट पर किया जाए।

              9. कई कॉन्ट्रैक्ट सुनते समय, क्या घटनाओं को सुनने के लिए कॉन्ट्रैक्ट के क्रम का चयन करना संभव है?

              Within a Subgraph, the events are always processed in the order they appear in the blocks, regardless of whether that is across multiple contracts or not.

              10. टेम्प्लेट्स और डेटा स्रोतों में क्या अंतर है?

              Templates allow you to create data sources quickly, while your Subgraph is indexing. Your contract might spawn new contracts as people interact with it. Since you know the shape of those contracts (ABI, events, etc.) upfront, you can define how you want to index them in a template. When they are spawned, your Subgraph will create a dynamic data source by supplying the contract address.

              Check out the “Instantiating a data source template” section on: Data Source Templates.

              11. Is it possible to set up a Subgraph using graph init from graph-cli with two contracts? Or should I manually add another dataSource in subgraph.yaml after running graph init?

              Yes. On graph init command itself you can add multiple dataSources by entering contracts one after the other.

              You can also use graph add command to add a new dataSource.

              12. एक डेटा स्रोत के लिए इवेंट, ब्लॉक और कॉल हैंडलर्स को किस क्रम में ट्रिगर किया जाता है?

              Event and call handlers are first ordered by transaction index within the block. Event and call handlers within the same transaction are ordered using a convention: event handlers first then call handlers, each type respecting the order they are defined in the manifest. Block handlers are run after event and call handlers, in the order they are defined in the manifest. Also these ordering rules are subject to change.

              When new dynamic data source are created, the handlers defined for dynamic data sources will only start processing after all existing data source handlers are processed, and will repeat in the same sequence whenever triggered.

              13. यह सुनिश्चित करने के लिए कि मैं अपने स्थानीय डिप्लॉयमेंट के लिए graph-node का नवीनतम संस्करण उपयोग कर रहा हूँ?

              आप निम्न आदेश चला सकते हैं:

              1docker pull graphprotocol/graph-node:latest

              ध्यान दें: docker / docker-compose हमेशा उसी graph-node संस्करण का उपयोग करेगा जिसे आपने पहली बार इसे चलाने पर खींचा था, इसलिए सुनिश्चित करें कि आप graph-node के नवीनतम संस्करण के साथ अपडेट हैं।

              14. इवेंट्स को हैंडल करते समय एक एंटिटी के लिए “स्वतः उत्पन्न” आईडी बनाने का अनुशंसित तरीका क्या है?

              If only one entity is created during the event and if there’s nothing better available, then the transaction hash + log index would be unique. You can obfuscate these by converting that to Bytes and then piping it through crypto.keccak256 but this won’t make it more unique.

              15. Can I delete my Subgraph?

              Yes, you can delete and transfer your Subgraph.

              नेटवर्क से संबंधित।

              16. The Graph द्वारा समर्थित नेटवर्क कौन से हैं?

              You can find the list of the supported networks here.

              17. क्या इवेंट हैंडलर्स के भीतर नेटवर्क (mainnet, Sepolia, local) के बीच अंतर करना संभव है?

              Yes. You can do this by importing graph-ts as per the example below:

              1import { dataSource } from '@graphprotocol/graph-ts'23dataSource.network()4dataSource.address()

              18. क्या आप Sepolia पर block और call handlers का समर्थन करते हैं?

              Yes. Sepolia supports block handlers, call handlers and event handlers. It should be noted that event handlers are far more performant than the other two handlers, and they are supported on every EVM-compatible network.

              Indexing & Querying Related

              19. क्या यह संभव है कि किस ब्लॉक से इंडेक्सिंग शुरू की जाए?

              Yes. dataSources.source.startBlock in the subgraph.yaml file specifies the number of the block that the dataSource starts indexing from. In most cases, we suggest using the block where the contract was created: Start blocks

              20. What are some tips to increase the performance of indexing? My Subgraph is taking a very long time to sync

              Yes, you should take a look at the optional start block feature to start indexing from the block where the contract was deployed: Start blocks

              21. Is there a way to query the Subgraph directly to determine the latest block number it has indexed?

              हाँ! निम्न आदेश का प्रयास करें, “संगठन/सबग्राफनाम” को उस संगठन के साथ प्रतिस्थापित करें जिसके अंतर्गत वह प्रकाशित है और आपके सबग्राफ का नाम:

              1curl -X POST -d '{ "query": "{indexingStatusForCurrentVersion(subgraphName: \"organization/subgraphName\") { chains { latestBlock { hash number }}}}"}' https://api.thegraph.com/index-node/graphql

              22. क्या The Graph एक क्वेरी में कितने ऑब्जेक्ट्स वापस कर सकता है, इस पर कोई सीमा है?

              डिफ़ॉल्ट रूप से, क्वेरी उत्तर हर संग्रह के लिए 100 आइटम तक सीमित होते हैं। यदि आप अधिक प्राप्त करना चाहते हैं, तो आप 1000 आइटम तक जा सकते हैं और उसके बाद, आप पेजिनेट कर सकते हैं:

              1someCollection(first: 1000, skip: <number>) { ... }

              23. If my dapp frontend uses The Graph for querying, do I need to write my API key into the frontend directly? What if we pay query fees for users – will malicious users cause our query fees to be very high?

              Currently, the recommended approach for a dapp is to add the key to the frontend and expose it to end users. That said, you can limit that key to a hostname, like yourdapp.io and Subgraph. The gateway is currently being run by Edge & Node. Part of the responsibility of a gateway is to monitor for abusive behavior and block traffic from malicious clients.

              विविध

              क्या Apollo Federation का उपयोग graph-node के ऊपर किया जा सकता है?

              Federation अभी समर्थित नहीं है। फिलहाल, आप schema stitching का उपयोग कर सकते हैं, या तो क्लाइंट पर या एक प्रॉक्सी सेवा के माध्यम से।

              25. मैं योगदान देना चाहता हूँ या कोई GitHub मुद्दा जोड़ना चाहता हूँ। मुझे ओपन सोर्स रिपॉज़िटरीज़ कहाँ मिल सकती हैं?

              • graph-node⁠
              • graph-tooling⁠
              • graph-docs⁠
              • graph-client⁠
              ⁠GitHub पर संपादित करें⁠

              Deleting a Subgraphबिलिंग
              इस पृष्ठ पर
              • सबग्रह संबंधित
              • 1. What is a Subgraph?
              • 2. What is the first step to create a Subgraph?
              • 3. Can I still create a Subgraph if my smart contracts don’t have events?
              • 4. Can I change the GitHub account associated with my Subgraph?
              • 5. How do I update a Subgraph on mainnet?
              • 6. Is it possible to duplicate a Subgraph to another account or endpoint without redeploying?
              • 7. How do I call a contract function or access a public state variable from my Subgraph mappings?
              • 8. Can I import ethers.js or other JS libraries into my Subgraph mappings?
              • 9. कई कॉन्ट्रैक्ट सुनते समय, क्या घटनाओं को सुनने के लिए कॉन्ट्रैक्ट के क्रम का चयन करना संभव है?
              • 10. टेम्प्लेट्स और डेटा स्रोतों में क्या अंतर है?
              • 11. Is it possible to set up a Subgraph using graph init from graph-cli with two contracts? Or should I manually add another dataSource in subgraph.yaml after running graph init?
              • 12. एक डेटा स्रोत के लिए इवेंट, ब्लॉक और कॉल हैंडलर्स को किस क्रम में ट्रिगर किया जाता है?
              • 13. यह सुनिश्चित करने के लिए कि मैं अपने स्थानीय डिप्लॉयमेंट के लिए graph-node का नवीनतम संस्करण उपयोग कर रहा हूँ?
              • 14. इवेंट्स को हैंडल करते समय एक एंटिटी के लिए “स्वतः उत्पन्न” आईडी बनाने का अनुशंसित तरीका क्या है?
              • 15. Can I delete my Subgraph?
              • नेटवर्क से संबंधित।
              • 16. The Graph द्वारा समर्थित नेटवर्क कौन से हैं?
              • 17. क्या इवेंट हैंडलर्स के भीतर नेटवर्क (mainnet, Sepolia, local) के बीच अंतर करना संभव है?
              • 18. क्या आप Sepolia पर block और call handlers का समर्थन करते हैं?
              • Indexing & Querying Related
              • 19. क्या यह संभव है कि किस ब्लॉक से इंडेक्सिंग शुरू की जाए?
              • 20. What are some tips to increase the performance of indexing? My Subgraph is taking a very long time to sync
              • 21. Is there a way to query the Subgraph directly to determine the latest block number it has indexed?
              • 22. क्या The Graph एक क्वेरी में कितने ऑब्जेक्ट्स वापस कर सकता है, इस पर कोई सीमा है?
              • 23. If my dapp frontend uses The Graph for querying, do I need to write my API key into the frontend directly? What if we pay query fees for users – will malicious users cause our query fees to be very high?
              • विविध
              • क्या Apollo Federation का उपयोग graph-node के ऊपर किया जा सकता है?
              • 25. मैं योगदान देना चाहता हूँ या कोई GitHub मुद्दा जोड़ना चाहता हूँ। मुझे ओपन सोर्स रिपॉज़िटरीज़ कहाँ मिल सकती हैं?
              The GraphStatusTestnetBrand AssetsForumSecurityPrivacy PolicyTerms of Service