Giter Site home page Giter Site logo

polkastats / polkastats Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 16.0 6.65 MB

PolkaStats block explorer

License: Apache License 2.0

JavaScript 4.86% Dockerfile 0.10% Shell 0.32% Vue 69.55% SCSS 2.25% PLpgSQL 2.86% TypeScript 20.07%
block-explorer blockchain kusama polkadot polkadot-js

polkastats's Introduction

PolkaStats

Polkastats is a block explorer for Polkadot, Kusama and other blockchains based on Substrate framework.

Check it out live versions:

Install

Dependencies

In Ubuntu 20.04 server you can do:

apt update && apt upgrade -y && apt auto-remove
apt install git build-essential apt-transport-https ca-certificates curl software-properties-common libpq-dev gnupg

# docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
apt update
apt install docker-ce

# docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

# node v16
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=16
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
apt-get update
apt-get install nodejs -y

# yarn
npm install --global yarn

Mono repo

Clone Polkastats repository and install js dependencies:

cd /usr/local/
git clone https://github.com/polkastats/polkastats.git
cd polkastats
yarn

Backend

Before build dockers we need to copy and edit an .env file:

cp backend/.env-sample backend/.env

NOTE: change Hasura password in HASURA_GRAPHQL_ADMIN_SECRET environmment variable. Also you can add your Sentry instance URL.

Polkadot:

yarn workspace backend docker:polkadot

Or Kusama:

yarn workspace backend docker:kusama

That will build and start all the required dockers:

  • PostgreSQL
  • Hasura GraphQL server
  • Parity Polkadot client
  • Node.js crawler
  • Substrate API Sidecar

Hasura console

After that you can access to Hasura console at http://server_ip_address:8082 and login as admin using the password you previously set in HASURA_GRAPHQL_ADMIN_SECRET environment variable.

Nginx configuration

You can use Nginx as a inverse proxy for Hasura GraphQL and also to serve the static frontend.

Example nginx config /etc/nginx/sites-available/default with SSL enabled using Certbot:

server {
    root /usr/local/polkastats-ng/frontend/dist;
    index index.html index.htm index.nginx-debian.html;
    server_name yourdomain.io;

    location / {
        try_files $uri $uri/ /index.html;
    }

    location /graphql {
        proxy_pass http://localhost:8082/v1/graphql;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location ~ ^/api/ {
        proxy_pass http://localhost:8000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/yourdomain.io/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.io/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
    if ($host = yourdomain.io) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name yourdomain.io;
    return 404; # managed by Certbot
}

Apply your new configuration:

ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
systemctl restart nginx

Frontend

First, copy the frontend config file either for Kusama:

cp frontend/frontend.config-kusama.js frontend/frontend.config.js

Or Polkadot:

cp frontend/frontend.config-polkadot.js frontend/frontend.config.js

Start a dev frontend with hot reload at http://localhost:3000

yarn workspace frontend dev

Generate a static build under frontend/dist directory:

yarn workspace frontend generate

Filter outside connections to RPC

/sbin/iptables -A INPUT -p tcp -i <put_your_internet_interface_here> --dport 9944 -j DROP

polkastats's People

Contributors

mariopino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

polkastats's Issues

Very Good rating for Identity (Validator Profile Page)

Dear Polkastats.io,

May I suggest that validators who have attained a 'Known good' identity verification also obtain a "Very good" identity rating on the respective profile page. While having all of the fields of an identity filled is certainly a good measure of identity, the known good rating is (in my opinion) equally as good since it requires some elevated means of verification.

Regards,
Paradox

Include a Thousand Validator identifier on Validator's profile page.

Dear Polkastat.io,

I would like to suggest that on the respective validator profile page that you include an identifier indicating that the validator is a member of the Thousand Validator Programme (TVP).

It is my opinion that this additional bit of information would be useful to nominators as members of the TVP are upheld to performance standards such as controls on their commission, no slash history, certainty of pay-outs and enter the active set periodically.

The W3F provides endpoints which list the members of the programme on Kusama and on Polkadot found https://kusama.w3f.community/candidates and here https://polkadot.w3f.community/candidates respectfully.

Your feedback would be most appreciated.

Regards,
Paradox

Era points question

Looking at the Validator dashboard I see X Bad for Era Points Below average! Validator got 0.02% of the total era points in the last 21 days while average was 0.11% if the validator is not in the active set do you still take 0 points into the Avg or should only be active set eras should be accounted for.

Running for other chain Substrate

Hello

My project build on Substrate, and when I try to setup this project on localhost it working well for Kusama and Polkadot, but when I try to test for own blockchain https://node.phuquoc.dog get the error below

Screen Shot 2021-09-02 at 17 46 10

image

The config frontend

export const network = {
  id: 'phuquocdog',
  name: 'Phu Quoc Dog',
  tokenSymbol: 'PQD',
  tokenDecimals: 10,
  ss58Format: 42,
  coinGeckoDenom: 'phuquocdog',
  nodeWs: 'wss://node.phuquoc.dog',
  backendWs: 'ws://localhost:8082/v1/graphql',
  backendHttp: 'http://localhost:8082/v1/graphql',
  googleAnalytics: 'UA-172854168-1',
  theme: '@/assets/scss/themes/polkastats.scss',
  // ranking
  historySize: 84, // 21 days
  erasPerDay: 4,
  validatorSetSize: 24,
}
export const paginationOptions = [10, 20, 50, 100]

Thanks

Failed build frontend

ERROR in ../node_modules/@polkadot/api/rx/Api.js 108:2
Module parse failed: Unexpected character '#' (108:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| export class ApiRx extends ApiBase {

#isReadyRx;
| /**
| * @description Create an instance of the ApiRx class
@ ../node_modules/@polkadot/api/rx/index.js 3:0-33 3:0-33
@ ../node_modules/@polkadot/api/bundle.js
@ ../node_modules/@polkadot/api/index.js
@ ../node_modules/babel-loader/lib??ref--2-0!../node_modules/@nuxt/components/dist/loader.js??ref--0-0!../node_modules/vue-loader/lib??vue-loader-options!./layouts/default.vue?vue&type=script&lang=js&
@ ./layouts/default.vue?vue&type=script&lang=js&
@ ./layouts/default.vue
@ ./node_modules/.cache/nuxt/App.js
@ ./node_modules/.cache/nuxt/index.js
@ ./node_modules/.cache/nuxt/client.js
@ multi ../node_modules/@nuxt/components/lib/installComponents.js ./node_modules/.cache/nuxt/client.js

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.