I have an ethereum contract that is called:
tokenFactory.sol
This contract generates ERC20 tokens as it goes along, and when it does it emits and event that has the generated ERC20 address.
I would like to go and then index the Transfer
event of these generated Token Contracts. Is there a way to do that programmatically with Subgraph?
You'll define this events and contracts and handlers under the templates
key in the manifest. Which is as dataSources
except there is no address and start block because they haven't been deploy yet.
When you receive an event that this contract has been deployed, or needs to be indexed, you will create it using the generated template
import { Token } from '../../generated/templates';
...
export function handleToken(event: TokenEvent): void {
const tokenAddress = event.params.token;
Token.create(tokenAddress);
...
}