- Messari Subgraphs
- EIP-721 (NFTS on The Graph Network)
- Lens Protocol
- Unlock Protocol on The Graph Network
- Open Sea Subgraph
- LiNEAR
- Aave Gotchi
- Tellor
- Live Peer
- ENS
- UMA on The Graph Network
- Contract to index
- Google Slides for NFT Subgraph Development Workshop
- Questions: twitter.com/schmid_si
- Install graph-cli:
yarn global add @graphprotocol/graph-cli
-
Download the ABI
-
Run this command to initialise the subgraph with events:
graph init \
--studio \
--protocol ethereum \
--from-contract 0xc2c747e0f7004f9e8817db2ca4997657a7746928 \
--index-events \
--contract-name Hashmasks \
--network mainnet \
hashmasks hashmasks-subgraph
- Inspect the source
- Change startblock:
source:
address: "0xc2c747e0f7004f9e8817db2ca4997657a7746928"
abi: Hashmasks
startBlock: 11743743
– Create new subgraph on Subgraph Studio named "Hashmasks"
graph auth --studio ...
yarn deploy
# schema.graphql
type Transfer @entity {
id: ID!
from: Bytes! # address
to: Bytes! # address
tokenId: BigInt! # uint256
}
Make them immutable for performance improvements
type Transfer @entity(immutable: true) {
id: ID!
from: Bytes! # address
to: Bytes! # address
tokenId: BigInt! # uint256
timestamp: BigInt!
blockNumber: BigInt!
}
Use event.transaction.hash.toHex() + "-" + event.logIndex.toString()
as the id for events
export function handleTransfer(event: TransferEvent): void {
let entity = new Transfer(
event.transaction.hash.toHex() + "-" + event.logIndex.toString()
);
entity.blockNumber = event.block.number;
entity.timestamp = event.block.timestamp;
entity.from = event.params.from;
entity.to = event.params.to;
entity.tokenId = event.params.tokenId;
entity.save();
}
- Identify the important entities: Token, Owner, Contract
- Link them
type Transfer @entity(immutable: true) {
id: ID!
from: Owner!
to: Owner!
token: Token!
timestamp: BigInt!
blockNumber: BigInt!
}
type Token @entity {
id: ID!
owner: Owner
uri: String
transfers: [Transfer!]! @derivedFrom(field: "token")
contract: Contract
}
type Owner @entity {
id: Bytes! # Use bytes as ID
ownedTokens: [Token!]! @derivedFrom(field: "owner")
balance: BigInt
}
type Contract @entity {
id: ID!
name: String
symbol: String
totalSupply: BigInt
mintedTokens: [Token!]! @derivedFrom(field: "contract")
}
- https://github.com/schmidsi/hackathon-starterkit
- https://github.com/scaffold-eth/scaffold-eth#-scaffold-eth
- https://soulbound.xyz
- https://github.com/Developer-DAO/resources
- https://dev.to/dabit3/the-complete-guide-to-full-stack-ethereum-development-3j13
- https://github.com/itsjerryokolo/CryptoPunks
- https://github.com/dabit3/building-a-subgraph-workshop
- https://thegraph.com/docs/developer/quick-start
- https://thegraph.com/discord
- https://protean-labs.github.io/subgrounds/