Prepare Environment
Check your environment is prepared with General Requirements and Database Storage Requirements. BlockScout requires a full archive node in order to import every state change for every address on the target network. For client specific settings related to a node running Erigon/Geth/Nethermind, please see Client Settings.For testing purposes, instead of an archive node, a test Ethereum client can be used. For instance, Anvil
Deployment Steps
1)git clone https://github.com/blockscout/blockscout
2) cd blockscout
3) Provide DB URL: export DATABASE_URL=postgresql://user:password@localhost:5432/blockscout
- Linux: Update the database username and password configuration
- Mac: Use logged-in user name and empty password
- Optional: Change credentials in
apps/explorer/config/test.exsfor test env
Example usage: Changing the default Postgres port from localhost:5432 if Boxen is installed.
mix do deps.get, local.rebar --force, deps.compile
5) Generate a new secret_key_base for the DB by setting a corresponding ENV var:export SECRET_KEY_BASE=VTIB3uHDNbvrY0+60ZWgUoUBKDn9ppLR8MI4CpRz4/qLyEFs54ktJfaNT6Z221No
In order to generate a new
secret_key_base run mix phx.gen.secretmix phx.digest.clean.
7) Set environment variables as needed.
CLI Example:
The
ETHEREUM_JSONRPC_VARIANT will vary depending on your client (nethermind, geth etc). More information on client settings.- Using docker:
docker run -p 8050:8050 ghcr.io/blockscout/smart-contract-verifier:latest
- Or install rust and build from sources:
cargo install --locked --git https://github.com/blockscout/blockscout-rs smart-contract-verifier-server- Then run the binary as
smart-contract-verifier-server
- Set ENV variables in CLI to enable the rust microservice for Blockscout (these can also be set at runtime).
mix compile
10) If not already running, start Postgres: pg_ctl -D /usr/local/var/postgres start
11) Create and migrate database mix do ecto.create, ecto.migrate
12) 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 -
mix phx.digest
14) Enable HTTPS in development. The Phoenix server only runs with HTTPS.
cd apps/block_scout_web; mix phx.gen.cert blockscout blockscout.local; cd -- Add blockscout and blockscout.local to your
/etc/hosts
If using Chrome, Enable
chrome://flags/#allow-insecure-localhostmix phx.server
16) Check the Frontend Migration section if you would like to connect the enhanced frontend UI to the manually installed backend.