DEV Community

Cover image for How to Accept Repeat Crypto Deposits with Permanent Static Addresses & Webhooks in Node.js
Vanryx
Vanryx

Posted on

How to Accept Repeat Crypto Deposits with Permanent Static Addresses & Webhooks in Node.js

One-time payment invoices work well for single checkouts, but they create friction when users need to top up a wallet balance, pay recurring subscriptions, or send variable deposit amounts. Generating a new invoice for every transfer adds extra steps for both your backend and your customers.

A cleaner architecture for SaaS platforms, marketplaces, and digital apps is assigning a permanent static deposit address per user—and letting webhooks credit the user's balance automatically whenever funds arrive.


Architecture Overview

Instead of setting a fixed amount and expiration window upfront:

  1. Generate once: Your backend requests a permanent receiving address for a chosen currency and network, attaching your internal user reference (externalId or email).
  2. Reuse anytime: The user can send repeat deposits or variable amounts to that same address at any time with no new invoice required.
  3. Sync via webhooks: Your server receives an event when a deposit is detected (transaction.pending) and again when it is confirmed on-chain (transaction.confirmed).

1. Install the Node.js SDK

Install the official Vanryx Node.js SDK:

npm install @vanryx/sdk
Enter fullscreen mode Exit fullscreen mode

Create an account in the Vanryx Dashboard to generate your API key. Onboarding is No-KYC, with processing fees starting from 0.5% and 0% fees on internal transfers.


2. Generate a Permanent Deposit Address

Call the API once when onboarding a user or setting up their wallet profile, then save the returned address in your database:

import { Vanryx } from '@vanryx/sdk';

const vanryx = new Vanryx({
  apiKey: process.env.VANRYX_API_KEY,
});

export async function assignDepositAddress(userId, userEmail) {
  const depositAddress = await vanryx.addresses.create({
    currency: 'USDT',
    network: 'TRON',
    externalId: userId,
    email: userEmail,
  });

  // Persist depositAddress.address in your database for this user
  return depositAddress;
}
Enter fullscreen mode Exit fullscreen mode

3. Handle Incoming Deposit Webhooks

When a customer sends funds to their static address, Vanryx sends a webhook POST request to your server. Each payload contains the gross amount sent, the Vanryx service fee, the net amount received, and your attached reference (externalId / email).

import express from 'express';

const app = express();
app.use(express.json());

app.post('/webhooks/vanryx', async (req, res) => {
  const event = req.body;

  // 1. Verify webhook signature before processing
  // 2. Deduplicate by event/transaction ID so retries never double-credit

  switch (event.type) {
    case 'transaction.pending': {
      // Detected on-chain — show a "Pending Deposit" state in your UI
      console.log(`Pending deposit for user: ${event.data.externalId}`);
      break;
    }

    case 'transaction.confirmed': {
      // Confirmed — credit the exact net amount after fees
      const { externalId, netAmount, asset } = event.data;
      await creditUserBalance(externalId, netAmount, asset);
      break;
    }
  }

  return res.sendStatus(200);
});

app.listen(3000, () => {
  console.log('Webhook listener running on port 3000');
});
Enter fullscreen mode Exit fullscreen mode

Production Checklist

  • Credit netAmount on confirmation: Wait for transaction.confirmed before unlocking funds, and credit the net amount after fees so your internal ledger matches your settled merchant wallet balance.
  • Idempotency: Store processed transaction or event IDs so retried webhook deliveries never credit a user twice.
  • Status lookup fallback: If your server experiences temporary downtime, you can query transaction status directly by tracking ID via the REST API.
  • Unified balance management: All deposits from static addresses and hosted invoices settle into your multi-asset Vanryx business wallet, where you can manage balances, withdraw funds, or execute zero-fee internal transfers.

Resources

Top comments (0)