Indexer for various NFT marketplaces on Ethereum (Seaport, SuperRare, KnownOrigin, etc.). Envio is used as the indexer framework. Please refer to the Envio documentation website for a thorough guide on all Envio indexer features.
- Node.js (use v18 or newer)
- pnpm (use v9 or newer)
- Podman (for deployments—this is a drop-in replacement for Docker so Docker should also work fine but you have to run the docker compose commands on your own instead of the documented
pnpm
commands in theDeployment
andUpgrades
sections)
Find buys, sells, or swaps by user address
The following query returns buys
. Simply replace buys
with sells
or swaps
for the other two types of trades.
query SalesByUser($userAddress: String!) {
Account(where: { address: { _ilike: $userAddress } }) {
id
address
buys(order_by: { sale: { timestamp: desc } }) {
sale {
id
timestamp
transactionHash
market
offerer {
address
}
recipient {
address
}
offerTokens
offerIdentifiers
offerAmounts
considerationTokens
considerationIdentifiers
considerationAmounts
}
}
}
}
Find all sales involving a specific NFT contract
query SalesByNFTContract($contractAddress: String!) {
NFTContract(where: { address: { _ilike: $contractAddress } }) {
id
address
tokens {
sales(order_by: { sale: { timestamp: desc } }) {
sale {
id
timestamp
transactionHash
market
offerer {
address
}
recipient {
address
}
offerTokens
offerIdentifiers
offerAmounts
considerationTokens
considerationIdentifiers
considerationAmounts
}
}
}
}
}
Find all sales of a specific NFT token
query SalesByNFTToken($contractAddress: String!, $tokenId: String!) {
NFTToken(
where: { contract: { address: { _ilike: $contractAddress } }, tokenId: { _eq: $tokenId } }
) {
id
tokenId
contract {
id
address
}
sales(order_by: { sale: { timestamp: desc } }) {
sale {
id
timestamp
transactionHash
market
offerer {
address
}
recipient {
address
}
offerTokens
offerIdentifiers
offerAmounts
considerationTokens
considerationIdentifiers
considerationAmounts
}
}
}
}
pnpm codegen
A Graph URL (GRAPH_API_URL
) needs to be provided in order to run test queries against a deployed Graph. If not provided, the query tests will be skipped.
# Run all tests
pnpm test
# Run only GraphQL integration tests
pnpm test:queries
# Run only unit tests
pnpm test:unit
Copy the following .env.*.example
files to .env.*
and update as you see fit:
cp .env.postgres.example .env.postgres
cp .env.hasura.example .env.hasura
cp .env.indexer.example .env.indexer
Then you should be able to start a local deployment with:
pnpm start
Visit http://localhost:8080 and navigate to Data
and click to track all database tables. Then you should be able to start using the playground.
Track the deployment status and other metadata about the indexer by running the following query in the playground:
{
_meta {
chainId
progressBlock
eventsProcessed
bufferBlock
firstEventBlock
sourceBlock
readyAt
isReady
startBlock
endBlock
}
}
If there are schema updates, currently the simplest approach is to restart with a clean slate.
TODO: Use envio local db-migrate up
instead.
pnpm restart:clean
If there is no re-indexing to be done, you can simply restart with:
pnpm restart