Documentation menu

Hosting guide

Qirsh is one Node.js process and one SQLite file. This guide puts it on a Linux server behind HTTPS, with backups, upgrades and monitoring. Every environment variable is listed in Configuration.

Requirements

Configure

git clone https://github.com/AQaddora/qirsh
cd qirsh
cp .env.example .env
openssl rand -base64 18      # a password for ADMIN_PASSWORD

Set at least:

ADMIN_EMAIL=you@example.com
ADMIN_PASSWORD=<generated>
PUBLIC_URL=https://pay.example.com
TRUST_PROXY=true
TRONGRID_API_KEY=<your key>
NETWORK=nile

PUBLIC_URL is used to build every checkout_url, and an https:// value also makes the session cookie Secure. TRUST_PROXY=true makes rate limiting see the real client IP from X-Forwarded-For. Set it only when the gateway is reachable through your proxy and nowhere else.

Start on nile. Move a store to mainnet after the checks in Testing pass.

Run with Docker

docker compose up -d --build
docker compose logs -f qirsh
curl -s http://127.0.0.1:8080/health

What the bundled docker-compose.yml does:

The admin CLI runs inside the container:

docker compose exec qirsh node dist/cli.js list-users

Run with Node and systemd

Create a user and install the app:

sudo useradd --system --create-home --home-dir /opt/qirsh --shell /usr/sbin/nologin qirsh
sudo -u qirsh git clone https://github.com/AQaddora/qirsh /opt/qirsh/app
cd /opt/qirsh/app
sudo -u qirsh npm ci
sudo -u qirsh npm run build
sudo -u qirsh npm prune --omit=dev
sudo install -d -o qirsh -g qirsh -m 700 /var/lib/qirsh
sudo install -o root -g qirsh -m 640 .env.example /etc/qirsh.env

Edit /etc/qirsh.env as in Configure, plus:

DATABASE_PATH=/var/lib/qirsh/qirsh.db
HOST=127.0.0.1
PORT=8080

better-sqlite3 downloads a prebuilt binary during npm ci. If none exists for your platform it compiles one, which needs python3, make and g++.

Create /etc/systemd/system/qirsh.service:

[Unit]
Description=Qirsh USDT payment gateway
After=network-online.target
Wants=network-online.target

[Service]
User=qirsh
Group=qirsh
WorkingDirectory=/opt/qirsh/app
EnvironmentFile=/etc/qirsh.env
ExecStart=/usr/bin/node dist/index.js
Restart=on-failure
RestartSec=5

NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true
PrivateDevices=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
RestrictSUIDSGID=true
LockPersonality=true
ReadWritePaths=/var/lib/qirsh

[Install]
WantedBy=multi-user.target

ProtectHome=true hides /home, which is fine because the app lives in /opt. If you use forwarder mode with FEE_PAYER_PRIVATE_KEY_FILE, keep the key file outside the app directory, readable only by qirsh (for example /etc/qirsh/fee_payer.key, mode 600).

sudo systemctl daemon-reload
sudo systemctl enable --now qirsh
journalctl -u qirsh -f

The admin CLI needs the same environment:

cd /opt/qirsh/app
sudo -u qirsh node --env-file=/etc/qirsh.env dist/cli.js list-users

HTTPS with nginx and certbot

/etc/nginx/sites-available/qirsh:

server {
    listen 80;
    server_name pay.example.com;

    client_max_body_size 128k;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 30s;
    }
}
sudo ln -s /etc/nginx/sites-available/qirsh /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d pay.example.com

certbot adds the TLS listener and the redirect from HTTP, and renews the certificate automatically. The gateway's request body limit is 64 KB, so client_max_body_size 128k is plenty.

Caddy instead of nginx

Caddy gets and renews certificates by itself:

pay.example.com {
    reverse_proxy 127.0.0.1:8080
}

Backups

The database holds projects, users, API key hashes, webhook secrets, invoices, transfers, webhook logs and the activity log. The money is on-chain and does not depend on it, but losing it means losing your records and every project's configuration.

The database runs in WAL mode, so copy it with SQLite's backup API, not with cp.

Node install, with the sqlite3 command line tool:

sqlite3 /var/lib/qirsh/qirsh.db ".backup '/var/backups/qirsh/qirsh-$(date +%F).db'"

Docker (the image has no sqlite3, so use the bundled driver):

docker compose exec qirsh node -e \
  "require('better-sqlite3')('/data/qirsh.db').backup('/data/backup.db').then(()=>console.log('ok'))"
docker compose cp qirsh:/data/backup.db ./backups/qirsh-$(date +%F).db

Run it daily from cron, for example:

15 3 * * * sqlite3 /var/lib/qirsh/qirsh.db ".backup '/var/backups/qirsh/qirsh-$(date +\%F).db'" && find /var/backups/qirsh -name '*.db' -mtime +30 -delete

Backups contain webhook secrets and, in single-store mode, nothing else secret (API keys are hashed). Store them encrypted, and never in the same place as a fee-payer key file.

To restore: stop the gateway, put the backup file at DATABASE_PATH (and delete any -wal and -shm files next to it), start the gateway. Test a restore on another machine now and then. A backup you have never restored is a guess.

If the database is lost

npm run admin -- recover-forwarder --network mainnet --factory T... --destination <project wallet> \
  --invoices-file invoice-ids.txt          # add --send to flush

Addresses created with a network fee also need the fee terms: add --collector T... --fee 1.5 with the project's fee, or rely on the defaults (FEE_COLLECTOR_ADDRESS and SWEEP_FEE_DEFAULT). Use --fee 0 for addresses without a fee. A wrong guess derives a different, empty address and sends nothing. See Network fees.

Invoice ids are in your stores' orders, webhook logs and checkout URLs. See the contracts README for a manual flush on Tronscan.

Upgrades

  1. Read CHANGELOG.md for the versions you are skipping.
  2. Back up the database.
  3. Update and restart.

Docker:

git pull
docker compose up -d --build

Node:

cd /opt/qirsh/app
sudo -u qirsh git pull
sudo -u qirsh npm ci && sudo -u qirsh npm run build && sudo -u qirsh npm prune --omit=dev
sudo systemctl restart qirsh

Database migrations run automatically at start. They only move forward, so to roll back, check out the previous version and restore the backup you took in step 2. Invoices created in between are lost from the database (not on-chain), so roll back quickly or not at all.

If you use forwarder mode and upgrade from a version without network fees, deploy a v2 factory afterwards (deploy-factory --network <n> --force) and set the new FORWARDER_FACTORY_<NETWORK>. See the operator guide.

Monitoring

GET /health is public:

{
  "ok": true,
  "watcher": { "ok": true, "last_poll_at": "2026-12-05T18:00:10.000Z", "last_error": null, "catching_up": false, "deposits_unreconciled": 0 },
  "sweeper": { "enabled": true, "ok": true, "queued": 0, "in_flight": 0, "failed": 0, "held": 1 }
}

Also watch the dashboard for unmatched transfers and failed webhooks. Logs are JSON lines (pino) on stdout, with the level set by LOG_LEVEL.

A static project website

The landing page and docs can also be published without a running gateway, for example on Cloudflare Pages or GitHub Pages:

SITE_URL=https://example.org SIGN_IN_URL=https://pay.example.org/admin npm run site:export

This writes dist-site/ with index.html, docs/*.html, the assets and a _headers file with the same security headers the gateway sends. Links to the legal pages point at the templates in the repository, because those pages belong to whoever runs an instance. Set LEGAL_PAGES=true to export them filled from the usual OPERATOR_* variables instead.

Scaling

Run one instance per database. The watcher, the webhook outbox and the sweeper assume a single writer, and SQLite is a single file. If you need separate mainnet and testnet environments, run two instances with two databases (and, in forwarder mode, two fee keys).

Security checklist

SECURITY.md has the full operator checklist. The short version: HTTPS only, the port bound to localhost, ALLOW_SIMULATION=false and no simulation on mainnet projects, TRUST_PROXY=true only behind your own proxy, daily backups, and in forwarder mode a dedicated fee key per network with a small balance.

Edit this page on GitHub