Indexing a Factory Contract using Unmarshal Parser

A Quick Guide

Unmarshal
4 min readDec 2, 2022

In this tutorial, I will demonstrate how you can index a Factory styled Contract with Unmarshal’s Parser.

For the purposes of this tutorial I will demonstrate how you can index Quickswap and all gather all of their children’s data. We find their factory contract deployed at 0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32 .

1. Index the factory like you would for any other contract

Polygon and the address of the factory

2. Once the ABI is loaded in select all events and function you want to index. Make sure to pick PairCreated event. (This is what’s emitted when a new Pair is created and holds the new contract’s addresss)

Event and Function Selection Page

3. Once at the Add Child Parser page, Click on Add Child Parser

4. This should open a brand new form to enter the new “Child” parser’s data in.

5. In our case PairCreated is the event emitted when a pair is created and pair holds the address of the field. So we select the same

1. PairCreated is picked. 2. pair is the column picked

6. Enter the address of any random pair. (Note: Every pair will be indexed, not just the one supplied. This column is used merely as a reference and to fetch ABI)

The ABI is loaded in automatically for verified contracts

7. Pick the events you want indexed. (At this time we can only track events for all deployed child contracts. There are future plans to support functions as well)

Pick the events you want

8. You can add any price plugins if you need. (Stay Tuned for a step-by step guide on this!)

9. Enter additional details about your child parser. This part is concerned with where you’d like to store your data (Schema) and how far back the data should go (Start Block). When you’re done, click on Add Child Parser.

10. Review yours Child parser’s details and change anything incorrect.

11. Fill in the rest of your Factory’s details and deploy your parser!

12. Both your Parser’s should be up and running now!

Price

There are a multitude of applications where tracking the price of a token is essential. Consider one of the most popular use cases for the factory pattern in Web3: A Dex. With the price plugin, the Parser allows you to track historical prices for all tokens involved. Stay tuned for our case study into Uniswap and how you can index it with Price details.

About Unmarshal

Unmarshal is a Multi-chain Web 3.0 data network aiming to deliver granular, reliable & real-time data to dApps, DeFi protocols, NFTs, Metaverse and GameFi solutions. Unmarshal provides the easiest way to query Blockchain data from Ethereum, Polygon, BNB Chain, Avalanche, Fantom, Celo, Solana, Klaytn, Kadena, Arbitrum, and XDC Network. Unmarshal network consists of data indexers and transforming tools to power Web 3.0 applications on any chain while providing a latent view of transformed data.

Website|Telegram Chat|Telegram Ann|Twitter|Medium|Discord

--

--

Unmarshal

The Most Advanced Blockchain Data Infrastructure #⃣ http://xscan.io: MultiChain Explorer http://unmarshal.io/parser: No Code Smart Contract Indexing