---
id: I0135
title: "Supabase Edge transaction check"
url: https://carbium.sh/library/integrate/supabase-edge-transaction-check
collection: Integrations
category: Serverless and edge
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Supabase Edge transaction check

A server function takes a signature from a client, reads the transaction through Carbium at confirmed, and returns a verdict: on chain, not failed, recent, and signed by the wallet you name.

## What the check decides

A client that says it has paid, or signed for an action, sends your server a transaction signature. Your server should not take that claim on trust. This check asks Carbium for the transaction at `confirmed` commitment and turns the answer into one verdict made of three facts: the transaction is on chain, it did not fail, and its block time falls within five minutes of now. With a wallet address as a second argument, it also requires that wallet to have signed.

The function only reads. It signs nothing, sends nothing and holds no private key. Your server still decides what the verdict permits, and it has to remember every signature it accepted, because a check cannot tell a first request from a repeat of the same signature.

## The calls and what they cost

A check with a signature makes one call, [getTransaction](https://carbium.sh/docs/rpc), with `commitment: "confirmed"`, `encoding: "jsonParsed"` and `maxSupportedTransactionVersion: 1`. Mainnet carries v1 transactions, and a call that leaves the version out, or sets it to 0, gets -32015 for a v1 transaction or a block holding one. The [version error entry](https://carbium.sh/library/howsolana/transaction-version-error-32015) covers that case. Without a signature argument, the function makes a second call first: `getSignaturesForAddress` for a busy program, limit 5, at `confirmed`, and it takes the first row that did not fail.

| Call | Used for | Cells |
|---|---|---|
| getTransaction | The signature the client sent | 50 |
| getSignaturesForAddress | The newest successful signature, only when no argument is given | 50 |

A check with a signature costs 50 cells, and a check without one costs 100. [Limits are per account](https://carbium.sh/docs/limits), so the checks share one budget with every other call on the same account. A check that the rate limit refuses returns an error with no verdict.

## Calling it from your server

The RPC endpoint is `https://services.carbium.sh`, and the file reads an override from `CARBIUM_RPC_URL`. Keep the Carbium key in your function's secret store and read it from the environment, as the file does. The handler takes the signature from the request body, runs the check, and writes the signature to your table before it grants anything. A signature already in that table is refused before any RPC call, so a repeat costs nothing.

This file targets Node 24 with `@solana/kit` 8.6.0. A Supabase Edge Function runs on Deno, so the port means importing kit through an npm specifier, reading the key with `Deno.env.get`, and wrapping the verify function in your handler. The calls and the checks stay as written.

## Run it on a signature

With no arguments, the file reads the newest successful signature for the busy program and checks it. Pass a signature to check that one, and add a wallet address to require that the wallet signed. Export `CARBIUM_KEY`, then run `node main.ts <signature> <wallet>`. The output is a JSON verdict.

> A verdict with `ok: false` still exits 0, so a script can read the reason. Exit 1 means a call itself failed, for example a refused key or a rate limit. An `older than 300 s` reason on a signature you just received usually means the server clock is wrong.

`main.ts` (run: `node main.ts`)

```ts
// I0135 · Supabase Edge transaction check
// https://carbium.sh/library/integrate/supabase-edge-transaction-check
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import {
  address,
  createDefaultRpcTransport,
  createSolanaRpcFromTransport,
  isSolanaError,
  SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR,
  signature,
} from "@solana/kit";

const key = process.env.CARBIUM_KEY;
if (!key) {
  console.error("Set CARBIUM_KEY to your Carbium key, then run again.");
  process.exit(1);
}
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",
    headers: { "x-api-key": key },
  }),
);

const MAX_AGE_S = 300; // older transactions are refused
const BUSY_PROGRAM = address("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4");
const [givenSig, wallet] = process.argv.slice(2);

// The signature from argv, or the newest successful one for a busy program.
async function pickSignature(): Promise<string> {
  if (givenSig) return givenSig;
  const rows = await rpc
    .getSignaturesForAddress(BUSY_PROGRAM, { limit: 5, commitment: "confirmed" })
    .send();
  const row = rows.find((r) => r.err === null);
  if (!row) throw new Error("none of the newest 5 signatures succeeded");
  return row.signature;
}

type Verdict = { ok: boolean; reason: string; slot?: string };

async function verify(raw: string): Promise<Verdict> {
  const tx = await rpc
    .getTransaction(signature(raw), {
      commitment: "confirmed",
      encoding: "jsonParsed",
      maxSupportedTransactionVersion: 1,
    })
    .send();
  if (tx === null) return { ok: false, reason: "not found at confirmed; retry shortly" };
  const slot = tx.slot.toString();
  if (tx.meta?.err) {
    const err = JSON.stringify(tx.meta.err, (_, v) => (typeof v === "bigint" ? v.toString() : v));
    return { ok: false, reason: `failed on chain: ${err}`, slot };
  }
  if (tx.blockTime === null) return { ok: false, reason: "no block time", slot };
  const age = Math.floor(Date.now() / 1000) - Number(tx.blockTime);
  if (age > MAX_AGE_S) return { ok: false, reason: `older than ${MAX_AGE_S} s (${age} s)`, slot };
  if (wallet) {
    const keys = (tx.transaction as unknown as { message: { accountKeys: { pubkey: string; signer: boolean }[] } }).message.accountKeys;
    if (!keys.some((k) => k.signer && k.pubkey === wallet)) {
      return { ok: false, reason: `${wallet} did not sign`, slot };
    }
  }
  return { ok: true, reason: "on chain, not failed, recent" + (wallet ? ", signed by the wallet" : ""), slot };
}

try {
  const sig = await pickSignature();
  const verdict = await verify(sig);
  console.log(JSON.stringify({ signature: sig, ...verdict }, null, 2));
} catch (err) {
  const status = isSolanaError(err, SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR) ? ` (HTTP ${err.context.statusCode})` : "";
  console.error(`check failed${status}: ${err instanceof Error ? err.message : String(err)}`);
  process.exitCode = 1;
}
```

## Where it ends

- The file targets Node 24. Supabase Edge Functions run on Deno, so the port described above is yours to make, and this entry does not run it.
- The verdict covers one transaction and nothing inside it. It does not compare an amount, a recipient or an instruction with your order. Add those checks on the parsed instructions before you grant anything.
- The check keeps no record of signatures. Store each accepted signature and refuse repeats, or the same signature passes again.
- The check reads at `confirmed`. A transaction that has not reached that level answers null, and the verdict asks for a retry instead of waiting.
- Without an argument, only the newest five signatures are read. `getSignaturesForAddress` reaches back 30 days at most, so an older signature, or one below the ledger floor, may answer null. This is a recent-transaction check and does not do archive lookups.
- The check trusts the answer from one endpoint. It does not compare with a second node, so a node that lags can report a transaction as missing when it is on chain.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| The verdict says `not found at confirmed; retry shortly` for a signature the client has just sent. | Commitment has not reached `confirmed` yet. Tell the client the payment is pending and check again after a short delay. Do not mark the action failed. |
| The call answers -32015 about a v1 transaction. | The call left out `maxSupportedTransactionVersion: 1`. Set it on every [getTransaction](https://carbium.sh/docs/rpc) and getBlock call, as the file does, and read the [error codes](https://carbium.sh/docs/errors) if the code persists. |
| The check exits 1 with `HTTP 401`, and the key is refused as `UNKNOWN_KEY`. | The key is wrong or was cut short. Check that `CARBIUM_KEY` holds the whole key, sent in the [x-api-key header](https://carbium.sh/docs/auth), and that nothing else sets `CARBIUM_RPC_URL`. |
| The check exits 1 with `HTTP 429` and a retry-after hint. | The account's budget is spent, often by other traffic on its keys. Wait the hinted time and run the check again. The action stays pending until a verdict comes back. |
| A check says ok for a signature your app already accepted. | The function keeps no record. Write each accepted signature to your table, under a unique constraint, before the handler answers, and refuse a signature already present. |
| A fresh payment fails with `older than 300 s`. | The server clock is wrong, or the client sent an old signature. Sync the server clock. A signature genuinely older than five minutes needs a new transaction. |

## Questions

### Can I verify a transaction on my server without storing anything?

You can read it, but a payment check needs a stored record of each signature you accepted. Without one, the same signature passes a second time and the check cannot tell.

### Why does the check read at confirmed and not finalized?

The calls name `confirmed`, the level most checks at the point of sale need. Choose `finalized` for an action you cannot reverse, since it can arrive a little after `confirmed`.

### Can the same function run inside a Supabase Edge Function?

The logic can, after the Node 24 to Deno port described above. The file in this entry is written for Node 24, so run it there first.

### What does a check cost against my plan?

A check with a signature is one 50 cell getTransaction call, and a check without one adds a 50 cell getSignaturesForAddress call. Limits are per account, so these checks share the budget with the rest of your traffic on that account.

## Related

- [Transaction version error -32015](https://carbium.sh/library/howsolana/transaction-version-error-32015) (How to use Solana, HS0012)
- [Slack slot-lag alerts](https://carbium.sh/library/integrate/slack-slot-lag-alerts) (Integrations, I0001)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
- [carbium.sh/docs/auth](https://carbium.sh/docs/auth)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/errors](https://carbium.sh/docs/errors)
