---
id: I0127
title: "Snowflake 30-day program load"
url: https://carbium.sh/library/integrate/snowflake-30-day-program-load
collection: Integrations
category: Data warehouses
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Snowflake 30-day program load

A Node script walks a program's signatures back 30 days on your Carbium RPC, fetches each transaction, and writes newline-delimited JSON for a Snowflake stage and COPY INTO.

## What the loader writes

The loader is one Node process with one dependency, `@solana/kit`. It takes a program address and asks Carbium for that program's signatures, newest first. It walks back page by page until a signature's block time is older than 30 days or the row limit runs out. Each signature in the window gets one `getTransaction` call, and each answer becomes one line of JSON: the signature, the slot, the block time, the fee, the error if there was one, and the program address.

The default program is pump.fun's program. For Raydium's AMM program, pass `--program 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8`. The loader lists the transactions that carry the program in their account keys, which includes every call into it. It does not read instruction data, so swap amounts are not in the file.

Each run rewrites its output file. Pass `--out` when you keep runs side by side, and let the Snowflake merge handle the overlap between them.

## The 30-day edge and the cost

Carbium's signature history for an address comes from an [index that keeps up to 30 days](https://carbium.sh/docs/migrate). A page past that edge can come back empty, and the address may have older transactions that this path does not answer. So a request for last month is only fully answered when the month ends within the last 30 days. The loader stops at the edge on its own, so a run never asks past it.

| Call | Cost | What the loader uses it for |
|---|---|---|
| getSignaturesForAddress | 50 cells a call | One page of up to 100 signatures, walked back with `before` |
| getTransaction | 50 cells a call | One transaction for each signature inside the window |

Cost follows the number of calls. A page is one call and a transaction is one call, so on a busy program there is one `getTransaction` for nearly every signature it lists. The cell cost of each call is in the [RPC table](https://carbium.sh/docs/rpc). [Limits are per account](https://carbium.sh/docs/limits), so all the keys on one account share one budget.

The loader sends one call at a time. A call over its rate waits once, and if its cells do not refill within a second it gets a 429 with a retry-after hint. A rate class absorbs bursts up to 1,024 cells or one second of its rate, whichever is larger. One call at a time keeps the load steady, though a long pull takes longer.

## The loader

Install the dependency with `npm install @solana/kit@8.6.0` and set `"type": "module"` in `package.json`. The file reads `CARBIUM_KEY` and exits with a message when it is unset. `CARBIUM_RPC_URL` is optional. The program, the row limit and the output path come from flags, so one file serves both programs.

`main.ts` (run: `node main.ts --program 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P --limit 20`)

```ts
// I0127 · Snowflake 30-day program load
// https://carbium.sh/library/integrate/snowflake-30-day-program-load
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, type Signature } from '@solana/kit';
import { appendFile, mkdir, writeFile } from 'node:fs/promises';
import { dirname } from 'node:path';

const key = process.env.CARBIUM_KEY;
if (!key) {
  console.error('Set CARBIUM_KEY to your Carbium key.');
  process.exit(1);
}

const args = process.argv.slice(2);
const flag = (name: string, fallback: string): string => {
  const i = args.indexOf(name);
  return i >= 0 && args[i + 1] !== undefined ? args[i + 1] : fallback;
};
const program = address(flag('--program', '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P'));
const limit = Number(flag('--limit', '1000'));
const outFile = flag('--out', 'load/program-30d.ndjson');
if (!Number.isInteger(limit) || limit < 1) {
  console.error('--limit must be a whole number above 0.');
  process.exit(1);
}
const cutoff = Math.floor(Date.now() / 1000) - 30 * 24 * 60 * 60;

const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? 'https://services.carbium.sh',
    headers: { 'x-api-key': key },
  }),
);
const json = (value: unknown) => JSON.stringify(value, (_k, v: unknown) => (typeof v === 'bigint' ? v.toString() : v));

await mkdir(dirname(outFile), { recursive: true });
await writeFile(outFile, '');

let before: Signature | undefined;
let seen = 0;
let written = 0;
let failed = 0;
let reachedEdge = false;
while (!reachedEdge && seen < limit) {
  const page = await rpc
    .getSignaturesForAddress(program, { limit: Math.min(100, limit - seen), before })
    .send()
    .catch((e: unknown) => {
      console.error('getSignaturesForAddress:', e instanceof Error ? e.message : String(e));
      return null;
    });
  if (!page || page.length === 0) break;
  before = page[page.length - 1].signature;
  const inWindow = page.filter((s) => s.blockTime === null || Number(s.blockTime) >= cutoff);
  reachedEdge = inWindow.length < page.length;
  seen += inWindow.length;
  const rows: string[] = [];
  for (const s of inWindow) {
    try {
      const tx = await rpc.getTransaction(s.signature, { encoding: 'json', maxSupportedTransactionVersion: 1 }).send();
      if (tx === null) {
        failed++;
        continue;
      }
      rows.push(json({ signature: s.signature, slot: tx.slot, blockTime: tx.blockTime, fee: tx.meta?.fee, err: tx.meta?.err ?? null, program }) + '\n');
    } catch (e) {
      failed++;
      console.error(`getTransaction ${s.signature}:`, e instanceof Error ? e.message : String(e));
    }
  }
  if (rows.length > 0) await appendFile(outFile, rows.join(''));
  written += rows.length;
}
console.log(`wrote ${written} transactions to ${outFile}; ${failed} listed but not written`);
```

## Loading the file into Snowflake

Snowflake's `COPY INTO` reads newline-delimited JSON from a stage into a `VARIANT` column. Three steps cover it:

- Put the file in a Snowflake stage with `PUT` from SnowSQL, or in the bucket behind an external stage.
- Copy it into a staging table with one `VARIANT` column, using a JSON file format.
- Merge the staging rows into the target table on `signature`, so a rerun adds only the rows the table does not hold yet.

Keep `signature` as the key. Two runs with overlapping windows list the same transaction twice, and a plain copy would store it twice. The merge keeps one row per signature, and a row that already exists stays as it is.

## Run it and check the file

Run the proof command with `--limit 20` first. Read the first line of the file: it should carry a signature, a slot and a block time inside the last 30 days, and a `program` field equal to the address you passed. A line with `err` set is a transaction that failed on chain. The program still lists it, so keep it, since failed rows are part of the program's activity.

The last line of output counts the rows written and the signatures that came back null or failed. Once the small run is clean, raise `--limit` in steps. A long pull on a busy program takes a long time, and the file holds the rows already written, so a stopped run leaves a usable file.

> Use a small `--limit` for the first Snowflake load. The loader writes each page as it finishes, so an interrupted run keeps the rows it completed.

## Where it ends

- It reads the 30-day index only. A calendar month that ended more than 30 days ago is partly out of reach, and the loader stops at the edge. The summary line counts the rows and does not say why a window ended.
- It lists transactions that carry the program in their account keys. It does not filter by instruction, token mint or pool, so a filter for swaps or launches is a step after the load.
- It keeps no amounts. A row holds the signature, slot, block time, fee and error. Token amounts sit in the transaction's balance fields, which need a decoder of your own.
- It runs one call at a time. That keeps the rate steady and makes a month of a busy program a long wait.
- A `getTransaction` that answers null is counted and skipped, and the loader does not retry it.
- The loader does not load Snowflake. The stage, the table and the merge are SQL you run yourself.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| The summary line shows many signatures listed but not written, and the log lines carry a 429 response. | The run is over its plan's rate for these calls. Rerun with a smaller `--limit`; the merge on `signature` drops rows that repeat. If the gaps stay, check the getTransaction rate for your plan in the [rate table](https://carbium.sh/docs/rpc). |
| A `getTransaction` for a listed signature answers null. | The signature may sit below the validator's ledger floor, which the signature index can reach past. The loader counts it and moves on. A few nulls at the old end of the window are normal, and the summary line gives the count. |
| The file is empty after the run and the summary says zero written. | Check the `--program` address, and check that the program has activity inside the last 30 days. A window with no rows writes an empty file, which is the correct result. |
| The run stops at the first call with an unknown-key error. | The key is wrong or cut short. The [door answers 401](https://carbium.sh/docs/errors) for an unknown key, so set `CARBIUM_KEY` to the whole key and run again. |
| A second run doubles the rows in Snowflake. | The copy went in without the merge. Load through a staging table and merge on `signature`, as the Snowflake section sets out. |
| Transactions in a pull come back with -32015. | The call dropped `maxSupportedTransactionVersion`. Mainnet carries v1 transactions, and a call without the setting answers -32015 for one. Keep the setting at 1, which the loader sends. |

## Questions

### Can this pull all of last month?

Only the part inside the 30-day index. A month that ended more than 30 days ago is partly out of reach, and an empty page past that age marks the edge. The loader stops there.

### Does the file show swap amounts?

No. Each line holds the signature, slot, block time, fee and error. Amounts sit in the transaction's token balance fields, which a decoder of your own reads from the full transaction.

### Can one run cover both pump.fun and Raydium?

Not in one call. Run the loader once per program address with its own `--out` file, then load both files into the same table. The `program` field tells the rows apart.

### Why is there no Snowflake driver in the script?

The script depends only on `@solana/kit` and Node built-ins, so it runs without a driver or a Snowflake account. The file it writes loads with the same `COPY INTO` that any newline-delimited JSON file uses.

## Related

- [BigQuery chain dataset](https://carbium.sh/library/integrate/bigquery-chain-dataset) (Integrations, I0012)
- [Token transfer volume report](https://carbium.sh/library/usecase/token-transfer-volume-report) (Use cases, UC0040)
- [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/errors](https://carbium.sh/docs/errors)
- [carbium.sh/docs/auth](https://carbium.sh/docs/auth)
