---
id: HS0156
title: "Null blockTime handling"
url: https://carbium.sh/library/howsolana/null-blocktime-handling
collection: How to use Solana
category: History and parsing
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Null blockTime handling

One read-only TypeScript file lists the newest signatures for an address, counts the null blockTime values, and dates each gap from its slot. It shows the nulls that no slot can fill and keeps them null.

## What null means

Solana stamps a block with a Unix timestamp, and the RPC copies that stamp into `blockTime`. The value is a count of seconds since 1970. It is `null` when the node has no timestamp for the slot. Three cases produce it: a transaction read before its slot has a timestamp, a slot the node no longer holds, and a slot with no block at all because its leader skipped it.

The field appears in two places. `getTransaction` returns it on the transaction object. `getSignaturesForAddress` returns it on each signature entry, next to the slot, the error and the confirmation status. The list call is the better route to dating activity. One call returns a page of signatures with their times, while `getTransaction` is one call per signature, and both cost 50 cells on Carbium.

The job here has three steps. List the newest signatures for an address. Count the entries whose time is null. Fill each gap from `getBlockTime` for the signature's slot, and keep the null when that answer is null too. The slot lookup is cached, so two signatures from one block trigger one call.

## The code

Install `@solana/kit` at 8.6.0, export `CARBIUM_KEY` and run the file with Node 24, which strips the types on load. With no argument it reads the SPL Memo program, which appears in blocks all day. Pass any address to read its own recent history instead.

`main.ts` (run: `node main.ts [address]`)

```ts
// HS0156 · Null blockTime handling
// https://carbium.sh/library/howsolana/null-blocktime-handling
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

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

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

// No argument: the SPL Memo program, which appears in blocks all day.
const target = address(
  process.argv[2] ?? "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr",
);
const sigs = await rpc
  .getSignaturesForAddress(target, { limit: 25, commitment: "confirmed" })
  .send();

type Ts = NonNullable<(typeof sigs)[number]["blockTime"]>;
const slotTimes = new Map<bigint, Ts | null>();
const fmt = (t: Ts | null) =>
  t === null ? "null" : new Date(Number(t) * 1000).toISOString();

let nulls = 0;
let filled = 0;
for (const s of sigs) {
  let blockTime = s.blockTime;
  if (blockTime === null) {
    nulls++;
    if (!slotTimes.has(s.slot)) {
      try {
        slotTimes.set(s.slot, await rpc.getBlockTime(s.slot).send());
      } catch (e) {
        console.error(`getBlockTime ${s.slot} failed: ${(e as Error).message}`);
        slotTimes.set(s.slot, null);
      }
    }
    blockTime = slotTimes.get(s.slot) ?? null;
    if (blockTime !== null) filled++;
  }
  console.log(
    `${s.signature.slice(0, 12)} slot=${s.slot} ${s.confirmationStatus ?? "-"} blockTime=${fmt(blockTime)}`,
  );
}
console.log(
  `${sigs.length} signatures, ${nulls} with null blockTime, ${filled} dated from their slot`,
);
```

The transport sends every call to `https://services.carbium.sh` with the key in the `x-api-key` header. The list is requested at `confirmed`, and the call states that commitment so the reader can see which level the times come from. A failed slot lookup is printed and leaves its null in place, so one missing block does not stop the list. The final line counts the nulls and the gaps the lookup filled.

`blockTime` arrives as a `bigint`, so the file converts it with `Number(t) * 1000` before it builds a `Date`. The conversion is safe for the range of Solana timestamps, which sit well inside the safe integer limit.

## Reading the output

Each line shows a signature prefix, its slot, its confirmation status and its time. The table explains each field the line carries.

| Field | Meaning |
|---|---|
| blockTime | Unix time in UTC for the slot, or null when no timestamp was found. |
| slot | The slot the transaction landed in. Signatures that share a slot share one block time. |
| confirmationStatus | processed, confirmed or finalized. A null on a processed read is the most common case, because the slot is still new. |
| summary line | The count of signatures, how many had a null time, and how many the slot lookup filled. |

A null that survives at confirmed or finalized is less common. Read the same signature again after a short pause, and treat a second null as the answer for now. The entry does not turn a null into a guessed time.

> The RPC returns seconds, and `new Date` expects milliseconds. The code multiplies by 1000 once, in one place, so every printed time uses the same conversion.

## On Carbium

`getSignaturesForAddress` costs 50 cells per call on Carbium, and the same price applies to [getTransaction](https://carbium.sh/docs/rpc) for one signature. The file makes one list call and then at most one `getBlockTime` per distinct null slot, so the cost grows with the number of gaps, not with the page size.

The list reads an address index that keeps up to 30 days. A page that reaches past 30 days can list signatures whose transactions the node no longer returns. The file dates those signatures from the list alone and does not call `getTransaction` for them.

Each call that runs over its [rate limits](https://carbium.sh/docs/limits) is answered with an error, so a loop over many addresses needs its own pacing. The file makes one list call per run, which keeps a single read well under any plan's ceiling.

## Where it ends

The file dates a list of recent signatures. It does not date a whole address history. The list reaches back 30 days at most, so a null on an old signature may come from the index edge, and the file cannot tell which.

`getBlockTime` answers only for slots the node holds. A skipped slot has no block, so the call returns an error. The code prints that error and keeps the null. It never copies a neighbouring slot's time into the gap, because a neighbour can belong to a different block.

A null `blockTime` says nothing about whether a transaction succeeded. Read `err` on the same signature entry for that, and keep the time and the outcome as separate fields in any table you build.

The time is the timestamp the cluster records for the block, and it is an estimate. Treat it as approximate. When the exact order of two events matters, sort by slot and show the time as a label.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| Every `blockTime` in the output is null, including signatures from last week. | Check the address and the commitment. A busy address read at processed shows nulls on fresh signatures. If old signatures are null too, the node no longer keeps those blocks, and this endpoint cannot give their time. |
| `getBlockTime` throws for a slot that appears in the list. | The slot had no block when the call ran, which happens for a skipped slot. The code prints the error and keeps the null. Do not retry it in a loop. |
| Times differ by a few seconds from a block explorer. | The RPC returns the cluster's timestamp for the block, which is an estimate. Store the slot next to the time, and sort by slot when order matters. |
| `getTransaction` returns null for a signature the list just showed. | The signature is older than the node's ledger floor, so the transaction body is gone while the index entry remains. Date it from the list and treat the body as unavailable. |
| The file exits at once with a message about CARBIUM_KEY. | Export CARBIUM_KEY in the same shell before you run the file. The file makes no call while the variable is unset. |

## Questions

### Why is blockTime null on a transaction I just sent?

A new slot may not have a timestamp yet, so a read at processed can show null that a later read fills. Wait for confirmed and read the signature again.

### Can I use blockTime as an exact clock for ordering events?

No. Order by slot, which is the sequence the cluster produced. Use blockTime to show a readable time, and treat that time as approximate.

### What should I store when the time is null?

Store the slot and the signature, which do not change. Keep the time as a nullable column that a later read can fill.

### How far back can I date a signature with this file?

The list reaches back 30 days at most. Older activity needs a source outside this file.

## Related

- [Signature history pagination](https://carbium.sh/library/howsolana/signature-history-pagination) (How to use Solana, HS0034)
- [Date-range transaction query](https://carbium.sh/library/usecase/date-range-transaction-query) (Use cases, UC0123)
- [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)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
