Setup Electrs

Install an Electrum server with Electrs.

An Electrum server is an indexing layer built on top of Bitcoin Core. It enables more efficient blockchain queries and easier wallet connections. Most wallets support Electrum.

We're going to use Electrs, a Rust implementation of an Electrum Server.

Install Electrs

Clone the repo:

cd ~
git clone https://github.com/romanz/electrs.git

Source the env file to update your $PATH with Rust & Cargo binaries:

. "$HOME/.cargo/env"

The binaries might already be in your PATH if Rust automatically added ."$HOME/.cargo/env" to your .profile, .bashrc, or .zshrc.

You can verify this with the command:

grep -H '.cargo/env' ~/.bashrc ~/.zshrc ~/.profile

Now you can compile electrs:

cd electrs
cargo build --locked --release

Once it's done, test the compilation was successful by checking the version:

Configure Electrs

Create the configuration file:

Add the following configuration to the config.toml file we just created:

  • cookie_file: Electrs can use the Bitcoin JSON-RPC API with cookie authentication.

  • daemon_rpc_addr: Bitcoin JSON-RPC API address and port.

  • daemon_p2p_addr: Bitcoin P2P address and port.

  • db_dir: Directory where Electrs store its index file.

  • electrum_rpc_addr: Electrum will run only on localhost, on port 50001.

Using 127.0.0.1 ensures that only locally running applications and Tor traffic can access our Electrum server.

Create Tor hidden service

We need to create a Tor hidden service to connect our wallets to the Electrum server. Edit the conf file:

Add the following:

Save it then restart tor:

Configure systemd service

Create the service file:

Add the following:

Line 6,7,8 and 9 make sure to replace your_user by your own user. Finally, reload systemd:

Startup

Configure Electrs to automatically start at boot:

Start Electrs:

Electrum will now connect to Bitcoin Core to build its own index of the blockchain.

Monitoring

Check the logs and monitor progress in real time:

Last updated

Was this helpful?