PDAs and Seeds
Program-derived addresses for program-owned accounts without private keys. Results appear in the same fence: same-line // comments when short, multiline // blocks below the sample when not.
Search across all documentation pages
Program-derived addresses for program-owned accounts without private keys. Results appear in the same fence: same-line // comments when short, multiline // blocks below the sample when not.
Search for a valid off-curve PDA + bump.
// let (pda, bump) = Pubkey::find_program_address(&[b"user", user.as_ref()], program_id);
// bump in 255..=0 until off-curveCreate from seeds including bump - may fail if on-curve.
// Pubkey::create_program_address(&[b"user", user.as_ref(), &[bump]], program_id)?Store bump so future invokes need not re-search.
// state.bump = bump;CPI with PDA signer seeds.
// invoke_signed(&ix, accounts, &[&[b"user", user.as_ref(), &[bump]]])?Prefer find_program_address bump for uniqueness.
// always persist the bump from find_program_addressSeeds are byte slices; keep short and stable.
// seeds: user pubkey, str "vault", mint pubkeyATA is a PDA of the ATA program.
// getAssociatedTokenAddress(mint, owner)PDAs cannot sign except via invoke_signed.
// no private key exists for a PDAOrder of seeds is significant.
// [b"cfg", authority.as_ref()] != [authority.as_ref(), b"cfg"]Seeds are always with a program_id.
// same seeds different program => different PDASystemProgram create_account + assign via CPI signed.
// create_account + assign to program_id with invoke_signedAnchor validates seeds match.
// seeds = [b"user", user.key().as_ref()], bumpResize account data with realloc (careful with rent).
// account.realloc(new_len, false)?Transfer lamports out and zero data carefully.
// drain lamports to destination; mark closedcreate_program_address errors if key is on curve.
// Err if seeds produce on-curve pointStack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, Rust 1.91.1, and @solana/kit 7.0.0.
Reviewed by Chris St. John·Last updated Jul 18, 2026