Skip to content

Clipto-Platform/clipto-subgraph

Repository files navigation

Clipto Graph

This subgraph indexes for v2 architecture (using graph for all data storage)

  1. To generate the subgraph.yaml file
# requires mustache to be install
$ npm install -g mustache

# for mainnet
$ npm run prepare:mainnet

# for testnet
$ npm run prepare:testnet
  1. Generate types for current contract
$ graph codegen
  1. To compile the mappings
$ graph build
  1. Add auth token
$ graph auth --product hosted-service <access-token>
  1. Deploy
$ graph deploy --product hosted-service <username/subgraph name>

Example Queries

  1. Get all request order by timestamp
{
    requests(
        orderBy: timestamp
        orderDirection: desc
    ) {
        id
        requestId
        requester
        creator {
            id
        }
        amount
        description
        delivered
    }
}
  1. To get all transfer history for particular token
{
    transfers(
        where: {
            nftContract: "0x123....."
            tokenId: 0
        }) {
            id
            from
            to
            tokenId
            cliptoToken {
                currentOwner
            }
            nftContract
            eventType
            blockNumber
            timestamp
        }
    )
}