Bug, i can´t add dinamyc templates


when indexing generate this error and not add template

the code example template in this repo GitHub - leovafme/thegraph-add-templates

expected add template of my factory and listing events of others contracts dynamically

Thank you for any information

1 Like

It looks like you may want to select a different id. Since the ExampleEntity id is the signer of the transaction, this can be loaded multiple times. If the event.params.game appears more than once it can cause an error trying to initialize that template multiple times.

export function handleNewExchange(event: NewExchange): void {
  let entity = ExampleEntity.load(event.transaction.from.toHex())

I would consider adding a game entity, and upon creation of the game you invoke the template.

import { BigInt } from "@graphprotocol/graph-ts"
import { NewExchange } from "../generated/FactoryTest/FactoryTest"
import { Exchange } from "../generated/schema"
import { Exchange as ExchangeTemplate} from '../generated/templates'

export function handleNewExchange(event: NewExchange): void {
let exchange = Exchange.load({exchange_contract_address})

if (!exchange) {
  exchange = new Exchange({exchange_contract_address})
  other fields...

counter logic etc.