Zentrace is a comprehensive block explorer and analytics platform tailored for the Zenchain blockchain. Originating as a fork from Blockscout, Zentrace has undergone significant enhancements to improve functionality and ease of deployment across various operating systems.
Zentrace ecosystem consists of the following components:
- Zentrace Backend (the current repository)
- Zentrace Frontend https://github.com/zenchain-protocol/zentrace-frontend
- Zentrace Rust Services https://github.com/zenchain-protocol/zentrace-rs
The process of setting up the development environment for Zentrace Backend, which is built using Elixir, differs depending on the operating system in use. This tutorial is designed to guide you through the preparation of your development environment, tailored to each of these operating systems.
To successfully compile your code, it's essential to first install the required dependencies, with the installation process varying depending on your operating system.
Git is needed to get code from repositories.
Follow the instructions based on your Linux distribution (WSL by default installs Ubuntu) https://git-scm.com/download/linux
Install Homebrew https://brew.sh and execute the following command:
brew install gitDownload and execute the installer based on your architecture https://git-scm.com/download/win
curl package is needed, you can install it executing the following command (Ubuntu as reference):
sudo apt install -y curlclone the Asdf repository with the following command:
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0edit the ~/.bashrc file appending the following lines:
. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"install needed plugins executing the following commands:
asdf plugin add erlang
asdf plugin add elixir
asdf plugin add nodejscurl and coreutils packages are needed, you can install them executing the following commands:
brew install coreutils curlclone the Asdf repository with the following command:
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0create/edit the ~/.bash_profile file appending the following lines:
. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"install needed plugins executing the following commands:
asdf plugin add erlang
asdf plugin add elixir
asdf plugin add nodejsInstall PostgreSQL with the following command:
sudo apt install postgresqlalter postgres password:
sudo -u postgres psql template1
ALTER USER postgres with encrypted password 'postgres';create the environment variable used by the backend as connection string:
export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/zentraceInstall PostgreSQL with the following command:
brew install postgresql@15 libpq
brew link --force libpqalter MAC_USER password:
ALTER USER MAC_USER with encrypted password 'postgres';create the environment variable used by the backend as connection string:
export DATABASE_URL=postgresql://MAC_USER:postgres@localhost:5432/zentraceExecute the following command (Ubuntu as reference):
sudo apt install -y libssl-dev make automake autoconf libncurses5-dev gcc g++ inotify-toolsCreate a new folder, open it in the terminal and execute:
git clone https://github.com/zenchain-protocol/zentrace-backend
Open zentrace-backend folder and execute:
asdf install
mix local.hex --force
mix do deps.get, local.rebar --force, deps.compileYou can also build and run all within Docker directly.
Edit the following environment variables:
- common-backend.env
- common-frontend.env
- common-smart-contract-verifier.env
- common-stats.env
- common-visualizer.env
and then execute:
cd docker-compose
docker compose up -d
cd docker-compose
docker compose -f external-frontend.yml up -d
starts containers and starts listening using the port 80.
Generate the database structure with the following command:
mix do ecto.create, ecto.migrateGenerate a new authentication encryption key:
mix phx.gen.secretset the key into the SECRET_KEY_BASE environment variable:
export SECRET_KEY_BASE=KEYInstall Node.js packages:
cd apps/block_scout_web/assets
npm install && node_modules/webpack/bin/webpack.js --mode production
cd -Generate local SSL certificate for development:
cd apps/block_scout_web
mix phx.gen.cert zentrace zentrace.localEdit common-backend.env variables and execute the following command to export all:
export $(grep -v '^#' ./docker-compose/envs/common-backend.env | xargs -d '\n')export $(grep -v '^#' ./docker-compose/envs/common-backend.env | xargs -0)You can now start the application for development with the following command:
mix phx.server