Skip to content

Repository files navigation

XDAG Block Explorer

This software provides a detailed view of the xdag network presented in a nice UI.

Features

  • network statistics and graphs
  • list of latest main blocks
  • mining calculator
  • balance checker
  • block details
  • API interface
  • responsive design

Installation on Ubuntu 24.04

  1. install, configure and run XdagJ
  2. adduser explorer - explorer runs as regular user, sudo premissions should not be given. Continue as root or as regular user with sudo permissions.
  3. install PHP8.5
  • sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common
  • sudo add-apt-repository ppa:ondrej/php
  • sudo apt install php8.5-fpm php8.5-cli php8.5-bcmath php8.5-curl php8.5-gd php8.5-mbstring php8.5-mysql php8.5-readline
  • create PHP-FPM pool: nano /etc/php/8.5/fpm/pool.d/explorer.conf
[explorer]
user = $pool
group = $pool
listen = /run/php/php8.5-fpm-$pool.sock

listen.owner = www-data
listen.group = www-data
listen.mode = 0660
pm = dynamic
pm.max_children = 10
pm.start_servers = 3
pm.min_spare_servers = 1
pm.max_spare_servers = 4
  • sudo systemctl enable php8.5-fpm
  • sudo systemctl restart php8.5-fpm
  1. install MySQL 8.0+
  • sudo apt install mysql-server mysql-client
  • sudo mysql
  • ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '...............'; - choose a strong password
  • exit
  • sudo mysql_secure_installation
  1. configure MySQL 8.0+
  • sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
  • add disable_log_bin at end of file
  • add tmp_table_size = 2G at end of file
  • add max_heap_table_size = 2G at end of file
  • sudo systemctl enable mysql
  • sudo systemctl restart mysql
  1. create database and MySQL user for explorer app
  • sudo mysql -p - enter root password
  • CREATE USER explorer@'%' IDENTIFIED BY '...............'; - choose a strong password
  • CREATE DATABASE explorer CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  • GRANT ALL ON explorer.* TO explorer@'%';
  • FLUSH PRIVILEGES;
  • exit
  1. install composer
  2. install NojdeJS 18
  • curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
  • sudo apt install -y nodejs
  1. prepare explorer app
  • sudo mkdir /var/www/explorer && sudo chown explorer:explorer /var/www/explorer
  • as explorer user, change into /var/www/explorer folder
  • execute git clone https://github.com/XDagger/explorer.git .
  • execute composer install, npm ci, npm run production, cp .env.example .env, php artisan key:generate
  • edit .env and supply MySQL connection parameters and XdagJ RPC URL
  • execute php artisan migrate
  • add crontab entry: * * * * * /usr/bin/php8.5 /var/www/explorer/artisan schedule:run >> /dev/null 2>&1
  1. install and configure nginx
  • sudo apt install nginx
  • replace default server: truncate -s 0 /etc/nginx/sites-available/default, nano /etc/nginx/sites-available/default
server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;

    merge_slashes off;
    root /var/www/explorer/public;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /index.php {
        include fastcgi_params;
        fastcgi_read_timeout 320;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php8.5-fpm-explorer.sock;
    }

    location = /favicon.ico {
        access_log off;
        log_not_found off;
    }

    location = /robots.txt {
        access_log off;
        log_not_found off;
    }
}
  • sudo systemctl enable nginx
  • sudo systemctl restart nginx
  1. optionally install Let's Encrypt certificate, configure https redirects

Updating to latest version

As explorer user, change into /var/www/explorer folder

  • git pull
  • composer install
  • php artisan migrate
  • npm ci
  • npm run production

Development

The explorer needs PHP 8.5 with bcmath, MySQL 8.0+, Composer and Node.js. Clone the repository, then:

  • composer install, npm ci, npm run dev
  • cp .env.example .env, php artisan key:generate, fill in the database credentials and the XdagJ RPC URL
  • php artisan migrate
  • git config core.hooksPath .githooks - enables the pre-commit hook, which formats staged PHP files with Laravel Pint and adds the fixes to the commit
  • php artisan serve

php artisan db:seed-dev replaces all explorer data in your database with made-up network stats, main blocks, wallets and transactions around the current time, so you can click through the whole explorer without running XdagJ. Do not run the scheduler meanwhile: without a node, fetching the stats marks the network as not synchronized. Run the command again whenever you want fresh data.

Tests use a database of their own, which is wiped on every run - never point them at a database you care about.

  • cp .env.testing.example .env.testing, php artisan key:generate --env=testing, fill in the test database credentials
  • composer test - migrates the test database and runs the whole suite in parallel

Code style is checked by vendor/bin/pint --test, vendor/bin/pint fixes it.

About

XDAG Block Explorer

Resources

Stars

8 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages