Description
Motivation
As a developer migrating from web3.js v1 to @solana/kit (v2), I've found a significant documentation issue regarding with the migration, some features are unknown here now in v2. Such as, there's no clear guidance on how to migrate code that uses PublicKey.findProgramAddressSync()
, which is one of the most common operations when interacting with Solana programs.
The current documentation extensively covers RPC calls, transactions, and keys, but does not adequately address this critical function for deriving PDAs in client-side code. Without this, migration efforts are stalled as developers cannot determine the equivalent API in the new library.
Example use case
In web3.js v1:
import { PublicKey } from '@solana/web3.js';
const PROGRAM_ID = new PublicKey('2CDCG8yMM1wUJgS74HgZn8BvRjnK3rruiie77ErvrSx2');
const SEED = 'player-state';
// Derive a PDA
const [playerStatePDA, bump] = PublicKey.findProgramAddressSync(
[Buffer.from(SEED)],
PROGRAM_ID
);
console.log(`PDA: ${playerStatePDA.toBase58()}, Bump: ${bump}`);
Desired @solana/kit equivalent:
import { /* what do I import? */ } from '@solana/kit';
const PROGRAM_ID = address('2CDCG8yMM1wUJgS74HgZn8BvRjnK3rruiie77ErvrSx2');
const SEED = 'player-state';
// How do I derive the same PDA in @solana/kit?
const [playerStatePDA, bump] = /* what function replaces findProgramAddressSync? */(
[Buffer.from(SEED)],
PROGRAM_ID
);
console.log(`PDA: ${playerStatePDA}, Bump: ${bump}`);
Details
The documentation should:
- Provide the equivalent function to
PublicKey.findProgramAddressSync()
in @solana/kit - Explain any differences in behavior or usage
- Show examples of common PDA derivation patterns
- Document the types and return values
- Explain if there are both synchronous and asynchronous options
If there are program-specific helpers (like the findAddressLookupTablePda
seen in the docs), the documentation should clarify when to use these vs. a general-purpose PDA finder.
This is especially important as PDAs are fundamental to Solana's programming model, and their derivation is a prerequisite for almost any interaction with on-chain programs.