Search code examples
mappingsolidityblocksmartcontractssubgraph

Can I set the start block number while creating a datasource template in Subgraph?


https://thegraph.com/docs/en/developing/creating-a-subgraph/#data-source-templates

The Graph supports starting a dynamically instantiated data source from a block earlier than the current block? The dynamic data source instantiated from a template begins processing events from the block where the .create() function was called. Is this correct?

What I wanna do is not to create a collection but to add an existing collection to the factory. In this case, I simply add a function which emits same events as the collection is created to the factory contract. But mapping function of factory contract works but template mapping function doesn't detect the minting events.


Solution

  • Yes. It starts processing events from the block where the .create() function was called.

    You can review Part 9 at https://thegraph.academy/developers/defining-a-subgraph/

    What you ran into is incapability to process the historical data. Currently, I am not sure if there is a way to fetch past events without reading the current state of the contract? see this screenshot