Overview
Does GhostGraph support state calls?
Yes, please view the state calls for instructions.
Hint: It's the same as what you would do when writing your smart contracts.
If I want to have a global state of the app, how would I go about it?
It's very straightforward. You can create a new struct called Global (or any name you prefer) like this:
struct Global {
string id;
uint256 totalMints;
}
Then, in your indexer.sol, whenever you want to access your global state, you can do something like this. Note that the "1" is arbitrary.
Global memory global = graph.getGlobal("1");
global.totalMints += 1;
graph.saveGlobal(global);
My event object does not have a unique id, what do I do?
There are a few ways to handle this situation:
- First, you can concatenate fields to create a deterministic unique id.
- Second, if you don't need to refer to the struct in the future, you can use our helper function
details.uniqueId()
; which creates a unique id based on the block number and log index.