Skip to content

Conversation

@meowyx
Copy link

@meowyx meowyx commented Dec 1, 2025

Summary

  • Add first-class helpers for fetching address lookup tables and nonce accounts in both @solana/client and @solana/react-hooks.

Closes #68

Open Questions Addressed

Should the LUT helper also accept multiple addresses in one call (batch)?

Yes. Implemented both single and batch variants:

  • fetchLookupTable(address) - single LUT fetch
  • fetchLookupTables(addresses[]) - batch fetch using getMultipleAccounts

Batch support is important because transactions often reference multiple LUTs, and batching reduces RPC round trips.

For nonces, should we prefer getNonceAndContext or parsed getAccountInfo?

Chose getAccountInfo with jsonParsed encoding. Reasons:

  • Consistency with existing fetchAccount pattern
  • Returns full account context (authority + blockhash) which developers typically need together
  • getNonceAndContext is a specialized RPC method not exposed in the current kit wrapper
  • RPC handles parsing, avoiding manual binary decoding

Changes

@solana/client

  • Types: AddressLookupTableData, NonceAccountData with full type definitions
  • Actions:
    • fetchLookupTable(address, commitment?) - parses LUT binary data
    • fetchLookupTables(addresses[], commitment?) - batch variant
    • fetchNonceAccount(address, commitment?) - uses jsonParsed encoding
  • Exports: All new types and functions

@solana/react-hooks

  • Hooks:
    • useLookupTable(address, options?) - SWR-powered with loading/error states
    • useNonceAccount(address, options?) - SWR-powered with loading/error states
  • Both follow existing hook patterns (useBalance, useAccount)

Documentation

  • Updated @solana/client README with usage examples
  • Updated @solana/react-hooks README with React examples

Usage

// Client
const lut = await client.actions.fetchLookupTable(address);
console.log(lut.addresses); // Address[]

const nonce = await client.actions.fetchNonceAccount(address);
console.log(nonce.blockhash, nonce.authority);

// React
const { data, isLoading } = useLookupTable(address);
const { data, isLoading } = useNonceAccount(address);

Testing

  • pnpm lint
  • pnpm test
  • pnpm build
  • Other (describe):

@GuiBibeau GuiBibeau self-requested a review December 2, 2025 08:49
@meowyx
Copy link
Author

meowyx commented Dec 2, 2025

I also have added two new components on Nextjs example:

  • Added NonceCard component to demo useNonceAccount
  • Added LookupTableCard component to demo useLookupTable
image

@meowyx
Copy link
Author

meowyx commented Dec 2, 2025

On the latest changes I have:

Refactored the address lookup table and nonce account helpers to use Kit's native implementations instead of manual parsing.

For Address Lookup Tables:

  • Replaced manual binary parsing with fetchAddressLookupTable and fetchAllAddressLookupTable from @solana-program/address-lookup-table
  • Added @solana-program/address-lookup-table as a new dependency

For Nonce Accounts:

  • Replaced manual jsonParsed RPC handling with fetchNonce from @solana-program/system (already a dependency)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add helpers for getAddressLookupTable and getNonce in client + hooks

1 participant