🚗 Autoscout is now available, providing a simple one-click explorer deployment with Blockscout’s optimized hosting infrastructure. Use it for early testing, modifications, and launching a full production-grade explorer. Get Started Now and have your explorer up-and-running in minutes.
📗 This guide walks you through a new Blockscout deployment including the user-friendly UI frontend and installation of all microservices. If you’d prefer a more automated approach see the docker-compose deployment page.

A. Prerequisites

Please familiarize yourself with the general requirements, db storage requirements, JSON RPC requirements and Client setting requirements before installing Blockscout.

Minimum Local Hardware Requirements

  • CPU: 4core / 8core
  • RAM: 8GB / 16GB / 32GB
  • DISK: 120gb or 500GB NVME SSD or Standard SSD
  • OS: Linux, MacOS

Hosting Environment Hardware Requirements

If you are running Blockscout on a cloud server or other remote environment, see the Hardware and Hosting Requirements

Software Dependencies

For Erlang/Elixir, asdf is recommended to install and set the appropriate versions. Note the supported versions for Erlang/Elixir/Node are specified in the .tool-versions file. Additional Instructions for setting up the environment are available for Ubuntu and MacOS.
DependencyMacLinux
Erlang/OTP 26brew install erlangErlang Install Example
Elixir 1.15.xbrew install elixirElixir Install Example
Postgres 12, 13, 14brew install postgresqlPostgres Install Example
Node.js 18.x.xbrew install nodeNode.js Install Example
Automakebrew install automakeAutomake Install Example
Libtoolbrew install libtoolLibtool Install Example
Inotify-toolsNot RequiredUbuntu - apt-get install inotify-tools
GCC Compilerbrew install gccGCC Compiler Example
GMPbrew install gmpInstall GMP Devel
Make-sudo apt install makeif Debian 9
G++ Compiler-sudo apt install g++if Debian 9

B. Manual Deployment

The following guide contains 5 sections that cover a complete Blockscout installation.
  1. Prepare the backend
  2. Run microservices
  3. Add the microservices integration to backend
  4. Run the backend
  5. Run the frontend

1. Prepare the backend

1) Clone the repository git clone https://github.com/blockscout/blockscout blockscout-backend 2) Change directories cd blockscout-backend 3) Provide DB URL with your username export DATABASE_URL=postgresql://username:password@localhost:5432/blockscout
  • Linux: Update the database username and password configuration
  • Mac: Use logged-in user name and empty password (export DATABASE_URL=postgresql://username:@localhost:5432/blockscout )
  • Optional: Change credentials in apps/explorer/config/test.exs for test env Example usage: Changing the default Postgres port from localhost:5432 if Boxen is installed.
You can check the regex pattern for the db url via https://regex101.com/ with the following regular expression:
\w*:\/\/(?<username>[a-zA-Z0-9_-]*):(?<password>[a-zA-Z0-9-*#!%^&$_.]*)?@(?<hostname>(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])):(?<port>\d+)\/(?<database>[a-zA-Z0-9_-]*)
4) Install Mix dependencies and compile mix do deps.get, local.rebar --force, deps.compile 5) Generate a new secret_key_base for the DB mix phx.gen.secret 6) Copy keybase and export as an env (for example) export SECRET_KEY_BASE=VTIB3uHDNbvrY0+60ZWgUoUBKDn9ppLR8MI4CpRz4/qLyEFs54ktJfaNT6Z221No 7) Export remaining environment variables as needed. CLI basic example:
export ETHEREUM_JSONRPC_VARIANT=geth
export ETHEREUM_JSONRPC_HTTP_URL=http://localhost:8545
export API_V2_ENABLED=true
export PORT=3001 # set for local API usage
export COIN=yourcoin
export COIN_NAME=yourcoinname
export DISPLAY_TOKEN_ICONS=true
Notes: 8) Compile the application: mix compile 9) If not already running, start Postgres: pg_ctl -D /usr/local/var/postgres start or brew services start postgresql
Check postgres status: pg_isready
10) Create and migrate database mix do ecto.create, ecto.migrate
If you are in dev environment and have run the application previously with a different blockchain, drop the previous database: mix do ecto.drop, ecto.create, ecto.migrate Be careful since this will delete all data from the DB. Don’t execute it on production if you don’t want to lose all of the data!
11) Install Node.js dependencies
Optional: If preferred, use npm ci rather than npm install to strictly follow all package versions in package-lock.json.
cd apps/block_scout_web/assets; npm install && node_modules/webpack/bin/webpack.js --mode production; cd - cd apps/explorer && npm install; cd - 12) Build static assets for deployment mix phx.digest 13) Enable HTTPS in development. The Phoenix server only runs with HTTPS. cd apps/block_scout_web; mix phx.gen.cert blockscout blockscout.local; cd - 14) Add blockscout and blockscout.local to your /etc/hosts
   127.0.0.1       localhost blockscout blockscout.local

   255.255.255.255 broadcasthost

   ::1             localhost blockscout blockscout.local
If using Chrome, Enable chrome://flags/#allow-insecure-localhost
🎉 This completes the backend setup! Proceed to setup microservices.

2. Run Microservices

You will use Docker to run 4 Rust microservices: smart-contract verification, smart-contract sol2uml visualizer, sig-provider, and stats services. These add additional functionality to your instance once everything is connected.

Prerequisites

  • Docker v20.10+
  • Docker-compose 2.x.x+

Commands

  1. Go to the docker-compose directory cd ./blockscout-backend/docker-compose
  2. run docker-compose docker-compose -f microservices.yml up -d

Stats

sig-provider

Sc-visualizer

A visualizer for smart contracts.

Sc-verifier

A separate smart contract verification service.
  • You can also use the Blockscout endpoint for smart-contract verification if you prefer (instructions in the integration section)
To stop all microservices, run docker-compose -f microservices.yml down
To troubleshoot issues with a container, run docker ps to check which containers are not starting.Check logs with docker logs visualizer -f

3. Add the microservices integration to the backend

Add the microservices env variables to the backend. Use the export command to add.
export MICROSERVICE_SC_VERIFIER_ENABLED=true
export MICROSERVICE_SC_VERIFIER_URL=http://localhost:8082/
export MICROSERVICE_VISUALIZE_SOL2UML_ENABLED=true
export MICROSERVICE_VISUALIZE_SOL2UML_URL=http://localhost:8081/
export MICROSERVICE_SIG_PROVIDER_ENABLED=true
export MICROSERVICE_SIG_PROVIDER_URL=http://localhost:8083/
The Blockscout team also provides an endpoint for smart-contract verification. To use, set the following for the MICROSERVICE_SC_VERIFIER envs
export MICROSERVICE_SC_VERIFIER_ENABLED=true
export MICROSERVICE_SC_VERIFIER_URL=https://eth-bytecode-db.services.blockscout.com/
export MICROSERVICE_SC_VERIFIER_TYPE=eth_bytecode_db
🎉 This completes the microservices setup! Proceed to run the backend and frontend.

4. Run backend

  1. Return to the blockscout-backend directory ./blockscout-backend
  2. Run mix phx.server
The API will be available at http://localhost:3001/api/

5. Run frontend

The frontend can be added to the same high-level directory as the blockscout-backend or a different directory of your choice.
  1. clone the blockscout frontend repository git clone https://github.com/blockscout/frontend blockscout-frontend
  2. change directories
cd blockscout-frontend
  1. create a .env file, for example
touch .env
  1. Add this minimal set of required env variables (additional variables are available here)
NEXT_PUBLIC_API_HOST=localhost
NEXT_PUBLIC_API_PORT=3001
NEXT_PUBLIC_API_PROTOCOL=http
NEXT_PUBLIC_STATS_API_HOST=http://localhost:8080
NEXT_PUBLIC_VISUALIZE_API_HOST=http://localhost:8081
NEXT_PUBLIC_APP_HOST=localhost
NEXT_PUBLIC_APP_PORT=3000
NEXT_PUBLIC_APP_INSTANCE=localhost
NEXT_PUBLIC_APP_ENV=development
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL='ws'
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=<your-secret>
  1. install dependencies
yarn install
  1. run frontend
yarn dev
🎉 Once completed, the frontend should be available at http://localhost:3000
Notes: