In short
A PDA is an address derived from a program plus some seeds. It has no private key, so only that program can sign for it, which makes it handy for storing app state at predictable addresses.You’ve used this in: Trade settlement Step 1
A program-derived address (PDA) is a 32-byte address derived from a program ID
and a set of seeds. It’s guaranteed to be off the Ed25519 curve, so no private
key exists for it. Only the program that derived it can “sign” for it, through
invoke_signed in a cross-program invocation (CPI).
PDA Derivation
The derivation algorithm and canonical bump, with examples for different
seed types.
PDA Accounts
Creating accounts at PDAs and signing for them, with Anchor patterns.
Key facts
- Deterministic: The same seeds and program ID always produce the same address.
- Off-curve: If the hash lands on the Ed25519 curve, derivation fails and the next bump seed is tried.
Security: PDA checklist
- Derive or verify every PDA inside the program. Don’t trust an address because the caller passed it in the right position.
- Use the canonical bump, stored at creation. Never take a bump from instruction data.
- Use fixed-length seeds or separators so two seed sets can’t produce the same address.
- Put the user, pool, or mint in the seeds of any PDA that signs for funds.
When to use PDAs
- Program signing: Only the owning program can sign via
invoke_signed, enabling programs to act as autonomous authorities. - User-scoped state: Derive per-user accounts from user pubkey seeds (e.g.,
["user", user_pubkey]). - No keypair management: No private key to store or lose.
Limits
| Limit | Value | Source |
|---|---|---|
| Max seeds | 16, including the bump (15 of your own) | MAX_SEEDS |
| Max seed length | 32 bytes maximum per seed | MAX_SEED_LEN |
| Bump range | 0-255 (1 byte) | Appended as the final seed element |
create_program_address cost | 1,500 CUs | create_program_address_units |
find_program_address worst-case cost | 1,500 entry + 1,500 x iterations | 1,500 on entry + 1,500 per failed bump |
| Max PDA signers per CPI | 16 | MAX_SIGNERS |