Documentation menu

Operator guide

This guide covers running a gateway day to day: the admin console, projects and their wallets, users, keys, password confirmations, the activity log, forwarder mode, network fees and the admin CLI. It assumes the gateway is installed (see Hosting).

First sign-in

Open https://pay.example.com/admin and sign in with ADMIN_EMAIL and ADMIN_PASSWORD. That account is created on the first start if no admin exists. Changing the variables later does not change an existing account. Without them, create an admin from the server:

npm run admin -- create-admin [email protected] "Your Name"

It prints a generated password. Change it from the user menu (top right, Change password).

The top bar has a project switcher, the network of the selected project, its wallet, a + New invoice button and, for admins, the Admin button that opens the admin console.

Project dashboard

Projects

A project is one store. Create one per store, and a separate one per network: a store's Nile test project and its mainnet project are two projects with two sets of keys.

Admin console: projects

Create a project

Admin → Projects → + New project:

Field Notes
Project name Shown on the checkout. 1 to 80 characters
Network Mainnet (real USDT), Nile testnet or Shasta testnet
Status Active or Disabled
Wallet that receives payments Generate a new wallet (the default) or Use an existing address. See below
Webhook URL Optional, can be set later by the project's users
Allow simulated payments Testnets only. Lets the store call simulate-payment and shows Simulate paid in the dashboard
Project user: email and name Optional. Creates a member account for the store owner, or adds an existing account to the project

After saving (and, with a generated wallet, after the wallet steps below), the gateway shows three secrets once: the project's first API key (labelled Initial key), its webhook secret, and the new user's password if one was created. Hand them to the store owner over a private channel. The API key cannot be shown again; the webhook secret can be revealed later in the project's settings.

Two active projects cannot share a wallet on the same network (409 wallet_in_use). A project's wallet cannot be the operator's fee collector (409 wallet_is_fee_collector).

Choose the wallet

The wallet is where the store's money goes. Qirsh only ever stores its public address. Never ask a store owner for a private key or recovery phrase, and never send one to the gateway.

Use an existing address is the right choice for a store that already has a wallet, and for any wallet that will hold large amounts. Create the wallet in TronLink (ideally on a hardware wallet such as a Ledger connected to TronLink), copy its address and paste it. The dashboard checks the address checksum before it saves. Never use an exchange deposit address: exchanges may credit deposits late or not at all, and some do not credit transfers sent by a contract, which is how forwarder sweeps arrive.

Generate a new wallet creates one for the store in your browser:

  1. Choose Generate a new wallet, fill in the rest of the form and press Save. A dialog shows a 12-word recovery phrase, the private key (hidden until you press Show) and the address. They are generated in your browser with crypto.getRandomValues. The server never sees, stores or logs the phrase or the key.
  2. Write the 12 words down on paper, in order. Download as text file saves the phrase, key and address as a file built in your browser; nothing goes over the network. If you copy the phrase or the key, clear your clipboard afterwards.
  3. Tick I wrote down the recovery phrase and stored it offline and press I've written it down.
  4. Type back the 3 words the dialog asks for (for example word #3, #7 and #11). This proves you have a correct copy. Back shows the words again.
  5. Press Confirm and use this wallet. The dialog closes, the phrase and key are removed from the page, and only the address is sent with the new project. If saving the project then fails (for example the name is missing), fix the form and save again: the same address is reused.

Generating a wallet in the browser

Read the warnings on that screen. Anyone with the 12 words or the private key controls every coin sent to the wallet. They are shown once: Qirsh cannot show them again or recover them. Keep them offline, not in email, chat, cloud notes or screenshots, and hand them to the store owner in person or over a channel you trust. Cancelling at any step saves nothing.

To use the wallet, import the phrase into TronLink (or Trust Wallet, or any TRON wallet that uses the standard path m/44'/195'/0'/0/0) with Import wallet, or import the private key. The wallet app shows the same address.

A generated wallet is a convenience, not cold storage. The code that generates it is served by the gateway, so someone who controls the server or your browser could tamper with it. Treat it as a hot wallet, move funds out of it regularly, and for large amounts create the wallet in TronLink or on a hardware wallet and choose Use an existing address. SECURITY.md has the details.

Edit a project

Admin → Projects → Edit, or the Edit button on the project's Wallet card in Settings (admins only), changes the name, network, status and simulation flag. Members can change the name, brand colour, invoice lifetime and webhook URL. The single-store project from .env keeps its wallet, network, simulation flag, webhook URL and deposit mode in the environment, so those fields are locked in the dashboard.

Changing the network or disabling the project asks for your password (see Password confirmation). Disabling a project stops new invoices (403 project_disabled). Existing invoices are still watched and settled.

Change a project's wallet

Admins only: the Wallet card in the project's Settings → Change wallet… (also in the project's edit dialog).

  1. Choose Generate a new wallet (the same steps as above: write down the 12 words, type 3 of them back) or paste an existing address.
  2. Review the current and the new wallet side by side.
  3. Type the last 4 characters of the new address. A pasted or swapped address is caught here.
  4. Press Change wallet and confirm your password if asked.

Changing a project's wallet

New invoices pay the new wallet from that moment. Invoices created before the change are not moved:

So keep access to the old wallet. The change is recorded in the activity log with the old and new address. The single-store project's wallet is MERCHANT_ADDRESS in the environment (409 env_managed from the dashboard).

Project settings

Users

Admin → Users.

+ New user takes an email, a name, a role and the projects. The gateway generates the password and shows it once. Edit changes the name, role, projects or disables the account; a disabled user cannot sign in and their sessions end. Reset password generates a new password and signs the user out everywhere. Changing a role, disabling a user and resetting a password ask for your own password first. You cannot demote or disable yourself, and the last active admin cannot be removed.

From the server:

npm run admin -- list-users
npm run admin -- reset-password [email protected]

API keys

Project → Settings → API keys. + New key creates a key with an optional label (for example "Production server") and shows it once. The table shows the label and when each key was last used. Revoke stops a key immediately.

To rotate a key without downtime:

  1. Create a new key.
  2. Deploy it to the store's backend.
  3. Check Last used on the new key, then revoke the old one.

Revoking a project's last active key takes the store offline, so it asks for your password.

For the single-store project the key is API_SECRET_KEY: change it in .env and restart.

Webhook secret

Project → Settings → Webhook: set the endpoint URL, Reveal or Copy the signing secret, Rotate it (this asks for your password), and Send test event (a signed ping). Rotating takes effect at once, including for queued retries, so update the store at the same time. For the single-store project the secret is WEBHOOK_SECRET.

Webhook URLs set in the dashboard cannot point at localhost or private networks unless ALLOW_PRIVATE_WEBHOOKS=true.

Team

Project → Settings → Team lists the people who can see the project. Add or remove people from Admin → Users.

Password confirmation

Actions that can redirect money or lock people out ask for your password again:

A Confirm it's you dialog appears. After the right password you are not asked again for 5 minutes, in that browser session only. Signing out, the session expiring or a password change ends the window. Sign-in protections are unchanged; the confirmation is an extra step for someone who finds an open dashboard. A wrong password is recorded in the activity log.

Password confirmation

Scripts that call the dashboard API get 403 reauth_required and must call POST /dashboard/api/me/reauth first (see the API reference).

Activity log

Admin → Activity lists who changed what, newest first: the time, the user and their IP address, the project, the action, and the old and new values.

Admin activity log

It records:

Members see their own project's entries, without IP addresses, under the project's Settings. After any incident, check this log first, and watch for Wrong password on a confirmation entries you cannot explain. The log never holds secrets. Entries stay in the database until you delete them; they are included in database backups.

Day-to-day work in a project

Invoices

Filter by status (All, Pending, Confirming, Paid, Expired), open an invoice's checkout, and Export CSV for accounting (the same as GET /api/v1/exports/invoices.csv). + New invoice creates one by hand, which is handy for a phone order or a test. On testnet projects with simulation, Simulate paid settles a pending invoice and sends a real signed invoice.paid webhook.

In forwarder projects the list has a Sweep column and per-invoice actions: Accept (settle with what the address received), Sweep now, and for admins Recover… (move TRX or another TRC-20 token sent to the address by mistake).

Forwarder invoices with sweep status

Transfers

Every incoming transfer seen on the project's wallet. Unmatched transfers fit no invoice: a customer sent a rounded amount, paid late, or paid twice. Assign… settles an invoice with that transfer: the invoice becomes paid with settled_manually: true and the real amount_paid, and an invoice.paid webhook goes out. Underpaid or out-of-window transfers ask for confirmation first. If the transfer belongs to no order, refund it from the wallet.

Webhooks

Each event with its status, attempts and the last result (HTTP status or error). Failed deliveries retry on their own for about two days; Retry now re-queues an event that has not been delivered. Send test event checks the endpoint and the store's signature code.

Forwarder mode setup

Forwarder mode gives every invoice its own deposit address and a round amount. Read Concepts and SECURITY.md first, and do everything on Nile before mainnet. Commands are npm run admin -- <command> on a Node install (after npm run build), or docker compose exec qirsh node dist/cli.js <command> in Docker.

1. Create the fee wallet

npm run admin -- fee-wallet new

This prints a new address and its private key once. Nothing is stored. Put the key in a file that only the gateway can read and point FEE_PAYER_PRIVATE_KEY_FILE at it.

Node install:

sudo install -d -o root -g qirsh -m 750 /etc/qirsh
sudo install -o qirsh -g qirsh -m 600 /dev/null /etc/qirsh/fee_payer_nile.key
sudoedit /etc/qirsh/fee_payer_nile.key     # paste the 64 hex characters
echo 'FEE_PAYER_PRIVATE_KEY_FILE=/etc/qirsh/fee_payer_nile.key' | sudo tee -a /etc/qirsh.env

Docker, with a docker-compose.override.yml next to docker-compose.yml:

services:
  qirsh:
    environment:
      FEE_PAYER_PRIVATE_KEY_FILE: /run/secrets/qirsh_fee_payer
    secrets: [qirsh_fee_payer]
secrets:
  qirsh_fee_payer:
    file: ./secrets/fee_payer.key
mkdir -p secrets && chmod 700 secrets
# paste the key into secrets/fee_payer.key, then:
chown 1000 secrets/fee_payer.key && chmod 600 secrets/fee_payer.key

The container runs as uid 1000. Keep secrets/ out of git and out of shared backups.

Rules for this wallet: a new key used for nothing else, never a merchant wallet's key (the gateway refuses a project whose wallet is the fee payer), a small TRX float only, and one key per network.

One instance can serve several networks with a separate key for each. Put each key in its own file and set FEE_PAYER_PRIVATE_KEY_FILE_MAINNET, FEE_PAYER_PRIVATE_KEY_FILE_NILE or FEE_PAYER_PRIVATE_KEY_FILE_SHASTA. A per-network file overrides the general FEE_PAYER_PRIVATE_KEY_FILE for that network:

FEE_PAYER_PRIVATE_KEY_FILE_MAINNET=/etc/qirsh/fee_payer_mainnet.key
FEE_PAYER_PRIVATE_KEY_FILE_NILE=/etc/qirsh/fee_payer_nile.key

2. Fund it

On Nile, get test TRX from the faucet at https://nileex.io/join/getJoinPage. Restart the gateway, then check:

npm run admin -- fee-wallet

It prints the address and, per network, the level (ok, low or empty), the TRX balance and the available energy. low means below FEE_WALLET_MIN_TRX.

3. Deploy or verify the factory

npm run admin -- deploy-factory --network nile

The fee wallet pays for the deployment (about 100 TRX of energy on mainnet; faucet TRX on Nile). The command checks the transaction before signing, waits until it is final, verifies the code on-chain and prints a line like FORWARDER_FACTORY_NILE=T.... Add it to the environment and restart. --fee-limit-trx (default 500) caps the deployment fee, and --force deploys another factory when one is already configured.

If you already have a factory address, verify it instead:

npm run admin -- verify-factory --network nile T...

Verification compares the on-chain code with contracts/artifacts/forwarders.json, checks the immutables and the CREATE2 prefix, compares on-chain and local address derivation, and dry-runs deploy() and flushTRX() without sending anything. The server repeats it at start and only derives addresses from a verified factory.

4. Switch the project

Project → Settings → How customers pay → Address per invoice. Only admins can change it. The card runs these checks, and Save works only when all pass:

Check Passes when
Fee payer A fee key is configured
Factory configured FORWARDER_FACTORY_<NETWORK> is set for the project's network
Factory verified The on-chain code matches the committed contracts
Fee wallet The fee wallet exists and is not empty on that network
Project wallet The wallet is not the token contract, the fee wallet, the factory or a deposit address, and on-chain derivation matches
Token The token contract can be read
Fee collector No collector is set (no fees), or the collector is a separate wallet and not the fee wallet, a contract of this gateway or a deposit address. Shows the fee each invoice will pay

A failed save answers 409 forwarder_requirements with the failing checks. For the single-store project, set DEPOSIT_MODE=forwarder instead.

Deposit mode card

5. Set the network fee (optional)

If you want projects to pay for their sweeps in USDT, set FEE_COLLECTOR_ADDRESS (or FEE_COLLECTOR_ADDRESS_<NETWORK>) to a wallet you control whose key is not on the server, and optionally SWEEP_FEE_DEFAULT. Restart. Then, per project, open Settings → How customers pay → Network fee: enter the fee per invoice (empty follows the default, 0 turns it off), choose who pays it (The store, deducted from the payout, or The customer, added to the amount), and press Save fee. Only admins can change it; members see it read-only. Changes apply to new invoices only, and each change is in the activity log.

Tell the store owner the fee and who pays it before you set it, and say so in your terms. Network fees explains the rules: the fee is bound into each deposit address, charged once per invoice, never taken from a balance that does not exceed it, and the smallest merchant-paid invoice is SWEEP_MIN_AMOUNT plus the fee.

6. Test on Nile

Go through the forwarder checks in Testing, including a partial payment, a late payment, an overpayment and the "dust before deploy" check. Note the real sweep costs in the Fee wallet tab; the cost table in the README is an estimate.

7. Go to mainnet

  1. Create a new fee key for mainnet with fee-wallet new. Never reuse the Nile key.
  2. Fund it with a few days of sweep fees, for example 100 to 300 TRX.
  3. Deploy or verify a mainnet factory, add FORWARDER_FACTORY_MAINNET, restart.
  4. Create a separate mainnet project for the store, with new API keys and webhook secret.
  5. Switch it to Address per invoice, start with small invoices, and watch the fee wallet for the first days.

Keep mainnet and testnets on separate instances, or at least give each network its own key with FEE_PAYER_PRIVATE_KEY_FILE_<NETWORK>. One key with factories on mainnet and a testnet makes the server log a warning: TRON transactions carry no chain id, so a malicious testnet node could get the key to sign transactions that are valid on mainnet and burn its TRX.

Upgrading from forwarder contracts v1

Network fees need version 2 of the forwarder contracts. A v1 factory fails verification after the upgrade, and its projects answer 503 forwarder_unavailable to new invoices until you deploy a v2 factory:

npm run admin -- deploy-factory --network nile --force

Set the printed FORWARDER_FACTORY_<NETWORK> line and restart. Projects that used the v1 factory move to the new one once it verifies. Old invoices keep forwarder.version: 1: payments to them are still detected and settled, but the gateway does not sweep them (409 legacy_forwarder). Flush them by hand as described in the contracts README.

Fee wallet tab

Admin → Fee wallet shows the fee wallet's address, balance, energy and level per network, the factory, sweep counts and the average TRX per sweep (last 20 confirmed sweeps). Top it up before it reaches low. With an empty fee wallet, payments are still detected and settled and the funds wait safely at their addresses; only sweeps stop.

The same tab is where you check whether fees cover gas:

Admin CLI

Run it where the server runs, with the same environment. It talks to the database directly.

Command What it does
create-admin <email> [name] Creates an admin and prints a generated password
reset-password <email> Prints a new password and signs the user out everywhere
list-users Lists users, roles and projects
fee-wallet new Generates a fee-payer key and address. Prints them once, stores nothing, needs no configuration
fee-wallet Fee wallet address and per-network level, TRX balance and energy
deploy-factory --network <n> [--fee-limit-trx 500] [--force] Deploys and verifies a factory, prints the FORWARDER_FACTORY_<NETWORK> line. --force deploys another one when a factory is already configured, for example a v2 factory after upgrading from v1
verify-factory --network <n> [address] Verifies a factory on-chain and registers it
sweep <invoice> [--trx | --token <T...>] [--force] Sweeps one invoice's address now and waits for the result. Ignores the daily budget. --force sweeps below SWEEP_MIN_AMOUNT, and a balance that does not exceed the network fee
forwarders [--project <id>] [--unswept] CSV of deposit addresses with amounts, sweep status and fee terms (collector, fee_token, fee_units)
recover-forwarder --network <n> --factory <T...> --destination <T...> (--invoice <id> | --invoices-file <path>) [--collector <T...>] [--fee <amount>] [--trx | --token <T...>] [--send] Recomputes deposit addresses from invoice ids and shows their balances; --send flushes them. Works without the database. The fee terms are part of the address: --collector and --fee default to FEE_COLLECTOR_ADDRESS and SWEEP_FEE_DEFAULT; pass --fee 0 for addresses without a fee
Install How to run
Node npm run admin -- <command> (reads .env; run npm run build first)
Node, development npm run admin:dev -- <command>
Docker docker compose exec qirsh node dist/cli.js <command>

Running a hosted instance for other merchants

If you run one gateway for many stores, as a service:

Edit this page on GitHub