---
id: BI0124
title: "Abandoned checkout report"
url: https://carbium.sh/library/blockchainideas/abandoned-checkout-report
collection: Blockchain ideas
category: Commerce
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Abandoned checkout report

A report that sorts every checkout into paid, failed attempt, open or abandoned by reading the transactions listed at its reference address, then prints the abandonment rate. Runnable code and plan costs included.

## Who uses it

A shop that takes SOL or USDC through Solana Pay opens a checkout for every cart: a payment link or QR code with an amount and a unique reference address. Some carts end in a payment. The rest go quiet, and nobody sees them, because a payment that never happens leaves nothing on chain except an empty list. This report finds the quiet ones.

A merchant reads it as a morning list: which checkouts expired with no payment, which ones had a payment attempt that failed, and what share of closed checkouts ended unpaid. A hackathon team can put it behind a dashboard tab in an afternoon, with the shop's checkout table feeding the list. The demo needs no wallet and no shop, only addresses, and the code can mint its own references. Every call goes to `services.carbium.sh` under one key.

## How a checkout closes

Every checkout carries one reference address, generated fresh and used once. The payment transaction lists that address among its accounts, read-only, next to the transfer. So getSignaturesForAddress on the reference returns the transactions that tried to pay this one checkout and no other. Nothing is ever held at the reference, and nothing needs signing with it afterwards.

| Status | Rule | Typical next step |
|---|---|---|
| Paid | a successful transaction is listed at the reference after the checkout was created | fulfil the order |
| Failed attempt | transactions are listed, and every one of them failed | send the shopper a fresh link |
| Open | nothing is listed and the time to live has not ended | wait |
| Abandoned | nothing is listed and the time to live has ended | send a reminder or release the stock |

The time to live is yours. The code stores it with each checkout, 30 minutes by default, so changing the default later leaves earlier rows alone. A checkout counts as abandoned only after that time passes.

The abandonment rate is the abandoned count over every closed checkout: paid, failed attempt and abandoned. Open ones stay out of it, since they can still pay. Each run works out every status again from the chain, so a shopper who pays after the time to live ends moves the row from abandoned to paid on the next sweep.

> A successful transaction at the reference shows that the payer included it. Check the amount and the recipient inside that transaction before you ship goods.

## The build

One file with `@solana/kit` and what Node 24 ships. It is read-only: no private key, nothing signed or sent. Run it with reference addresses, or the word `new` to mint one, and it prints one line per checkout and then the tally.

1. Read the references from the command line. The word `new` makes a fresh address and prints it, ready to go into a payment link.
2. Store each reference in `checkouts.db` with `node:sqlite`, together with its creation time and time to live. A reference already stored keeps its first row. `TTL_MIN` sets the time to live, and `AGE_MIN` backdates new rows so a demo can show an old checkout.
3. For every stored checkout after the first, wait `GAP_MS`, then call getSignaturesForAddress on the reference for the newest 20 signatures.
4. Keep the signatures whose block time is at or after the creation time. A signature with no block time yet is new, so it stays.
5. Pick the status from the rules in the table, print the line and count it.
6. Print the tally and the abandonment rate.

`main.ts` (run: `CARBIUM_KEY=<YOUR_KEY> TTL_MIN=30 node main.ts new <REFERENCE_ADDRESS>`)

```ts
// BI0124 · Abandoned checkout report
// https://carbium.sh/library/blockchainideas/abandoned-checkout-report
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { DatabaseSync } from "node:sqlite";
import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, generateKeyPairSigner } from "@solana/kit";

const key = process.env.CARBIUM_KEY ?? "";
if (!key) {
  console.error("Set CARBIUM_KEY, then run: node main.ts <reference address | new> ...");
  process.exit(1);
}
const TTL_MIN = Number(process.env.TTL_MIN ?? 30); // time to live of a new checkout, minutes
const AGE_MIN = Number(process.env.AGE_MIN ?? 0); // backdates new rows, for a demo
const GAP_MS = Number(process.env.GAP_MS ?? 4500); // 50 cells per call: one per 4.5 s fits Free's 0.24 req/s
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",
    headers: { "x-api-key": key },
  }),
);

type Row = { reference: string; created: number; ttl_min: number };
const db = new DatabaseSync("checkouts.db");
db.exec("CREATE TABLE IF NOT EXISTS checkouts (reference TEXT PRIMARY KEY, created INTEGER, ttl_min INTEGER)");
const add = db.prepare("INSERT OR IGNORE INTO checkouts VALUES (?, ?, ?)");
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));

async function main() {
  const now = Math.floor(Date.now() / 1000);
  for (const arg of process.argv.slice(2)) {
    const reference = arg === "new" ? (await generateKeyPairSigner()).address : arg;
    if (arg === "new") console.log(`new checkout reference ${reference}`);
    add.run(reference, now - AGE_MIN * 60, TTL_MIN);
  }
  const rows = db.prepare("SELECT reference, created, ttl_min FROM checkouts ORDER BY created").all() as unknown as Row[];
  const tally: Record<string, number> = {};
  for (let i = 0; i < rows.length; i++) {
    const c = rows[i]!;
    if (i > 0) await sleep(GAP_MS);
    try {
      const sigs = await rpc.getSignaturesForAddress(address(c.reference), { limit: 20, commitment: "confirmed" }).send();
      // A signature with no block time yet is brand new, so it counts.
      const mine = sigs.filter((s) => s.blockTime === null || Number(s.blockTime) >= c.created);
      const status = mine.some((s) => s.err === null)
        ? "paid"
        : mine.length > 0
          ? "failed attempt"
          : now > c.created + c.ttl_min * 60
            ? "abandoned"
            : "open";
      tally[status] = (tally[status] ?? 0) + 1;
      console.log(`${c.reference.slice(0, 8)} ${status} (${mine.length} listed since creation)`);
    } catch (e) {
      console.log(`${c.reference.slice(0, 8)} failed: ${e instanceof Error ? e.message : e}`);
    }
  }
  console.log(JSON.stringify(tally));
  const closed = (tally["paid"] ?? 0) + (tally["failed attempt"] ?? 0) + (tally["abandoned"] ?? 0);
  if (closed > 0) {
    console.log(`abandonment rate ${(((tally["abandoned"] ?? 0) / closed) * 100).toFixed(0)}% of ${closed} closed checkouts`);
  }
}

main().catch((e) => {
  console.error(e instanceof Error ? e.message : e);
  process.exit(1);
});
```

The listing reads at `confirmed`, which suits a paid mark while the shopper waits on the checkout page. If the mark starts something you cannot undo, such as shipping, read at `finalized` for that step.

`GAP_MS` defaults to 4500, which spaces the 50-cell listing calls to fit the Free plan. Lower it on a bigger plan. Each listing sits in its own `try`, so a failed one prints its message, stays out of the tally and the sweep carries on.

## What it costs

One sweep is one getSignaturesForAddress call per stored checkout, at 50 cells each. A table of 100 checkouts is 5,000 cells a sweep. Limits belong to the account, so every other tool on its keys draws from the same budget.

| Plan | Listing rate | Sweep of 100 checkouts |
|---|---|---|
| Free ($0) | 0.24 req/s | about 417 s |
| Dev ($20) | 1.2 req/s | about 83 s |
| Business ($250) | 100 req/s | 1 s |
| Pro ($500) | 500 req/s | 0.2 s |

The last column divides 100 calls by the plan's listing rate, before network time, with `GAP_MS` lowered to match the plan. The code reads every stored row on every run, so the cost grows with the table. Move paid rows to an archive table once you have fulfilled them and the sweep stays small. On Free, with `GAP_MS` at 4500, a run every 15 minutes covers about 200 stored checkouts.

## What to add next

- Amounts. For each paid checkout, call getTransaction (50 cells, with `maxSupportedTransactionVersion` set to 1) and compare the balance change with the order total. [Invoice payment tracker](https://carbium.sh/library/blockchainideas/invoice-payment-tracker) shows that read.
- A live paid mark. On the checkout page the shopper is watching, open `wss://services.carbium.sh` with the key as `?api-key=` and send logsSubscribe with a mention of that one reference. It costs 25 credits to open, then 20 credits per MiB sent. [Solana Pay confirmation](https://carbium.sh/library/usecase/solana-pay-confirmation) covers the reference flow end to end.
- Cart context. Add columns for the product, the cart total and the referrer, so the report can group abandonment by product or by hour of day.
- Reminders. Send each abandoned checkout's owner a message with a new link, minted with a new reference.
- Stock release. Hand reserved items back when a checkout turns abandoned, and take them again if a late payment moves it to paid.

## Where it ends

- History is the 30-day address index at most, so a checkout older than that cannot be classified from the chain. The code stores no status and works each one out again on every run, so a paid row left in `checkouts.db` past 30 days reads abandoned on the next sweep. Move paid rows out well before then.
- Abandoned covers every reason for silence. A shopper who never opened the wallet, one who closed it, and one whose transaction expired before it landed all leave an empty list. The report cannot say which.
- A failed attempt shows only when the failing transaction landed on chain. A payment that the wallet or network dropped before that leaves nothing to list.
- The code reads the newest 20 signatures at a reference. One reference per checkout keeps that enough. A reference shared by many carts can push an older payment out of the window.
- Any successful transaction listing the reference counts as paid, whatever it moved. The amount check from the list above closes that gap.
- A transaction a node reports with no block time is treated as new, so a very fresh payment shows at once.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| Every checkout reads abandoned although shoppers say they paid. | The payment link probably left the reference out of the transaction, or the wallet app dropped it. Open one paid transaction and look for the reference among its account keys. A payment without it lists at no checkout. |
| A checkout older than a month lists nothing. | The address index keeps up to 30 days. Classify each checkout once its time to live ends, long before that, and keep the status in your own table. |
| The sweep stops partway with a 429. | The sweep runs faster than the plan's listing rate. Raise `GAP_MS`, sweep less often, or move to a plan whose listing rate fits the table of checkouts. |
| Two checkouts show the same payment. | They share a reference. Mint one per checkout with `new`, and never reuse a reference for a second cart. |
| A checkout reads open long after its time to live ended. | The row was stored with a longer `ttl_min` than you expect: `TTL_MIN` applies only when a reference is first added, and a stored reference keeps its first row. Read the row in `checkouts.db` and correct its `ttl_min`. |
| The run stops with a clear message and no output. | The key is missing. Set `CARBIUM_KEY` before running the file. |

## Questions

### Why a reference address and not the shop's wallet?

The shop's wallet receives every payment, so a listing there cannot tell carts apart. A reference belongs to one cart, so its listing answers for that cart alone.

### How long should the time to live be?

Long enough for a shopper to find a wallet and approve, short enough that stock is not held for ever. 30 minutes is the default, and each row stores its own value, so products with different needs can differ.

### Does it work for USDC checkouts?

Yes. The reference sits in the transfer instruction whether it moves SOL or a token, so the listing works the same. Reading the amount of a token payment needs the token balances in the transaction.

### Will it run on the Free plan?

Yes, with `GAP_MS` at its default. A sweep of 100 checkouts takes about seven minutes at 0.24 req/s, so run it from cron every 15 minutes and archive paid rows.

## Related

- [Solana Pay confirmation](https://carbium.sh/library/usecase/solana-pay-confirmation) (Use cases, UC0002)
- [Invoice payment tracker](https://carbium.sh/library/blockchainideas/invoice-payment-tracker) (Blockchain ideas, BI0021)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/migrate](https://carbium.sh/docs/migrate)
- [carbium.sh/docs/websocket](https://carbium.sh/docs/websocket)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
