Crypto Payment Gateway Tech Stack: A Layer-by-Layer Build Guide
A crypto payment gateway runs on a Node.js or Go backend, PostgreSQL for the ledger, HD-derived deposit addresses with HSM or KMS custody, and one reorg-aware chain scanner per network. Add signed webhooks, AML screening, and Kubernetes hosting. Choose build, white-label, or clone script based on custody control and launch speed.
Nov 05, 2026
13 mins read
- Backend: Node.js or Go, split into wallet, monitor, invoicing, and settlement services.
- Ledger: PostgreSQL with double-entry rows and integer amounts. Keep the settlement queue in PostgreSQL, not Redis.
- Custody: the wallet service holds an xpub only. Signing happens in an isolated signer backed by KMS, HSM, or MPC.
- Chains: launch on the chain your first merchants pay on (usually Tron for USDT), then add a second.
- Scanners: store block hashes so a chain reorg rolls payments back instead of settling ghost deposits.
- Webhooks: HMAC-SHA256 over timestamp and body, event IDs, 24 hours of exponential retries.
- Delivery path: clone script in 4-8 weeks, full custom build in 24-48 weeks. Custody control rises with build time.
A crypto payment gateway needs 4 pieces: a Node.js or Go backend, PostgreSQL for the ledger with Redis for caching, HD-derived deposit addresses with HSM or KMS key custody, and one chain scanner per network that confirms deposits and fires signed webhooks.
Every piece works with the others. A weak ledger design corrupts balances. A weak custody model leaves you liable for funds you didn't secure. A bad chain choice puts settlement fees at $50 per transaction instead of cents.
Below, each layer in the order a payment moves through it. For the full build plan, see our crypto payment gateway development guide.
Planning a crypto payment gateway? Troniex has shipped 150+ crypto and AI projects since 2021. Talk to our gateway engineers for a free 30-minute scoping call.
Crypto Payment Gateway Architecture: The 4 Payment States
A payment moves through 4 states:
- Pending: a merchant creates an invoice. The wallet service derives a unique deposit address and stores the invoice.
- Detected: a chain scanner spots an incoming transfer to that address and records the payment.
- Confirmed: the transaction monitor sees enough confirmations and marks the payment confirmed.
- Settled: the settlement service moves funds to the merchant and a signed webhook tells the merchant's system.
Each state maps to a service, a table, and a chain-facing component. The sections below follow that order.

Best Blockchains and RPC Node Options for Crypto Payments
Stablecoin payments run mostly on Tron, BNB Chain, and Polygon, where fees are low and blocks are fast. Ethereum suits high-value settlement and corporate treasuries.
Add Bitcoin if merchants ask for it, but plan for a separate UTXO scanner. Solana needs its own scanner too, reading at the finalized commitment level.
Launch with the chain your first merchants pay on. For USDT, that usually means Tron. Add a second chain only after the first scanner has run clean for a few weeks.
You reach a chain through a hosted provider such as Alchemy or Infura, or through your own nodes. Hosted providers bill by usage and offer free tiers, so cost grows with traffic.
Self-hosting swaps that bill for server, storage, and on-call work, and it needs an engineer watching sync status around the clock. Most teams start hosted and keep one fallback provider per chain.

Crypto Payment Gateway Backend: Node.js vs Go and Service Design
Choosing a language
Node.js and Go are the standard picks for the API layer and the monitors. Node.js is faster to prototype and has the richest chain libraries (ethers, viem). Go compiles to a single binary, uses less memory, and handles many concurrent RPC connections cleanly. Python with FastAPI works if latency matters less than speed of delivery.
Service boundaries
Split the logic into 4 services:
- Wallet service: derives addresses and talks to the signer. It holds no spendable keys.
- Transaction monitor: runs the chain scanners and tracks confirmations.
- Invoicing API: the REST layer merchants call to create payments and check status.
- Settlement service: moves funds to merchants and writes ledger entries.
Separate services let you scale the monitor when volume spikes and restart one service without dropping incoming payments.
Crypto payment gateway database design: PostgreSQL ledger and payment state
PostgreSQL is the source of truth. Use 5 tables:
- invoices: merchant ID, requested amount, chain, token, deposit address, derivation index, expiry, locked rate.
- payments: invoice ID, transaction hash, log index, confirmations, status (detected, confirmed, settled, failed).
- ledger_entries: double-entry rows (debit account, credit account, amount, asset). Balances are sums of entries, never a stored number that gets overwritten.
- webhook_events: event ID, payload, delivery attempts, next retry time.
- scanner_cursors: last scanned block and block hash per chain, which drives reorg recovery.
Store amounts in each asset's smallest unit as integers (wei, sun, satoshi). Convert to USD at read time using the rate captured at invoice creation.
Redis holds price caches and rate limits. Keep the settlement queue in PostgreSQL instead, using a transactional outbox or a SELECT ... FOR UPDATE SKIP LOCKED worker. A payment row and its settlement job then commit together, and a Redis restart never loses a paid invoice.
PostgreSQL handles everything else too: auth, merchant metadata, history. Add MongoDB or Cassandra only if you have measured a problem PostgreSQL doesn't solve.

Crypto Deposit Detection, Confirmations and Blockchain ReORG Handling
Run one scanner per blockchain. It reads each new block, matches transfers against your open deposit addresses, and records them as detected. Polling intervals follow block time: a few seconds on Tron and Polygon, about 12 seconds on Ethereum.
Store the block hash with every cursor update. When a new block's parent hash doesn't match, the chain is reorganized.
Roll the cursor back, revert payments from orphaned blocks to detected, and rescan. Without this step, a reorg leaves you settling a payment that no longer exists.
Set confirmation depth per chain and per payment size. Treat these as starting points and tune them to your risk policy:
|
Chain |
Small payments |
Large payments |
|---|---|---|
|
Tron |
Solidified block (about 19 blocks, roughly 1 minute) |
Solidified block |
|
Polygon |
Provider's finality signal |
Provider's finality signal, plus a time buffer |
|
Ethereum |
A few blocks |
finalized status (2 epochs, about 13 minutes) |
|
Bitcoin |
1-2 confirmations |
3-6 confirmations |
Handle the edge cases in code, not in support tickets:
- Underpayment: keep the invoice open and show the remaining amount.
- Overpayment: settle the invoice and credit or refund the difference per merchant policy.
- Late payment: accept it against the expired invoice and flag it for review. Don't swallow it.
Webhooks
Sign every webhook with HMAC-SHA256 over the timestamp and body, so merchants reject replays. Include an event ID. Retry failed deliveries with exponential backoff for 24 hours. The merchant's handler checks the event ID, sees it was already processed, and skips it.

Crypto Wallet Key Management: HD Addresses, HSM and KMS Custody
Generate one deposit address per invoice from a BIP-44 HD tree. The wallet service holds only the extended public key (xpub), so it derives addresses but never signs anything. A compromised wallet service leaks addresses, not funds.
Spending needs the private keys, and plain KMS doesn't do BIP-32 derivation. Two working patterns:
- Encrypt the seed with AWS KMS or Google Cloud KMS, and decrypt it only inside an isolated signer service with no inbound internet access.
- Use an HSM or MPC custody provider that supports BIP-32 derivation natively.
Keep a small hot wallet for settlement payouts, funded by sweeps from deposit addresses. Move the balance above a set threshold to cold storage on hardware devices such as Ledger.
Token sweeps need gas. EVM chains need native gas in each deposit address, and Tron needs energy or TRX. Budget a gas top-up job, or you'll hold paid USDT you're unable to move.
Never put keys in application code, environment files, or the database.


Not Sure Which Custody and Ledger Design Fits Your Volume?
Our team reviews your chains, settlement flow, and compliance needs, then maps the stack for you. You get a written architecture outline and a build-path recommendation.
Talk to Our Experts
Crypto Payment API, Webhooks, SDKs and eCommerce Plugins
Expose a REST API for creating invoices, checking payment status, and pulling settlement history. Authenticate every request with an API key, and sign every response so merchants can verify it came from you.
Ship SDKs in Node.js and Python. Build a WooCommerce plugin first. Check Shopify's payment app rules before promising a Shopify plugin, because it restricts third-party gateways.
Pair the REST API with webhooks and idempotency keys on invoice creation. A merchant who retries a failed request then gets the original invoice back, not a duplicate. Our crypto payment gateway integration services guide covers the merchant side in detail.
Crypto Payment Gateway Compliance and Security: AML, KYB and Audits
Screen every merchant at onboarding and every incoming transaction. Tools like Chainalysis and TRM Labs check addresses against sanctions lists and known illicit clusters. KYB, Travel Rule obligations, and licensing (MiCA in the EU, MSB or state licenses in the US) depend on where you operate. Read our crypto payment gateway compliance breakdown before you pick jurisdictions.
Commission an independent audit of the signer, the wallet service, and the settlement logic before launch. Troniex runs code audits and load tests before each release, and we recommend an outside firm for the custody path.
Infrastructure and Monitoring for a Crypto Payment Gateway
Host on AWS or GCP. Run services on Kubernetes (EKS or GKE) and scale the transaction monitor on queue depth. Use managed PostgreSQL (RDS or Cloud SQL) with a read replica, and ElastiCache or Memorystore for Redis.
Send logs and metrics to Datadog or New Relic. Alert on 4 conditions:
- Confirmation latency above 2 minutes.
- A scanner whose cursor stopped advancing.
- A failed settlement.
- Webhook retries piling up for one merchant.
Build vs White-label vs Clone script for a Crypto Payment Gateway
|
Approach |
Typical timeline |
Custody control |
Audit scope |
Upgrades |
|---|---|---|---|---|
|
Clone script |
4-8 weeks |
Limited to the script's flows |
Full codebase, vendor-written |
You own and patch every fix |
|
White-label base |
8-12 weeks |
High, via overrides |
Vendor core plus your overrides |
Tied to vendor releases |
|
White-label + custom modules |
12-24 weeks |
Full |
Custom modules plus vendor core |
Vendor core updates, your modules need retesting |
|
Full custom build |
24-48 weeks |
Full |
Entire codebase |
Entirely yours |
A clone script gets you live fastest. You inherit its custody model, settlement flow, and design, and you audit all of it because you run all of it.
A white-label base lets you override dispute handling, settlement rules, and UI while the vendor maintains the core. Upgrades are easier until one conflicts with your overrides.
A full custom build gives you every decision: custody policy, settlement timing, security model. It also gives you the longest audit and every upgrade. The how to build a crypto payment gateway guide walks through the build path step by step.

At Troniex, We shipped 150+ projects since 2021, including custom gateways, white-label platforms, and API integrations into exchange ecosystems.
Crypto Payment Gateway Tech Stack: Tools Per Layer
|
Layer |
Tool |
Purpose |
|---|---|---|
|
Wallets |
BIP-44 HD derivation (xpub) |
Deposit address generation |
|
Wallets |
AWS KMS / Google Cloud KMS |
Seed encryption, signer key custody |
|
Wallets |
Ledger / HSM |
Cold storage and BIP-32 signing |
|
Chain access |
Alchemy, Infura |
EVM RPC providers |
|
Chain access |
TronGrid |
Tron node API |
|
Chain access |
ethers / viem |
EVM client libraries |
|
Chain scanner |
Custom block scanner with reorg handling |
Deposit detection and confirmations |
|
Backend |
Node.js or Go |
API layer, monitors, settlement |
|
Database |
PostgreSQL |
Invoices, payments, ledger, outbox |
|
Cache |
Redis |
Price feeds, rate limits |
|
Screening |
Chainalysis, TRM Labs |
AML and sanctions checks |
|
Monitoring |
Datadog, New Relic |
Logs, metrics, alerts |
|
Hosting |
AWS / GCP |
Kubernetes, RDS or Cloud SQL, ElastiCache or Memorystore |
Start Your Crypto Payment Gateway Build on a Sound Stack
Three decisions set the course: where keys live, how the ledger records money, and what the scanner does when a chain reorganizes. Settle those first. Chain choice, SDKs, and plugins follow from them.
Pick a delivery path that matches your custody needs and launch date. A clone script gets you live in weeks. A custom build gives you every control. If you’re unsure which fits, a short architecture review answers it before you commit budget.

Ready to Build Your Crypto Payment Gateway?
Troniex designs and delivers custom gateways, white-label platforms, and API integrations for exchanges and fintechs. Tell us your target chains and launch date, and we’ll return a scoped plan and timeline.
Contact Us