Payments
A payment is confirmed when transaction.confirmed arrives and getTransaction shows status: "confirmed". It is still not final: a reorg can revert it, which sends transaction.reverted.
transaction- detectedtransaction.
detected - confirmingtransaction.
detected - confirmedtransaction.
confirmed - revertedtransaction.
reverted
confirmed can become reverted, and confirmed again.
Nothing is credited before confirmed. Each network's confirmations.required is the number of blocks a payment needs to count as confirmed. Before that, a payment to one of your customer addresses sends transaction.detected once, and getTransaction and listTransactions show it as detected or confirming, where confirmations tracks its progress.
Show a pending payment
transaction.detected says a payment is on its way, never that it arrived. It names the wallets and amounts its confirmation would credit, and its confirmations when it was seen: current, required, remaining and progress_percent. Show it to your customer as pending, such as "2.5 USDT on its way, 1 of 12 confirmations", and never credit, ship or release anything on it: the payment can still leave the chain. Keep the pending entry by transaction_id, and apply it like any other event of the payment, in the order Credit a customer sets out:
transaction.confirmedof the samecanonicality_generationturns the pending entry into the credit.transaction.revertedof the samecanonicality_generationmeans the payment left the chain before it confirmed: clear the pending entry. It lists noamountsand nowallets, since nothing was credited.- A later
transaction.detected, at a highercanonicality_generation, is the same payment seen again in another block: it is pending again, and any credit of an earlier generation was taken back, even if itstransaction.revertedhas not reached you yet.
transaction.detected is not repeated as confirmations grow; read getTransaction for the current count. Your install never sends a transaction.detected once a later transaction.confirmed or transaction.reverted of its payment exists: the delivery ends superseded. One already on its way at that moment can still reach you after the outcome, which the order above sets aside.
A payment that already meets its policy at the install's first check sends no transaction.detected, and transaction.confirmed is its first event. That is every payment on Solana and XRPL under their default policy of one confirmation, since their scanners read only final data, and a payment found long after its block on any network. If the operator raises the policy on Solana or XRPL, each payment there, already final on chain, sends transaction.detected until it reaches that policy.
transaction.detected is sent for a payment of any amount, dust included: anyone can send one of your customer addresses a tiny amount, and each such payment is announced like any other. Your install filters nothing; ignore small amounts on your side if you want to. An endpoint whose events leave it out receives no transaction.detected at all.
Handle an event
Store each event once by its id. Events can arrive twice, late and out of order, so apply them by canonicality_generation and then occurred_at, never by arrival. Compare occurred_at as a time, as Order events explains.
A payment that confirms again after a revert sends a new transaction.confirmed with a new id. A later change to its amounts or customers repeats transaction.confirmed for the same canonicality_generation: a credit that posts late, such as a token listed after the payment, or a sweep whose send timed out, which your install recognises as its own only after it confirmed. On EVM, and on TRON, Solana, XRPL and Bitcoin for a payout to one of your customer addresses, a payout's transaction is announced once the payout's outcome is known: an EVM payout whose send timed out sends its first transaction.confirmed once your install recognises it, and one whose transfer the chain leaves short or unclear once it settles, after an operator's ruling where it needs one. On TRON, Solana, XRPL and Bitcoin, a payout's transaction that a reorg reported as reverted is announced again once it confirms again and the payout has settled. A transaction.reverted can arrive for a payment that was never announced as confirmed in the generation it ends, and then lists no amounts and no wallets.
Sweeps send these events too, and so do payouts: every EVM payout, and on other networks a payout to one of your customer addresses. A payout to an outside address on those networks sends none, so follow every payout by its payout.* events. Only a positive entry in the amounts of a transaction.confirmed is money in; the amounts of a transaction.detected are not.
Credit a customer
wallets lists the customers a transaction paid: each customer address that received money from outside your install, with its wallet_id, your external_id and what it received per asset, fee excluded. A transaction sent by one of your own addresses pays no customer, so a sweep, a gas top-up or a payout from your treasury lists none. A Bitcoin transaction names no sender, so one that spends from any of your own addresses lists none either. A transaction anyone else sends lists no customer in an asset it takes, on balance, from one of your own addresses, such as a token issuer's transfer out of your treasury.
Set a credit, never add to it. Keep the amount you credited per transaction_id, wallet_id and asset_id, and the last event you applied per transaction_id. Apply one event per transaction_id at a time, under a row lock or a conditional update on what you stored. For each event:
- Skip it unless it is newer: a higher
canonicality_generation, or the same one with a lateroccurred_at. It then becomes the last event you applied. - On
transaction.detected, set each amount to 0, then show itswalletsas pending until a newer event arrives: an event of a newer generation means every earlier credit was taken back. - On
transaction.confirmed, set each amount to the one itswalletslists, and to 0 where it lists none. - On
transaction.reverted, set each amount to 0.
A customer's balance is the sum of their amounts. Applied this way, it ends where the chain did, whatever order the events arrive in, and a payment that only waits is never left credited.
Credits by an operator
A customer address can receive money no payment event reports, such as a transfer made from inside a contract. The install reads every customer address on chain and shows such a gap to the operator, who may credit it. Each credit sends wallet.deposit_credited, with a credit_id and the amounts credited. Add each credit_id to the customer once, beside their payment amounts. When the operator found the transaction, tx_hash names it: if a later transaction.confirmed reports that same transaction, credit only one of the two. The install raises that double count to the operator as an alarm too.
Amounts
amounts lists, per asset, the signed change to the install's funds. The network fee is not part of it: getTransaction reports it as fee. On Bitcoin, a sweep's amounts include the fee its inputs paid, so a sweep reads minus that fee rather than 0. So does a move from a customer address into the treasury that your install did not make, such as an earlier install's sweep that an install rebuilt from the same seed reads again: the money stayed yours.
A transaction.reverted repeats the amounts and wallets of the transaction.confirmed events it takes back, those one canonicality_generation below its own: the newest one's amounts, and every customer they named. It lists neither when you were sent none. The revert takes them back, so the transaction moves nothing, as getTransaction shows for a reverted transaction.
Find payments
listTransactions filters by wallet_id, network, asset, status, source and more; network and asset take a code or an id. With wallet_id it lists the transactions that touched one customer address.
On XRPL, tx_hash is the hash as XRPL nodes and explorers name it: 64 uppercase hex characters, with no 0x. Filter listTransactions by tx_hash as the API spells it.
Warning
source=deposit also returns sweeps: every transaction that touches a customer address gets that role.