Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.xpaylabs.com/llms.txt

Use this file to discover all available pages before exploring further.

Payouts let you transfer funds from your gateway-managed wallet to any external blockchain address. This is useful for withdrawing collected funds, paying vendors or affiliates, or moving tokens to exchange wallets.

Creating a Payout

Call POST /v1/order/createPayout with the destination address, amount, symbol, and chain:
import crypto from "crypto";

const GATEWAY_URL = "http://your-gateway:3010";
const MERCHANT_TOKEN = process.env.XPAYLABS_TOKEN;

function signRequest(data) {
  return crypto
    .createHmac("sha256", MERCHANT_TOKEN)
    .update(JSON.stringify(data), "utf8")
    .digest("hex");
}

async function createPayout({ amount, symbol, chain, receiveAddress, orderId }) {
  const data = {
    amount,
    symbol,
    chain,
    receiveAddress,
    orderId,
  };

  const payload = {
    sign: signRequest(data),
    timestamp: Math.floor(Date.now() / 1000),
    nonce: crypto.randomUUID(),
    data,
  };

  const response = await fetch(`${GATEWAY_URL}/v1/order/createPayout`, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(payload),
  });

  const result = await response.json();
  if (result.code !== 200) throw new Error(result.msg);

  return result.data;
}

// Send 50 USDT on TRON to an external address
const payout = await createPayout({
  amount: "50.00",
  symbol: "USDT",
  chain: "TRON",
  receiveAddress: "TYourExternalAddress...",
  orderId: "payout_001",
});

console.log(`Payout created: ${payout.orderId}`);

Request Parameters

ParameterRequiredDescription
amountYesAmount as decimal string (e.g., "50.00")
symbolYesToken symbol (e.g., "USDT")
chainYesBlockchain network
receiveAddressYesDestination blockchain address
orderIdNoYour identifier for this payout
uidNoYour user identifier

Address Validation

The gateway validates the receiveAddress format for the specified chain before processing:
ChainAddress FormatExample
TRONBase58, starts with TTWkKZkmuB8DpVeiMoHiKf99ZoFHzk73CqR
EVM (ETH, BSC, POLYGON)Hex, starts with 0x0x05E833cF6a895a9ABe408FD6a8d5e0d3DB2Fec5A
SUIHex, starts with 0x0x24f672b38299ae651f7598f4994ade780c38aeffa4e595c79ab73d3d176543cd
If the address format is invalid, the API returns "ReceiveAddress error".

Payout Status Tracking

After creating a payout, track its status using the order status endpoint:
async function getPayoutStatus(orderId, token) {
  const response = await fetch(
    `${GATEWAY_URL}/v1/order/status/${orderId}`,
    { headers: { "Content-Type": "application/json" } }
  );
  const result = await response.json();
  return result.data;
}

// Poll until completed
const status = await getPayoutStatus("payout_001");
console.log(status.status); // "PENDING", "PENDING_CONFIRMATION", "SUCCESS", "FAILED"
if (status.transaction) {
  console.log(`TxID: ${status.transaction.txid}`);
}

Payout Statuses

StatusDescription
PENDINGPayout created, awaiting processing
PENDING_CONFIRMATIONTransaction submitted to blockchain
SUCCESSPayout confirmed on-chain
FAILEDPayout failed (insufficient balance, etc.)

Webhook Notifications

Payouts also trigger webhook events:
EventWhen
ORDER_PENDINGPayout order created
ORDER_PENDING_CONFIRMATIONTransaction submitted
ORDER_SUCCESSPayout confirmed on-chain
ORDER_FAILEDPayout failed

Important Security Notes

  • Blockchain transactions are irreversible. Double-check the receiveAddress before submitting.
  • The gateway validates address format but cannot verify the address is owned by the intended recipient.
  • Payouts consume blockchain gas fees (TRX for TRON, ETH gas for EVM chains).
  • Ensure your hot wallet has sufficient balance (including gas tokens) before initiating payouts.