services
Get a key

library / AI and blockchain / SI0017

LLM oracle reader

You get a reader that collects read-only Solana evidence for one question, hashes it, prints the prompt a model should answer from, and re-checks the signature facts against the chain, so an oracle answer points at the exact data it saw.

By Carbium · Verifiable AI and oracles · SI0017 · updated 2026-11-22

01

What an LLM oracle needs from the chain

An LLM oracle takes a question about chain state, puts evidence in front of a language model and returns an answer that a program or a person acts on. The model knows only what the prompt holds. The part you can make checkable is the evidence: which chain data went in, at which slot, at which commitment.

The reader here works on one mint. It reads the total supply and the newest transactions that touched the mint, writes them into one record, hashes the record, prints the prompt and then re-checks the part of the record that anyone can read again. Pass any mint address as the argument. The default is USDC.

The model call is yours and is not in this file. A model's text can differ between runs, so an answer cannot be reproduced the way a median of feeds can. The input can be pinned. If the digest quoted next to an answer matches the hash of a stored record, a reviewer knows the answer was written against exactly that record.

If you would rather let the model fetch data itself through tool calls, LLM tool calling covers that loop. Reading first and handing over a fixed record gives you one object to hash and store instead of a trail of calls to log. To check a single transaction by hand, Transaction status check shows the status read.

02

The evidence record

The record is a plain object with five fields, and each one answers a question a reviewer will ask later.

FieldHoldsWhy it is there
questionthe question text, with the mint addressthe model and the reviewer read the same words
commitmentconfirmedthe record states the level every read used
pinnedsignature, slot, failed flag and block time for the newest three transactionssettled facts that anyone can look up again
snapshottotal supply amount, decimals and the slot of the reada value that moves, kept with the slot it was true at
missingnames of the reads that failedthe model is told what it was not shown

Hashing needs the same bytes for the same data. JSON.stringify does not give that on its own: key order follows insertion, and it throws on a bigint, which is what @solana/kit returns for slots and block times. The file passes a replacer that sorts each object's keys and writes every bigint as text. Hash the exact text you store, and never a copy you rebuilt from parsed JSON.

The memo field of a signature is left out on purpose. Memos are text that strangers wrote on chain, and the prompt carries only numbers and addresses.

03

The reader file

It is one file on Node 24 and @solana/kit 8.6.0, with node:crypto for the SHA-256. The key comes from CARBIUM_KEY, and the file exits with a message when it is unset. CARBIUM_RPC_URL overrides the endpoint, which defaults to https://services.carbium.sh.

main.ts
// SI0017 · LLM oracle reader// https://carbium.sh/library/si/llm-oracle-reader// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// LLM oracle reader: gather the chain evidence an answer rests on, hash it, print the prompt. Run: CARBIUM_KEY=... node main.ts [mint]import { address, createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";import { createHash } from "node:crypto";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 } }));const commitment = "confirmed" as const;const mint = address(process.argv[2] ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");// Sorted keys, bigint as text: the same data always gives the same bytes.const canon = (value: unknown) =>  JSON.stringify(value, (_k: string, x: any) =>    typeof x === "bigint"      ? x.toString()      : x && typeof x === "object" && !Array.isArray(x)        ? Object.fromEntries(Object.entries(x).sort(([a], [b]) => (a < b ? -1 : 1)))        : x,  );const missing: string[] = [];function take<T>(name: string, r: PromiseSettledResult<T>): T | null {  if (r.status === "fulfilled") return r.value;  missing.push(name);  console.error(`${name} read failed: ${(r.reason as Error).message}`);  return null;}const [supplyRead, sigsRead] = await Promise.allSettled([  rpc.getTokenSupply(mint, { commitment }).send(),  rpc.getSignaturesForAddress(mint, { commitment, limit: 3 }).send(),]);const supply = take("supply", supplyRead);const pinned = (take("signatures", sigsRead) ?? []).map(({ signature, slot, err, blockTime }) => ({  signature,  slot,  failed: err !== null,  blockTime,}));const body = canon({  question: `What is the total supply of ${mint}, and did its newest transactions succeed?`,  commitment,  pinned,  snapshot: supply && { slot: supply.context.slot, amount: supply.value.amount, decimals: supply.value.decimals },  missing,});const digest = createHash("sha256").update(body).digest("hex");console.log(["Answer only from this evidence. If it does not hold the answer, say so.", `Evidence digest: ${digest}`, body].join("\n"));console.log(`digest ${digest}`);// Audit: look the pinned signatures up again and compare slot and outcome.let audit = `audit: 0 of ${pinned.length} pinned entries match`;if (pinned.length > 0) {  try {    const { value } = await rpc      .getSignatureStatuses(pinned.map((p) => p.signature), { searchTransactionHistory: true })      .send();    const matched = pinned.filter((p, i) => value[i]?.slot === p.slot && (value[i]?.err !== null) === p.failed).length;    audit = `audit: ${matched} of ${pinned.length} pinned entries match`;  } catch (e) {    console.error(`audit read failed: ${(e as Error).message}`);    audit = "audit: not run";  }}console.log(audit);

run: node main.ts

The two evidence reads run together under Promise.allSettled, so one failing read leaves the other intact. A failed read goes to stderr and into missing, and the prompt carries the list. The model then sees an empty pinned array together with missing: ["signatures"], which is different from a mint with no recent activity.

The output has three parts: the prompt with its instruction line and digest, a digest line you can store beside the answer, and an audit line. For USDC the snapshot shows decimals 6 and the pinned array holds three entries.

Both evidence reads pass confirmed explicitly, so the record names the level it used and does not depend on a library default.

04

Pinned facts and snapshots

The two kinds of fact in the record age differently.

  • Pinned: a signature, the slot it landed in and whether it failed. Once a transaction has landed these do not change, so a reviewer can look the signature up again and compare. The audit step in the file does exactly that with getSignatureStatuses.
  • Snapshot: the total supply at one slot. It changes whenever the mint issues or burns, so a later read gives another number and proves nothing about the earlier one. The record keeps the slot next to the amount so the reader knows when it was true.

Because a snapshot cannot be re-read, the record itself has to be kept. Store the exact text next to the digest, in your own database or a log. A digest without its record cannot be checked by anyone.

The audit prints how many pinned entries match. A match needs the same slot and the same failed flag. A status that comes back null counts as a mismatch. If the audit read itself fails, the line says audit: not run, so a failed read cannot pass for a count of zero matches.

05

Calls, cost and limits

A run makes three calls: getTokenSupply, getSignaturesForAddress and getSignatureStatuses. getSignaturesForAddress costs 50 cells, and its rate is 0.24 req/s on Free, 1.2 on Dev, 100 on Business and 500 on Pro. On a small plan an oracle that gets asked often should cache one record per question and mint for a short while, since the signature read costs 50 cells.

This file does not retry a 429: the failed read lands in missing and the prompt says so. Limits are per account and an account's keys share one budget, so a 429 can also come from another service on the same account.

Signature pages come from an address index that keeps up to 30 days. That index reaches below the validator's ledger floor, so a signature it lists can have no transaction behind it when you ask getTransaction. The file never calls getTransaction. If you add it to read a transaction's contents, pass maxSupportedTransactionVersion: 1 with an encoding: mainnet carries v1 transactions, and with the option absent or 0 the call answers -32015 for one of them.

06

Where it ends

  • Carbium serves chain data. It does not run a model, sign an answer or publish anything on chain. This file has no signer and no send call. A program that puts an oracle answer on chain is a separate design with its own trust model.
  • The digest binds the input and says nothing about the answer. A model can misread correct evidence, so an answer worth acting on needs a check you can compute yourself, such as the pinned entries the audit re-reads.
  • History is limited to the 30-day address index. An empty page past 30 days marks the index's age limit, and the address may have older transactions. Pinned entries older than that cannot be re-checked here.
  • getTokenLargestAccounts is not served and answers -32601, so a question about the biggest holders needs another way to gather the data. Do not retry that code; check the method.
  • A snapshot is true at one slot. A question about a moving value gets an answer that is already old when it arrives, and the record shows how old.
07

When it goes wrong

what goes wrongwhat to do
JSON.stringify throws on the evidence.@solana/kit returns slots and block times as bigint. Write them as text in the replacer before hashing, as the file does.
The same evidence hashes to two different digests.Sort object keys before serialising, and hash the exact text you store. Never hash a copy rebuilt from parsed JSON.
The audit reports fewer matches than pinned entries.An older signature can come back with no status, because the address index reaches below the ledger floor. Treat a null as unchecked, audit right after the read and keep the record itself.
A 429 leaves the evidence empty and the model answers anyway.Keep the failed read in missing and refuse to publish an answer while the list is non-empty. Wait for the retry-after hint before one retry, and cache a record per question.
Adding a transaction read gives -32015 on some signatures.Pass maxSupportedTransactionVersion: 1 with an encoding. Mainnet carries v1 transactions, and the call answers -32015 without the option.
08

Questions

Does Carbium run the model?

No. Carbium serves the chain reads. The model call stays in your code, and this file only prepares the evidence it should answer from.

Why hash the evidence at all?

The digest ties an answer to one stored record. A reviewer hashes the record, compares it with the digest next to the answer and then audits the pinned entries against the chain.

Which commitment should an oracle read at?

The file reads at confirmed, so the audit finds the same data straight away. For an answer that triggers an irreversible action, change the one commitment constant to finalized, and the record will say so.

How far back can the pinned entries be re-checked?

Signature pages reach back 30 days at most, from the address index. Entries below the ledger floor, even inside those 30 days, can already come back null from the audit. Keep your own copy of the record and its audit result.

Can the model fetch the evidence itself?

Yes, as tool calls, which LLM tool calling covers. A fixed record read before the model runs gives you one object to hash. Tool calls give you a trail of calls that you have to log.