Skip to content

secsec2025/cryptopunks-subgraph-migration

Repository files navigation

cryptopunks-subgraph-migration

A quest to migrate CryptoPunks subgraph to Subsquid

Introduction

This is the squid implementation of the cryptopunks subgraph. https://thegraph.com/explorer/subgraph?id=YqMJatbgbqy1GodtbYZv4U9NzyaScCgSF7CAE5ivAM7&view=Overview

What is Changed?

  • Batch Processing is used.
  • The schema.graphql file has been changed as mentioned in the below section.
  • Punk Metadata is fetched after the squid is fully synced with the blockchain.
  • An EntityCache is used to store the entities in memory to improve performance.
  • The queries may be slightly different compared to the subgraph version due to the schema changes made. But it will not affect the results.
  • Please note that, transaction hashes stored in entities are in `Byte` format, not in `String`.

How to start?

git clone https://github.com/secsec2025/cryptopunks-subgraph-migration.git
cd cryptopunks-subgraph-migration
npm ci
sqd up
sqd process &
sqd serve

GraphQL Schema Changes

  • Interfaces have been removed. Concrete types are used instead. This is due to typegen not working with interfaces.
  • All the Event types are considered as one entity called Event. Events can be distinguished based on Event.type
  • Bid and Ask are considered as one entity called Offer. Offers can be distinguished based on Offer.offerType
  • NFT interface is removed and Punk entity is used instead.
  • Due to the above reasons, subgraph queries will have to be slightly modified to fetch the results.

Squid Stats

  • Time to fully sync (without metadata) - Less than 2 hours (1 hour and 50 min approximately)
  • You can download the fully synced Postgres database (up to 18489539th block/ without metadata) here.
  • Multicall Endpoint gives some errors. So I was unable to use it.

What's Next to Do?

  • Add more sample queries. queries.md
  • Add custom resolvers to make the querying more similar to the subgraph.

About

A quest to migrate CryptoPunks subgraph to Subsquid

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published