- EVM
- Substrate
An end-to-end idiomatic usage of Apply the migrations withIn the snippet above, we decode both The script will build the code automatically before running.In a separate terminal window, runInspect the GraphQL API at
EvmBatchProcessor can be inspected in the gravatar template repository and also learned from more elaborate examples.In order to illustrate the concepts covered in the development guide, here we highlight the key steps, put together a processor configuration and a data handling definition.Pre-requisites: NodeJS, Git, Docker, Squid CLI, any of the EVM templates.
1. Model the target schema and generate entity classes
Create or editschema.graphql to define the target entities and relations. Consult the schema reference.Update the entity classes, start a fresh database and regenerate migrations:2. Generate Typescript ABI modules
Useevm-typegen to generate the facade classes, for example like this:3. Configuration
See Configuration section for more details.4. Iterate over the batch items and group events
The following code snippet illustrates a typical data transformation in a batch. The strategy is to- Iterate over
ctx.blocksandblock.logs - Decode each log using a suitable facade class
- Enrich and transform the data
- Upsert arrays of entities in batches using
ctx.save()
processor.run() method the looks as follows:NewGravatar and UpdatedGravatar with a single helper function that uses the generated events facade class:5. Run the processor and store the transformed data into the target database
Run the processor withhttp://localhost:4350/graphql.