Skip to content

PDA Derivation - Automatic Program Derived Address Calculation

Program Derived Addresses (PDAs) are a fundamental concept in Solana programming, but calculating them manually during testing can be tedious and error-prone. Testship automatically derives PDAs for you, handling both simple and complex derivation patterns.

PDAs are deterministic addresses derived from:

  • A program ID
  • One or more seeds (strings, public keys, or other data)
  • A bump seed (to ensure the address is off the ed25519 curve)

For simple PDA patterns like:

#[account(
seeds = [b"user", authority.key().as_ref()],
bump
)]

Testship automatically:

  1. Identifies the seeds from your program’s IDL
  2. Creates appropriate input fields for variable seeds
  3. Calculates the PDA when you provide the required inputs
  4. Displays the derived address

Testship handles advanced patterns including:

Multiple Seeds

seeds = [b"vault", token_mint.key().as_ref(), owner.key().as_ref()]

Numeric Seeds

seeds = [b"order", order_id.to_le_bytes().as_ref()]

Nested PDAs

// Uses another PDA as a seed
seeds = [b"derived", pda_account.key().as_ref()]

The PDA Builder interface shows:

  • All required seeds in order
  • Input fields for variable seeds
  • Constant seeds (auto-filled)
  • The derived address (live-updated)
  • The bump seed used

Testship validates:

  • Seed type compatibility
  • Required vs optional seeds
  • Seed length constraints
  • Format requirements (e.g., proper byte conversion)

Previously derived PDAs are saved:

  • Quick access to frequently used addresses
  • Reuse across different instructions
  • Share with team members via session links

Testship automatically:

  • Finds the canonical bump seed
  • Caches bump values for performance
  • Handles manual bump specification when needed
  1. Navigate to an instruction requiring a user PDA
  2. Fill in the authority (wallet) address
  3. Testship automatically derives: [b"user", authority_pubkey]
  4. The derived PDA appears in the account field

For instructions with multiple PDAs:

  1. Derive the first PDA (e.g., vault account)
  2. Use that PDA to derive the next (e.g., vault authority)
  3. Both addresses auto-populate in the instruction form
  • No Manual Calculation: Never compute PDAs by hand
  • Error Prevention: Avoid typos and calculation mistakes
  • Speed: Instantly derive complex addresses
  • Learning Tool: Understand PDA patterns in your program
  • Consistency: Same derivation logic as your on-chain program

For non-standard seed patterns:

  • Upload seed data from files
  • Use computed values from previous transactions
  • Integrate external data sources

When you need a specific bump:

  • Manually specify the bump seed
  • Useful for debugging and edge cases
  • Warning displayed if non-canonical bump used

Learn how Testship remembers your frequently used accounts in Account Suggestions.