You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/pages/en/developing/developer-faqs.mdx
+30-30Lines changed: 30 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,56 +14,54 @@ It is not possible to delete subgraphs once they are created.
14
14
15
15
No. Once a subgraph is created, the name cannot be changed. Make sure to think of this carefully before you create your subgraph so it is easily searchable and identifiable by other dapps.
16
16
17
-
## 4. Can I change the GitHub account associated with my subgraph?
18
-
19
-
No. Once a subgraph is created, the associated GitHub account cannot be changed. Make sure to think of this carefully before you create your subgraph.
20
-
21
-
## 5. Am I still able to create a subgraph if my smart contracts don't have events?
17
+
## 4. Am I still able to create a subgraph if my smart contracts don't have events?
22
18
23
19
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 by far the fastest way to retrieve useful data.
24
20
25
-
If the contracts you are working with do not contain events, your subgraph can use call and block handlers to trigger indexing. Although this is not recommended, as performance will be significantly slower.
21
+
If the contracts you are working with do not contain events, your subgraph can use call and block handlers to trigger indexing, but this is not recommended as performance will be significantly slower.
26
22
27
-
## 6. How are templates different from data sources?
23
+
## 5. How are templates different from data sources?
28
24
29
25
Templates allow you to create data sources on the fly, while your subgraph is indexing. It might be the case that your contract will spawn new contracts as people interact with it, and since you know the shape of those contracts (ABI, events, etc) upfront you can define how you want to index them in a template and when they are spawned your subgraph will create a dynamic data source by supplying the contract address.
30
26
31
27
Check out the "Instantiating a data source template" section on: [Data Source Templates](/developing/creating-a-subgraph#data-source-templates).
32
28
33
-
## 7. How do I make sure I'm using the latest version of graph-node for my local deployments?
29
+
## 6. How do I make sure I'm using the latest version of graph-node for my local deployments?
34
30
35
31
You can run the following command:
36
32
37
33
```sh
38
34
docker pull graphprotocol/graph-node:latest
39
35
```
40
36
41
-
**NOTE:** docker / docker-compose will always use whatever graph-node version was pulled the first time you ran it, so it is important to do this to make sure you are up to date with the latest version of graph-node.
37
+
>Note: docker / docker-compose will always use whatever graph-node version was pulled the first time you ran it, so it is important to do this to make sure you are up to date with the latest version of graph-node.
42
38
43
-
## 8. How do I call a contract function or access a public state variable from my subgraph mappings?
39
+
## 7. How do I call a contract function or access a public state variable from my subgraph mappings?
44
40
45
41
Take a look at `Access to smart contract` state inside the section [AssemblyScript API](/developing/graph-ts/api/#access-to-smart-contract-state).
46
42
47
-
## 9. 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`?
43
+
## 8. 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`?
48
44
49
-
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 new datasource.
45
+
Yes. On `graph init` command itself you can add multiple datasources by entering contracts one after the other.
50
46
51
-
## 10. I want to contribute or add a GitHub issue. Where can I find the open source repositories?
47
+
You can also use `graph add` command to add new datasource.
48
+
49
+
## 9. I want to contribute or add a GitHub issue. Where can I find the open source repositories?
## 11. What is the recommended way to build "autogenerated" ids for an entity when handling events?
56
+
## 10. What is the recommended way to build "autogenerated" ids for an entity when handling events?
59
57
60
58
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.
61
59
62
-
## 12. When listening to multiple contracts, is it possible to select the contract order to listen to events?
60
+
## 11. When listening to multiple contracts, is it possible to select the contract order to listen to events?
63
61
64
62
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.
65
63
66
-
## 13. Is it possible to differentiate between networks (mainnet, Sepolia, local) from within event handlers?
64
+
## 12. Is it possible to differentiate between networks (mainnet, Sepolia, local) from within event handlers?
67
65
68
66
Yes. You can do this by importing `graph-ts` as per the example below:
69
67
@@ -74,59 +72,61 @@ dataSource.network()
74
72
dataSource.address()
75
73
```
76
74
77
-
## 14. Do you support block and call handlers on Sepolia?
75
+
## 13. Do you support block and call handlers on Sepolia?
78
76
79
77
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.
80
78
81
-
## 15. Can I import ethers.js or other JS libraries into my subgraph mappings?
79
+
## 14. Can I import ethers.js or other JS libraries into my subgraph mappings?
80
+
81
+
Not currently, as mappings are written in AssemblyScript.
82
82
83
-
Not currently, as mappings are written in AssemblyScript. One possible alternative solution to this is to store raw data in entities and perform logic that requires JS libraries on the client.
83
+
One possible alternative solution to this is to store raw data in entities and perform logic that requires JS libraries on the client.
84
84
85
-
## 16. Is it possible to specify what block to start indexing on?
85
+
## 15. Is it possible to specify what block to start indexing on?
86
86
87
87
Yes. `dataSources.source.startBlock` in the `subgraph.yaml` file specifies the number of the block that the data source starts indexing from. In most cases, we suggest using the block in which the contract was created: [Start blocks](/developing/creating-a-subgraph#start-blocks)
88
88
89
-
## 17. Are there some tips to increase the performance of indexing? My subgraph is taking a very long time to sync
89
+
## 16. Are there some tips to increase the performance of indexing? My subgraph is taking a very long time to sync
90
90
91
91
Yes, you should take a look at the optional start block feature to start indexing from the block that the contract was deployed: [Start blocks](/developing/creating-a-subgraph#start-blocks)
92
92
93
-
## 18. Is there a way to query the subgraph directly to determine the latest block number it has indexed?
93
+
## 17. Is there a way to query the subgraph directly to determine the latest block number it has indexed?
94
94
95
95
Yes! Try the following command, substituting "organization/subgraphName" with the organization under it is published and the name of your subgraph:
96
96
97
97
```sh
98
98
curl -X POST -d '{ "query": "{indexingStatusForCurrentVersion(subgraphName: \"organization/subgraphName\") { chains { latestBlock { hash number }}}}"}' https://api.thegraph.com/index-node/graphql
99
99
```
100
100
101
-
## 19. What networks are supported by The Graph?
101
+
## 18. What networks are supported by The Graph?
102
102
103
103
You can find the list of the supported networks [here](/developing/supported-networks).
104
104
105
-
## 20. Is it possible to duplicate a subgraph to another account or endpoint without redeploying?
105
+
## 19. Is it possible to duplicate a subgraph to another account or endpoint without redeploying?
106
106
107
107
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.
108
108
109
-
## 21. Is this possible to use Apollo Federation on top of graph-node?
109
+
## 20. Is this possible to use Apollo Federation on top of graph-node?
110
110
111
111
Federation is not supported yet, although we do want to support it in the future. At the moment, something you can do is use schema stitching, either on the client or via a proxy service.
112
112
113
-
## 22. Is there a limit to how many objects The Graph can return per query?
113
+
## 21. Is there a limit to how many objects The Graph can return per query?
114
114
115
115
By default, query responses are limited to 100 items per collection. If you want to receive more, you can go up to 1000 items per collection and beyond that, you can paginate with:
## 23. If my dapp frontend uses The Graph for querying, do I need to write my query key into the frontend directly? What if we pay query fees for users – will malicious users cause our query fees to be very high?
121
+
## 22. If my dapp frontend uses The Graph for querying, do I need to write my query key into the frontend directly? What if we pay query fees for users – will malicious users cause our query fees to be very high?
122
122
123
123
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.
124
124
125
-
## 24. How do I update a subgraph on mainnet?
125
+
## 23. How do I update a subgraph on mainnet?
126
126
127
-
If you’re a subgraph developer, you can deploy a new version of your subgraph to Subgraph Studio using the CLI. It’ll be private at that point, but if you’re happy with it, you can publish to the decentralized Graph Explorer. This will create a new version of your subgraph that Curators can start signaling on.
127
+
You can deploy a new version of your subgraph to Subgraph Studio using the CLI. It’ll be private at that point, but if 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.
128
128
129
-
## 25. In what order are the event, block, and call handlers triggered for a data source?
129
+
## 24. In what order are the event, block, and call handlers triggered for a data source?
130
130
131
131
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.
0 commit comments