npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@solsonar/solana-alt-cache

v0.2.0

Published

Address Lookup Table cache for Solana. Preload + lazy fetch + synchronous resolve of all account keys for a VersionedTransaction without per-tx RPC overhead.

Downloads

231

Readme

@solsonar/solana-alt-cache

Address Lookup Table cache for Solana. Preload + lazy fetch + synchronous resolve of all account keys for a VersionedTransaction — no per-tx RPC overhead.

import { Connection } from '@solana/web3.js';
import { AltCache } from '@solsonar/solana-alt-cache';

const connection = new Connection('https://your-rpc-url.com');
const altCache   = new AltCache({ connection });

await altCache.preload(KNOWN_ALT_ADDRESSES);

// hot path — synchronous, zero RPC
const allKeys = altCache.resolve(versionedTx);
if (!allKeys) {
  // miss — lazy fetch already fired, this tx skipped for now
  return;
}
// allKeys is `[static..., loadedWritable..., loadedReadonly...]` — exactly the
// order Solana uses, so `instruction.accountKeyIndexes[i]` indexes into it.

Why this exists

Address Lookup Tables are how modern Solana transactions reference more accounts than the legacy 35-account ceiling allows. A v0 VersionedTransaction carries addressTableLookups — pointers to on-chain ALT accounts plus indices into them. Until you fetch and parse the referenced ALTs, you only see the static portion of the tx's account list.

For most Solana applications (validators, RPC nodes) the runtime does this for you. For anything that processes raw transactions — shred listeners, indexers, MEV bots, simulators — you have to do it yourself, and the obvious implementation (one RPC call per tx) defeats the purpose of being on-chain-adjacent in the first place.

This package solves the cache + lazy fill problem cleanly.

  • Synchronous resolve() — no RPC on the hot path.
  • Batched preload() — one RPC call for up to 100 ALTs.
  • Background lazy fetch — on miss, the missing ALTs are fetched in the background. The next time the same ALT shows up, resolve() returns.
  • Deduplication — concurrent misses for the same ALT result in one RPC call, not many.
  • Event-driven — no console.log inside the library.

What this package does not do

  • It does not listen for transactions. Pair with @solsonar/solana-shred-parser or your favourite @solana/web3.js RPC subscription.
  • It does not parse transactions or instructions — you get a string array of account keys back, and you decode the rest yourself.
  • It does not handle ALT lifecycle (deactivation, deletion). It assumes ALTs are stable once seen — true for production-grade routers like Jupiter, where ALTs are extended but rarely re-created.

Install

npm install @solsonar/solana-alt-cache @solana/web3.js

@solana/web3.js@^1.91.0 is a peer dependency.

Requires Node 18+.

How resolve works

resolve(vtx)
  │
  ├─ vtx has no ALT lookups   → return staticAccountKeys (fast path)
  │
  ├─ all referenced ALTs in cache
  │     → return [static..., loadedWritable..., loadedReadonly...]
  │     (canonical Solana order — safe to index with accountKeyIndexes)
  │
  └─ at least one ALT missing
        → schedule background _lazyFetch(missing)
        → return null
        → next tx using the same ALT will succeed

Hit rate climbs to ~95%+ within minutes in production once your "popular" ALTs (Jupiter, large DEX routers) are loaded.

API

new AltCache(options)

| option | type | default | notes | | ------------ | --------------------- | ------------- | ------------------------------------------------------ | | connection | Connection | required | @solana/web3.js Connection (or compatible shape) | | commitment | string | 'confirmed' | RPC commitment for getMultipleAccountsInfo | | batchSize | number | 100 | ALTs per RPC call (Solana RPC limit is 100) |

Methods

  • preload(addrs: string[]) — batched RPC fetch + parse.
  • resolve(vtx) — sync. Returns string[] (base58) or null.
  • has(addr), get(addr), size() — cache introspection.
  • stats(){ hits, misses, lazyFetches, preloaded, errors, cached }.

Events

| event | payload | | --------------- | ---------------------------------------------------- | | 'preloaded' | { count, total, durationMs } | | 'lazyFetched' | { addrs: string[], count } | | 'error' | (err: Error) |

Constants

import {
  ALT_HEADER_SIZE,    // 56
  PUBKEY_SIZE,        // 32
  DEFAULT_BATCH_SIZE, // 100
  DEFAULT_COMMITMENT, // 'confirmed'
} from '@solsonar/solana-alt-cache';

Examples

See examples/:

  • resolve-tx.js — fetch a tx by signature, resolve its ALTs.
  • preload-known.js — preload a list of ALTs from a JSON file, print stats.

Pairs well with

License

MIT