2021-01-11 15:07:16 +01:00
# The Mempool Open Source Project
2019-08-23 02:51:12 +02:00
2021-02-11 06:57:43 +01:00
Mempool is the fully featured visualizer, explorer, and API service running on [mempool.space ](https://mempool.space/ ), an open source project developed and operated for the benefit of the Bitcoin community, with a focus on the emerging transaction fee market to help our transition into a multi-layer ecosystem.
2020-03-29 20:58:28 +02:00
2021-01-11 15:07:16 +01:00
![mempool ](https://pbs.twimg.com/media/Ei8p_flUcAEjfXE?format=jpg&name=4096x4096 )
2020-03-29 20:58:28 +02:00
2021-02-11 06:57:43 +01:00
## Installation Methods
Mempool can be self-hosted on a wide variety of your own hardware, ranging from a simple one-click installation on a Raspberry Pi distro, all the way to an advanced high availability cluster of powerful servers for a production instance. We support the following installation methods, ranked in order from simple to advanced:
2021-02-12 08:20:57 +01:00
1) One-click installation on: [Umbrel ](https://github.com/getumbrel/umbrel ), [RaspiBlitz ](https://github.com/rootzoll/raspiblitz ), [RoninDojo ](https://code.samourai.io/ronindojo/RoninDojo ), or [MyNode ](https://github.com/mynodebtc/mynode ).
2021-02-11 06:57:43 +01:00
2) [Docker installation on Linux using docker-compose ](https://github.com/mempool/mempool/tree/master/docker )
3) [Manual installation on Linux or FreeBSD ](https://github.com/mempool/mempool#manual-installation )
4) [Production installation on a powerful FreeBSD server ](https://github.com/mempool/mempool/tree/master/production )
5) [High Availability cluster using powerful FreeBSD servers ](https://github.com/mempool/mempool/tree/master/production#high-availability )
# Manual Installation
The following instructions are for a manual installation on Linux or FreeBSD. The file and directory paths may need to be changed to match your OS.
2019-07-22 10:46:36 +02:00
2019-09-08 19:37:07 +02:00
## Dependencies
2019-07-22 10:46:36 +02:00
2021-01-11 15:07:16 +01:00
* Bitcoin Core (no pruning, txindex=1)
* Electrum Server (romanz/electrs)
2019-07-22 10:46:36 +02:00
* NodeJS (official stable LTS)
2021-01-11 15:07:16 +01:00
* MariaDB (default config)
* Nginx (use supplied nginx.conf and nginx-mempool.conf)
2019-07-22 10:46:36 +02:00
2021-01-11 15:07:16 +01:00
## Mempool
Clone the mempool repo, and checkout the latest release tag:
2020-02-25 18:34:37 +01:00
```bash
2020-10-13 00:51:39 +02:00
git clone https://github.com/mempool/mempool
cd mempool
2020-10-20 04:54:04 +02:00
latestrelease=$(curl -s https://api.github.com/repos/mempool/mempool/releases/latest|grep tag_name|head -1|cut -d '"' -f4)
2020-10-13 00:51:39 +02:00
git checkout $latestrelease
2020-02-25 18:34:37 +01:00
```
2019-09-08 19:37:07 +02:00
## Bitcoin Core (bitcoind)
2019-07-22 10:46:36 +02:00
2021-01-11 15:07:16 +01:00
Enable RPC and txindex in `bitcoin.conf` :
2019-09-08 19:37:07 +02:00
```bash
rpcuser=mempool
rpcpassword=71b61986da5b03a5694d7c7d5165ece5
txindex=1
2019-07-22 10:46:36 +02:00
```
2019-09-08 19:37:07 +02:00
## MySQL
2019-07-22 10:46:36 +02:00
2021-01-11 15:07:16 +01:00
Install MariaDB from OS package manager:
2019-09-08 19:37:07 +02:00
```bash
# Linux
apt-get install mariadb-server mariadb-client
# macOS
brew install mariadb
brew services start mariadb
2019-07-22 10:46:36 +02:00
```
Create database and grant privileges:
2019-09-08 19:37:07 +02:00
```bash
MariaDB [(none)]> drop database mempool;
Query OK, 0 rows affected (0.00 sec)
2019-07-22 10:46:36 +02:00
2019-09-08 19:37:07 +02:00
MariaDB [(none)]> create database mempool;
Query OK, 1 row affected (0.00 sec)
2019-07-22 10:46:36 +02:00
2021-01-12 12:49:18 +01:00
MariaDB [(none)]> grant all privileges on mempool.* to 'mempool'@'%' identified by 'mempool';
2019-09-08 19:37:07 +02:00
Query OK, 0 rows affected (0.00 sec)
2019-07-22 10:46:36 +02:00
```
2021-01-11 15:07:16 +01:00
From the mempool repo's top-level folder, import the database structure:
2019-09-08 19:37:07 +02:00
```bash
mysql -u mempool -p mempool < mariadb-structure.sql
2019-07-22 10:46:36 +02:00
```
2021-01-11 15:07:16 +01:00
## Mempool Backend
Install mempool dependencies from npm and build the backend:
```bash
# backend
cd ../backend/
npm install
npm run build
```
In the `backend` folder, make a copy of the sample config and modify it to fit your settings.
2019-07-22 10:46:36 +02:00
2021-01-11 15:07:16 +01:00
```bash
cp mempool-config.sample.json mempool-config.json
```
2019-09-08 19:37:07 +02:00
2021-01-11 15:07:16 +01:00
Edit `mempool-config.json` to add your Bitcoin Core node RPC credentials:
2019-09-08 19:37:07 +02:00
```bash
2021-01-11 15:07:16 +01:00
{
"MEMPOOL": {
"NETWORK": "mainnet",
"BACKEND": "electrum",
"HTTP_PORT": 8999,
"API_URL_PREFIX": "/api/v1/",
"POLL_RATE_MS": 2000
},
"CORE_RPC": {
"USERNAME": "mempool",
"PASSWORD": "71b61986da5b03a5694d7c7d5165ece5"
},
"ELECTRUM": {
"HOST": "127.0.0.1",
"PORT": 50002,
"TLS_ENABLED": true,
},
"DATABASE": {
"ENABLED": true,
2021-01-30 12:43:58 +01:00
"HOST": "127.0.0.1",
2021-01-11 15:07:16 +01:00
"PORT": 3306,
"USERNAME": "mempool",
"PASSWORD": "mempool",
"DATABASE": "mempool"
},
"STATISTICS": {
"ENABLED": true,
"TX_PER_SECOND_SAMPLE_PERIOD": 150
}
}
2019-07-22 10:46:36 +02:00
```
2021-01-11 15:07:16 +01:00
Start the backend:
2019-07-22 10:46:36 +02:00
2019-09-08 19:37:07 +02:00
```bash
2021-01-11 15:07:16 +01:00
npm run start
2019-09-08 19:37:07 +02:00
```
2021-01-11 15:07:16 +01:00
When it's running you should see output like this:
2019-07-22 10:46:36 +02:00
2019-09-08 19:37:07 +02:00
```bash
Mempool updated in 0.189 seconds
Updating mempool
Mempool updated in 0.096 seconds
Updating mempool
Mempool updated in 0.099 seconds
Updating mempool
Calculated fee for transaction 1 / 10
Calculated fee for transaction 2 / 10
Calculated fee for transaction 3 / 10
Calculated fee for transaction 4 / 10
Calculated fee for transaction 5 / 10
Calculated fee for transaction 6 / 10
Calculated fee for transaction 7 / 10
Calculated fee for transaction 8 / 10
Calculated fee for transaction 9 / 10
Calculated fee for transaction 10 / 10
Mempool updated in 0.243 seconds
Updating mempool
```
2021-01-11 15:07:16 +01:00
## Mempool Frontend
2019-12-01 03:50:14 +01:00
2021-01-11 15:07:16 +01:00
Install mempool dependencies from npm and build the frontend static HTML/CSS/JS:
2019-12-01 03:50:14 +01:00
2021-01-11 15:07:16 +01:00
```bash
# frontend
cd frontend
npm install
npm run build
2019-07-22 10:46:36 +02:00
```
2019-08-23 02:51:12 +02:00
2021-01-11 15:07:16 +01:00
Install the output into nginx webroot folder:
2019-07-22 10:46:36 +02:00
2019-09-08 19:37:07 +02:00
```bash
sudo rsync -av --delete dist/mempool/ /var/www/html/
2019-07-22 10:46:36 +02:00
```
2021-01-11 15:07:16 +01:00
## nginx + certbot
Install the supplied nginx.conf and nginx-mempool.conf in /etc/nginx
2020-06-22 17:10:49 +02:00
```bash
2021-01-11 15:07:16 +01:00
# install nginx and certbot
apt-get install -y nginx python-certbot-nginx
# install the mempool configuration for nginx
cp nginx.conf nginx-mempool.conf /etc/nginx/nginx.conf
2020-06-22 17:10:49 +02:00
2021-01-11 15:07:16 +01:00
# replace example.com with your domain name
certbot --nginx -d example.com
```
2019-08-23 02:51:12 +02:00
If everything went okay you should see the beautiful mempool :grin:
2019-07-22 10:46:36 +02:00
2019-08-23 02:51:12 +02:00
If you get stuck on "loading blocks", this means the websocket can't connect.
Check your nginx proxy setup, firewalls, etc. and open an issue if you need help.