2020-03-29 20:58:28 +02:00
# mempool
## a mempool visualizer and explorer for Bitcoin
2019-08-23 02:51:12 +02:00
2019-07-22 10:46:36 +02:00
![mempool ](https://pbs.twimg.com/media/EAETXWCU4AAv2v-?format=jpg&name=4096x4096 )
2020-03-29 20:58:28 +02:00
![blockchain ](https://pbs.twimg.com/media/EAETXWAU8AAj4IP?format=jpg&name=4096x4096 )
## Pick the right version for your use case
Mempool V1 has basic explorer functionality and can run from a Bitcoin Core full node on a Raspberry Pi (no pruning, txindex=1).
Mempool V2 is what runs on https://mempool.space and has advanced explorer functionality, but requires a fully synced electrs backend running on powerful server hardware.
# Mempool V1 using Docker (easy)
Install from Docker Hub, passing your Bitcoin Core RPC credentials as environment variables:
```bash
docker pull mempool/mempool:v1.0
docker create -p 80:80 -e BITCOIN_NODE_HOST=192.168.1.102 -e BITCOIN_NODE_USER=foo -e BITCOIN_NODE_PASS=bar --name mempool mempool/mempool:v1.0
docker start mempool
docker logs mempool
```
You should see mempool starting up, which takes over an hour (needs 8 blocks). When it's ready, visit http://127.0.0.1/ to see your mempool.
# Mempool V1 not using Docker (advanced)
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
2019-08-23 02:51:12 +02:00
* Bitcoin (full node required, no pruning, txindex=1)
2019-07-22 10:46:36 +02:00
* NodeJS (official stable LTS)
2019-08-23 02:51:12 +02:00
* MySQL or MariaDB (default config)
2019-08-21 22:25:29 +02:00
* Nginx (use supplied nginx.conf)
2019-07-22 10:46:36 +02:00
2020-02-25 18:34:37 +01:00
## Checking out release tag
```bash
git clone https://github.com/mempool-space/mempool.space
cd mempool.space
git checkout v1.0.0 # put latest release tag here
```
2019-09-08 19:37:07 +02:00
## Bitcoin Core (bitcoind)
2019-07-22 10:46:36 +02:00
2019-09-08 19:37:07 +02:00
Enable RPC and txindex in bitcoin.conf
```bash
rpcuser=mempool
rpcpassword=71b61986da5b03a5694d7c7d5165ece5
txindex=1
2019-07-22 10:46:36 +02:00
```
2019-09-08 19:37:07 +02:00
## NodeJS
2019-07-22 10:46:36 +02:00
2019-09-08 19:37:07 +02:00
Install dependencies and build code:
2019-07-22 10:46:36 +02:00
2019-09-08 19:37:07 +02:00
```bash
# Install TypeScript Globally
npm install -g typescript
# Frontend
cd frontend
npm install
npm run build
# Backend
cd ../backend/
npm install
npm run build
2019-08-23 15:35:04 +02:00
```
2019-09-08 19:37:07 +02:00
## Mempool Configuration
In the `backend` folder, make a copy of the sample config and modify it to fit your settings.
```bash
cp mempool-config.sample.json mempool-config.json
2019-07-22 10:46:36 +02:00
```
2019-09-08 19:37:07 +02:00
Edit `mempool-config.json` to add your Bitcoin Core node RPC credentials:
```bash
2019-07-22 10:46:36 +02:00
"BITCOIN_NODE_HOST": "192.168.1.5",
"BITCOIN_NODE_PORT": 8332,
"BITCOIN_NODE_USER": "mempool",
"BITCOIN_NODE_PASS": "71b61986da5b03a5694d7c7d5165ece5",
```
2019-09-08 19:37:07 +02:00
## MySQL
2019-07-22 10:46:36 +02:00
2019-09-08 19:41:28 +02:00
Install MariaDB:
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
2019-09-08 19:37:07 +02:00
MariaDB [(none)]> grant all privileges on mempool.* to 'mempool' identified by '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
From the root folder, initialize database structure:
```bash
mysql -u mempool -p mempool < mariadb-structure.sql
2019-07-22 10:46:36 +02:00
```
2019-09-08 19:37:07 +02:00
## Running (Backend)
2019-07-22 10:46:36 +02:00
Create an initial empty cache and start the app:
2019-09-08 19:37:07 +02:00
```bash
touch cache.json
npm run start # node dist/index.js
2019-07-22 10:46:36 +02:00
```
After starting you should see:
2019-09-08 19:37:07 +02:00
```bash
Server started on port 8999 :)
New block found (#586498)! 0 of 1986 found in mempool. 1985 not found.
New block found (#586499)! 0 of 1094 found in mempool. 1093 not found.
New block found (#586500)! 0 of 2735 found in mempool. 2734 not found.
New block found (#586501)! 0 of 2675 found in mempool. 2674 not found.
New block found (#586502)! 0 of 975 found in mempool. 974 not found.
New block found (#586503)! 0 of 2130 found in mempool. 2129 not found.
New block found (#586504)! 0 of 2770 found in mempool. 2769 not found.
New block found (#586505)! 0 of 2759 found in mempool. 2758 not found.
Updating mempool
Calculated fee for transaction 1 / 3257
Calculated fee for transaction 2 / 3257
Calculated fee for transaction 3 / 3257
Calculated fee for transaction 4 / 3257
Calculated fee for transaction 5 / 3257
Calculated fee for transaction 6 / 3257
Calculated fee for transaction 7 / 3257
Calculated fee for transaction 8 / 3257
Calculated fee for transaction 9 / 3257
```
You need to wait for at least *8 blocks to be mined* , so please wait ~80 minutes.
2019-08-23 02:51:12 +02:00
The backend also needs to index transactions, calculate fees, etc.
When it's ready you will 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
```
## nginx + CertBot (LetsEncrypt)
2019-12-01 03:50:14 +01:00
Setup nginx using the supplied nginx.conf
2019-09-08 19:37:07 +02:00
```bash
2019-12-01 03:50:14 +01:00
# install nginx and certbot
2019-09-08 19:37:07 +02:00
apt-get install -y nginx python-certbot-nginx
2019-12-01 03:50:14 +01:00
# replace example.com with your domain name
certbot --nginx -d example.com
# install the mempool configuration for nginx
2019-09-08 19:37:07 +02:00
cp nginx.conf /etc/nginx/nginx.conf
2019-12-01 03:50:14 +01:00
# edit the installed nginx.conf, and replace all
# instances of example.com with your domain name
2019-07-22 10:46:36 +02:00
```
2019-12-01 03:50:14 +01:00
Make sure you can access https://< your-domain-name > / in browser before proceeding
2019-07-22 10:46:36 +02:00
2019-08-21 22:25:29 +02:00
2019-09-08 19:37:07 +02:00
## Running (Frontend)
2019-08-23 02:51:12 +02:00
2019-08-23 15:04:16 +02:00
Build the frontend static HTML/CSS/JS, rsync the output into nginx folder:
2019-07-22 10:46:36 +02:00
2019-09-08 19:37:07 +02:00
```bash
cd frontend/
npm run build
sudo rsync -av --delete dist/mempool/ /var/www/html/
2019-07-22 10:46:36 +02:00
```
2020-06-22 17:10:49 +02:00
### Optional frontend configuration
In the `frontend` folder, make a copy of the sample config and modify it to fit your settings.
```bash
cp mempool-frontend-config.sample.json mempool-frontend-config.json
```
2019-09-08 19:37:07 +02:00
## Try It Out
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.