Setting up the faucet
The faucet is the application used to create new accounts on the blockchain

Installation

It is recommended to use Ubuntu 18.04 to run the faucet.

Clone the Repository

1
git clone https://gitlab.com/PBSA/PeerplaysIO/tools-libs/faucet.git -b develop
Copied!

Install the dependencies

1
sudo apt update
2
sudo apt-get install libffi-dev libssl-dev python-dev python3-pip redis-server
Copied!
It is best practice to use python virtual environments. https://docs.python.org/3/tutorial/venv.html
1
sudo apt-get install python3-venv
2
cd faucet
3
python3 -m venv env
4
source env/bin/activate
Copied!
1
pip3 install -r requirements.txt
Copied!

Edit the configuration

1
cp config-example.yml config.yml
Copied!
Change the config.yml for Beatrice and your node:
1
secret_key: "RANDOM-STRING" # Random keys
2
nobroadcast: True # Safety mode
3
4
mail_host: "SERVER:589"
5
mail_user: "user"
6
mail_pass: "password"
7
mail_from: "[email protected]"
8
9
admins:
12
13
minIPAge: 300 # How long in secs does an IP need to wait to register a new account?
14
witness_url: "<your node endpoint>"
15
16
registrar: "<registrar account name>"
17
default_referrer: "<referrer account name>"
18
referrer_percent: 50 # in percent
19
wif: "<WIF for your account>"
20
21
balance_mailthreshold: 500 # if balances goes below this, you will be notified
22
core_asset: "TEST"
Copied!

Apply the changes

1
python3 manage.py install
Copied!

Usage

1
python work.py # for starting the worker
2
3
python manage.py run # for normal mode
4
5
python manage.py start # for debug mode
Copied!
The faucet will then be available at http://localhost:5000

Testing

Once the faucet is running, tests can be run.
1
python3 test_faucet.py
Copied!

Production Configuration

NGINX

Run uwsgi
1
uwsgi --ini wsgi.ini
Copied!
and use a configuration similar to this:
1
user peerplays;
2
worker_processes 4;
3
4
events {
5
worker_connections 2048;
6
}
7
8
http {
9
include mime.types;
10
default_type application/octet-stream;
11
access_log /www/logs/access.log;
12
error_log /www/logs/error.log;
13
log_not_found off;
14
sendfile on;
15
keepalive_timeout 65;
16
gzip on;
17
18
upstream websockets {
19
server localhost:9090;
20
server localhost:9091;
21
}
22
23
server {
24
listen 80;
25
if ($scheme != "https") {
26
return 301 https://$host$request_uri;
27
}
28
29
listen 443 ssl;
30
server_name peerplays-wallet.com;
31
ssl_certificate /etc/nginx/ssl/peerplays-wallet.com.crt;
32
ssl_certificate_key /etc/nginx/ssl/peerplays-wallet.com.key;
33
ssl_session_cache shared:SSL:1m;
34
ssl_session_timeout 5m;
35
ssl_ciphers HIGH:!aNULL:!MD5;
36
ssl_prefer_server_ciphers on;
37
38
location ~ /ws/? {
39
access_log on;
40
proxy_pass http://websockets;
41
proxy_set_header X-Real-IP $remote_addr;
42
proxy_set_header Host $host;
43
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
44
proxy_http_version 1.1;
45
proxy_set_header Upgrade $http_upgrade;
46
proxy_set_header Connection "upgrade";
47
proxy_next_upstream error timeout invalid_header http_500;
48
proxy_connect_timeout 2;
49
}
50
location ~ ^/[\w\d\.-]+\.(js|css|dat|png|json)$ {
51
root /www/wallet;
52
try_files $uri /wallet$uri =404;
53
}
54
location / {
55
root /www/wallet;
56
}
57
location /api {
58
include uwsgi_params;
59
uwsgi_pass unix:/tmp/faucet.sock;
60
}
61
62
}
63
}
Copied!
Last modified 1yr ago