Giter VIP home page Giter VIP logo

polkastats-ng'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
apt install git build-essential apt-transport-https ca-certificates curl software-properties-common libpq-dev

# 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
curl -fsSL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh
bash nodesource_setup.sh
apt install nodejs

# yarn
npm install --global yarn

Mono repo

Clone Polkastats-ng repository and install js dependencies:

cd /usr/local/
git clone https://github.com/Colm3na/polkastats-ng.git
cd polkastats-ng
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

polkastats-ng's People

Contributors

mariopino avatar

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.