GithubHelp home page GithubHelp logo

dapps-staking-indexer's Introduction

Astar dApp staking indexer

This is a simple Astar dApp staking indexer. The indexer is based on SubQuery engine and it indexes the following events:

  • dApp registration
  • dApp unregistration
  • stake
  • unstake
  • nomination transfer
  • reward

The indexer has never been used in production. It has been developed as proof of concept. Although all local testing was good, please take the previous sentences into consideration before use this code in real life scenarios.

Preparation

Environment

  • Typescript are required to compile project and define types.

  • Both SubQuery CLI and generated Project have dependencies and require Node.

  • Docker

Install the SubQuery CLI

Install SubQuery CLI globally on your terminal by using NPM:

npm install -g @subql/cli

Initialize indexer

Under the project directory, run following command to install all the dependency.

yarn install

Build the project

yarn codegen
yarn build

Indexing and Query

Run required systems in docker

Start Docker and under the project directory run following command:

docker-compose pull && docker-compose up

Query the project

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.

You can try to query with the following code to get a taste of how it works.

query {
  stakes(first:10, orderBy: TIMESTAMP_ASC) {
    nodes {
      contract,
      staker,
      amount,
      timestamp,
      block
    }
  }
}
query {
  contracts {
    nodes {
      id,
      owner,
      state,
      blockRegistered,
      blockUnregistered
    }
  }
}

Important note

Don't forget to stake on your favorite dApps on Astar portal.

dapps-staking-indexer's People

Contributors

bobo-k2 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

dapps-staking-indexer's Issues

Typescript Build Error on the entity EraReward, Call, Stake, and Contract & Problems running the app.

Hello

I follow all the instruction until build the project section using yarn build. it throws this error instead

yarn run v1.22.19
$ subql build
 ›   Error: [tsl] ERROR in /home/corlys/Dev/dapps-staking-indexer/src/mappings/dappsStakingCallHandlers.ts(51,17)
 ›         TS2554: Expected 5 arguments, but got 1.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

after some digging, the entities mention above will throw an error if the values are not initialized directly on the parameters. Is this also like this on your side? do you use a different version?

Also if i then suplied the values directly to the parameters and run the docker-compose pull && docker-compose up command is it suppose to print anything other than this or are we suppose to wait longer?

Attaching to dapps-staking-indexer-graphql-engine-1, dapps-staking-indexer-postgres-1, dapps-staking-indexer-subquery-node-1

I also check http://localhost:3000 and there is nothing there

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.