**This SubQuery project indexes all events from the Lotto dApp **
First, install SubQuery CLI globally on your terminal by using NPM npm install -g @subql/cli
You can either clone this GitHub repo, or use the subql
CLI to bootstrap a clean project in the network of your choosing by running subql init
and following the prompts.
Don't forget to install dependencies with npm install
or yarn install
!
The simplest way to run your project is by running yarn dev
or npm run-script dev
. This does all of the following:
yarn codegen
- Generates types from the GraphQL schema definition and contract ABIs and saves them in the/src/types
directory. This must be done after each change to theschema.graphql
file or the contract ABIsyarn build
- Builds and packages the SubQuery project into the/dist
directorydocker-compose pull && docker-compose up
- Runs a Docker container with an indexer, PostgeSQL DB, and a query service. This requires Docker to be installed and running locally. The configuration for this container is set from yourdocker-compose.yml
You can observe the three services start, and once all are running (it may take a few minutes on your first start), please open your browser and head to http://localhost:3000 - you should see a GraphQL playground showing with the schemas ready to query. Read the docs for more information or explore the possible service configuration for running SubQuery.
For this project, you can use the following GraphQL code to query the data.
query {
participations {
nodes { id, accountId, numRaffle, numbers }
}
}
query GetParticipations($numRaffle: BigFloat, $accountId: String){
participations(filter: {and: [{numRaffle: {equalTo: $numRaffle}}, {accountId: {equalTo: $accountId}}]}){
nodes{ accountId, numRaffle, numbers }
}
}
query {
results(orderBy: NUM_RAFFLE_DESC){
nodes{ numRaffle, numbers }
}
}
query{
winners(orderBy: NUM_RAFFLE_DESC){
nodes{numRaffle, accountId}
}
}