TRON · TRC-20 Self-hosted · MIT Open source from Palestine

Accept USDT on TRON. Keep your keys.

Qirsh is a self-hosted payment gateway for USDT. Your backend creates an invoice, the customer pays on a hosted checkout, and a signed webhook tells your store the order is paid. The money lands in your own wallet. The server never holds that wallet's keys.

  • No keys in the default mode
  • Paid only when final on-chain
  • One container, one SQLite file
Hosted checkout: the exact amount with highlighted digits, a QR code, the TRON address and live payment status

How it works

Three steps between a cart and a paid order

Your store never talks to the blockchain. It calls one endpoint and handles one webhook. Qirsh watches TRON and does the rest.

  1. 1

    Create an invoice

    Your backend posts the order total and your order id. Retries with the same order id return the same invoice.

    POST /api/v1/invoices
    { "amount": "49.90",
      "order_id": "ORDER-1001" }
  2. 2

    The customer pays

    Redirect to the hosted checkout. It shows a QR code, the exact amount, a countdown, live status and a Pay with TronLink button, in English or Arabic.

    303 See Other
    Location: /pay/inv_Luonp2…
  3. 3

    Fulfil on the webhook

    When the transfer is final, your store gets a signed invoice.paid event. Failed deliveries are retried for about two days.

    Qirsh-Signature: t=…,v1=…
    { "type": "invoice.paid", … }

Two deposit modes

Pick how payments are matched, per store

Both modes use the same API and the same webhooks. Your store code does not change when an admin switches a project from one to the other.

Unique amount

No keys
49.907423USDTto your wallet

Each open invoice asks for a slightly different amount, so a transfer to your one address can be matched to its order.

  • No keys on the server at all
  • No fees beyond the customer's own transfer
  • Set up with just a wallet address
  • The customer must send the exact amount

Address per invoice

Default when set up
49.90USDTto a one-time address

Each invoice gets its own deposit address. After payment, a small contract sweeps the funds to your wallet, the only place they can go.

  • Round amounts, friendly to exchange withdrawals
  • Partial payments can be topped up
  • Funds stay recoverable even without the gateway
  • About 11 to 13 TRX per sweep, paid by a fee wallet

New projects use an address per invoice when the server has a fee wallet and a factory for their network, and unique amounts otherwise. Compare the modes in detail.

Security model

Built so a compromised server cannot take the money

The worst case in the default mode is a server that reports wrong statuses. Your store still fulfils only on signed webhooks and can check every transaction on Tronscan. Read the concepts or the threat model.

Your keys stay with you

The server never holds a merchant wallet's keys. In unique-amount mode it holds no keys at all and only watches your address.

Destination in the address

In forwarder mode your wallet is hashed into each deposit address. The fee key can pay for sweeps but cannot send funds anywhere else.

Final before paid

Only transfers of the right token, to the right address, inside the invoice window and solidified on-chain settle an invoice.

Checked before signing

Every sweep transaction is rebuilt locally and compared byte for byte with what the node returned. Nothing else is ever signed.

Isolated projects

API keys belong to one project and are stored hashed. Every query is filtered by project, and only admins can change a wallet.

Locked-down web layer

Strict CSP with no inline scripts, HttpOnly SameSite cookies, CSRF headers, rate limits and an SSRF guard on webhook URLs.

Multi-project hosting

One gateway, many stores

Run a single instance for all your shops, or host one for clients. Each project is a store with its own settings and its own people.

  • A wallet and network (mainnet or testnet) per project
  • API keys, webhook endpoint and signing secret per project
  • The store's own name and colour on its checkout
  • Project users who see only their own payments
  • Revenue stats, CSV export and manual reconciliation
Project dashboard with revenue stats and a list of invoices
The project dashboard: stats, invoices, transfers, webhooks and settings.
# 1. Your backend creates the invoice (price from your database)
curl https://qirsh.online/api/v1/invoices \
  -H "Authorization: Bearer $QIRSH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount":"49.90","order_id":"ORDER-1001",
       "success_url":"https://shop.example/orders/1001"}'

# 2. Redirect the customer to checkout_url from the response
{ "id": "inv_Luonp2fQ0b8rR1cS9yZ5w08", "status": "pending",
  "amount_due": "49.907423",
  "checkout_url": "https://qirsh.online/pay/inv_Luonp2fQ0b8rR1cS9yZ5w08" }
import { constructWebhookEvent, coversOrderTotal } from "qirsh-sdk";

app.post("/webhooks/qirsh", express.raw({ type: "application/json" }), async (req, res) => {
  // Verify the signature on the raw body. Throws if it is forged or older than 5 minutes.
  const event = constructWebhookEvent(req.body, req.headers["qirsh-signature"], process.env.QIRSH_WEBHOOK_SECRET);
  const inv = event.data.invoice;
  const order = await db.orders.find(inv.order_id);
  if (event.type === "invoice.paid" && coversOrderTotal(inv, order.total)) {
    await db.orders.markPaidOnce(order.id, inv.tx_id); // idempotent: webhooks can repeat
  }
  res.sendStatus(200);
});
// webhook.php: verify on the raw body, then fulfil once
$raw = file_get_contents('php://input');
parse_str(str_replace(',', '&', $_SERVER['HTTP_QIRSH_SIGNATURE'] ?? ''), $sig);
$expected = hash_hmac('sha256', ($sig['t'] ?? '') . '.' . $raw, getenv('QIRSH_WEBHOOK_SECRET'));
if (!hash_equals($expected, $sig['v1'] ?? '') || abs(time() - (int)($sig['t'] ?? 0)) > 300) {
  http_response_code(400); exit;
}
$event = json_decode($raw, true);
if ($event['type'] === 'invoice.paid') {
  mark_order_paid_once($event['data']['invoice']);  // check the amount, update WHERE status <> 'paid'
}
import hmac, hashlib, json, time

def verify(raw: bytes, header: str, secret: str) -> dict:
    parts = dict(p.split("=", 1) for p in header.split(","))
    expected = hmac.new(secret.encode(), parts["t"].encode() + b"." + raw, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(expected, parts["v1"]) or abs(time.time() - int(parts["t"])) > 300:
        raise ValueError("bad signature")
    return json.loads(raw)

event = verify(await request.body(), request.headers["Qirsh-Signature"], SECRET)
if event["type"] == "invoice.paid":
    mark_order_paid_once(event["data"]["invoice"])  # Decimal amounts, idempotent

For developers

One endpoint, one webhook

A small REST API, a zero-dependency Node SDK, and examples for Express, Next.js, Laravel, WooCommerce, Django, Flask and FastAPI. Coding agents can use the bundled skills to wire it in.

Screens

What your customers and your team see

Open source

Run it yourself

A few thousand lines of TypeScript, seven runtime dependencies and a SQLite database. Read it, fork it, run it on a small VPS. Start on the Nile testnet, move to mainnet when your checklist passes.

$ git clone https://github.com/AQaddora/qirsh qirsh
$ cd qirsh && cp .env.example .env
# set ADMIN_EMAIL and ADMIN_PASSWORD in .env
$ docker compose up -d --build
$ curl -s localhost:8080/health
{"ok":true, ...}

FAQ

Questions people ask first

Does Qirsh ever hold my money?

No. In unique-amount mode customers pay your wallet directly and the server holds no keys at all. In forwarder mode customers pay a deposit address that can only send funds to your wallet; the server holds one fee-payer key that pays TRX for sweeps and cannot redirect anything.

Why does the checkout ask for 49.907423 instead of 49.90?

In the default mode every open invoice gets a slightly different amount, so an anonymous transfer can be matched to its order without a new address. The extra is at most 0.009999 USDT. If your customers pay from exchanges that cannot send exact amounts, use forwarder mode and they pay a round 49.90.

What does it cost?

The software is free and MIT-licensed. Unique-amount mode costs nothing per payment. In forwarder mode each sweep costs about 11 to 13 TRX of network fees (an estimate), paid by the fee wallet.

When is an order marked paid?

Only after the transfer is solidified on TRON, about a minute after it is sent. Your store gets a signed invoice.paid webhook and should fulfil the order then, and only then.

Can I try it without real money?

Yes. Create a project on the Nile testnet, enable simulated payments, and every invoice can be marked paid with one API call. It sends the same signed webhook a real payment would.

What if a customer sends the wrong amount or the wrong token?

A wrong amount shows up as an unmatched transfer that you can assign to its invoice or refund. USDT on another chain never reaches TRON and cannot be seen or recovered by the gateway. Blockchain transfers are final, so refunds are up to the merchant.

Can one server run several stores?

Yes. Each project has its own wallet, network, API keys, webhook, branding and users. Project users only see their own project.

More in the full FAQ.

Take USDT payments without giving up your keys

Set up a test store on Nile in a few minutes. No real funds needed.