This subgraph indexes and tracks data from the CryptoPunks NFT collection on the Ethereum blockchain. It provides a comprehensive view of CryptoPunks transactions, ownership, bids, listings, and market statistics using The Graph Protocol.
The CryptoPunks subgraph is built using The Graph, a decentralized protocol for indexing and querying blockchain data. This subgraph specifically tracks various events from the CryptoPunksMarket smart contract, creating and maintaining entities such as Punks, Accounts, Bids, Listings, Events, and State to provide a rich dataset for querying CryptoPunks-related information.
- Track Punk ownership and transfers
- Monitor bids and listings
- Record sales and price history
- Calculate floor prices and market statistics
- Convert ETH values to USD using Chainlink price feed
- Historical price data for early transactions
This subgraph is built on The Graph, an indexing protocol for querying networks like Ethereum. It allows for efficient, decentralized, and real-time data indexing from blockchain events and state changes. The Graph uses GraphQL as a query language, providing a powerful and flexible way to request exactly the data you need.
- Schema (
schema.graphql
): Defines the data structure for the subgraph. - Subgraph Manifest (
subgraph.yaml
): Configuration file for the subgraph. - Mapping (
src/crypto-punks-market.ts
): Contains the event handling logic. - Helpers (
src/utils/
): Utility functions for various operations.
-
Install dependencies:
yarn install
-
Generate types:
yarn codegen
-
Build the subgraph:
yarn build
-
Deploy the subgraph:
yarn deploy
The subgraph handles various events from the CryptoPunksMarket contract, including Assign, Transfer, PunkTransfer, PunkOffered, PunkBidEntered, PunkBidWithdrawn, PunkBought, and PunkNoLongerForSale.
These event handlers update the subgraph's state based on on-chain events, ensuring accurate and up-to-date data.
The subgraph uses two methods for ETH to USD conversion:
- Chainlink Price Feed: For recent transactions, it queries the Chainlink ETH/USD price feed in real-time.
- Historical Price Data: For older transactions (before the Chainlink feed was available), it uses a predefined set of historical price points.
The subgraph calculates and updates the floor price based on active listings.
Contributions to improve the subgraph are welcome. Please submit issues and pull requests on the project's GitHub repository.
This project is licensed under the Creative Commons CC0 1.0 Universal license. See the LICENSE file for details.