This project index:
- all accounts staking in the dApp 'Lucky' in the context of dAppStaking module
- all developer rewards received by the dApp 'Lucky' in the context of dAppStaking module
- all pending rewards distributed by the dApp 'Lucky'
- all claimed rewards distributed by the dApp 'Lucky'
-
Typescript are required to compile project and define types.
-
Both SubQuery CLI and generated Project have dependencies and require Node.
Last, under the project directory, run following command to install all the dependency.
yarn install
You will be mainly working on the following files:
- The Manifest in
project.yaml
- The GraphQL Schema in
schema.graphql
- The Mapping functions in
src/mappings/
directory
For more information on how to write the SubQuery, check out our doc section on Define the SubQuery
In order to index your SubQuery project, it is mandatory to build your project first. Run this command under the project directory.
yarn codegen
In order to deploy your SubQuery project to our hosted service, it is mandatory to pack your configuration before upload.
Run pack command from root directory of your project will automatically generate a your-project-name.tgz
file.
yarn build
Under the project directory run following command:
docker-compose pull && docker-compose up
Open your browser and head to http://localhost:3000
.
Finally, you should see a GraphQL playground is showing in the explorer and the schemas that ready to query.
Query amount staked by account via the dAppStaking
query {
stakes{
groupedAggregates(
groupBy: [ACCOUNT_ID],
having: { sum: {amount: { notEqualTo: "0" }}}
) {
sum{amount}, keys
}
}
}
Query amount staked by account for a given era
query {
stakes(filter: { era: { lessThanOrEqualTo: "2100" }}) {
groupedAggregates(
groupBy: [ACCOUNT_ID],
having: { sum: { amount: { notEqualTo: "0" }}}
) {
sum{amount}, keys
}
}
}
or
query {
accounts {
nodes {
id
stakes {
groupedAggregates(
groupBy: [ACCOUNT_ID],
having: { sum: { amount: { notEqualTo: "0" }}}
) {
sum{amount}
}
}
}
}
}
Query the dApp's rewards
query {
developerRewards {
aggregates {sum{amount}}
nodes {amount, era}
}
}
Query the dApp's rewards for a given era
query {
developerRewards(filter: { era: { equalTo: "2100" } }) {
nodes {amount, era}
}
}
Query the last dApp's rewards
query {
developerRewards(orderBy: ERA_DESC, first:1) {
nodes {amount, era}
}
}
Current era for the dApp Staking pallet
query {
palletInfos {
nodes {
currentEra
}
}
}
Query the total stake and the rewards distributed by account
query {
accounts{
nodes{
id,
totalStake,
totalRewards,
totalPending,
totalClaimed,
rewards{nodes{era, amount}},
rewardsClaimed{nodes{amount}}
}
}
}
Query a specific account
query {
accounts(filter : {id: {equalTo: "5C...hM"}}){
nodes{
id,
totalStake,
totalRewards,
totalPending,
totalClaimed,
rewards{nodes{era, amount}},
rewardsClaimed{nodes{amount}}
}
}
}