Skip to content

RequestNetwork/storage-subgraph

Repository files navigation

Request Network Storage Subgraph

A Subgraph to index Request transactions.

Getting started

  • Do the usual
git clone ...
cd ...
yarn
  • Prepare your environment
cp .env.example .env
  • Start a Graph Node and an IPFS node (connected to Request dedicated IPFS network)
docker-compose up -d
  • Create the subgraph. Do this only once (or each time you clear the Graph node)
yarn create-local
yarn codegen ./subgraph-private.yaml
yarn test
# or, run in Docker
yarn test:docker
yarn build ./subgraph-private.yaml
yarn deploy-local ./subgraph-private.yaml
  • Monitor the deployment of your new subgraph
yarn monitor-deployment-local

You can go to http://localhost:8000/ to see the GraphiQL ui.

Example queries

  • Get all transactions
query AllTransactions {
  transactions {
    id
    hash
    channelId
    blockNumber
    blockTimestamp
    smartContractAddress
    topics
    data
    encryptedData
    encryptionMethod
    publicKeys
  }
}
  • Get transactions by channelId
query ByChannelId($channelId: String!) {
  transactions(where: { channelId: $channelId }) {
    id
    hash
    channelId
    blockNumber
    blockTimestamp
    smartContractAddress
    topics
    data
    encryptedData
    encryptionMethod
    publicKeys
  }
}
  • Get transactions by topic
query ByChannelId($topics: [String!]) {
  transactions(where: { topics_contains: $topics }) {
    id
    hash
    channelId
    blockNumber
    blockTimestamp
    smartContractAddress
    topics
    data
    encryptedData
    encryptionMethod
    publicKeys
  }
}

Run on another network

To test this on another network than your local Ganache:

  • change the .env values to your own
  • run docker-compose down
  • run docker-compose up -d
  • re-create & deploy the subgraph, with the right subgraph manifest (xdai, rinkeby...)

Troubleshooting

The admin API is available at http://localhost:8030/graphql

fragment status on SubgraphIndexingStatus {
  subgraph
  synced
  health
  entityCount
  chains {
    network
    earliestBlock {
      number
    }
    chainHeadBlock {
      number
    }
    latestBlock {
      number
    }
    latestBlock {
      number
    }
  }
  fatalError {
    message
  }
  nonFatalErrors {
    message
  }
}

query {
  indexingStatusForCurrentVersion(
    subgraphName: "RequestNetwork/request-storage"
  ) {
    ...status
  }

  indexingStatusForPendingVersion(
    subgraphName: "RequestNetwork/request-storage"
  ) {
    ...status
  }
}

About

A Subgraph to index Request transactions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •