Skip to content
SummaryPDAs are derived by hashing seeds + program ID + bump via SHA-256 until the result is off the Ed25519 curve. The canonical bump is the first value that produces an off-curve address. Max 16 seeds including the bump (15 of your own), Max 32 bytes per seed.

​Background

Solana Keypair values are points on the Ed25519 curve. A keypair consists of a public key (used as the account address) and a secret key (used to produce signatures). Anyone with the secret key can sign transactions for that address.
Wallet addresses are points on the Ed25519 curve, so each has a private key.Wallet addresses are points on the Ed25519 curve, so each has a private key.
Wallet addresses are points on the Ed25519 curve, so each has a private key.
A PDA is intentionally derived to fall off the Ed25519 curve. Because it is not a valid curve point, no secret key exists, and no external party can produce a signature. Only the deriving program can authorize operations on the PDA through invoke_signed.
A PDA is derived to fall off the curve, so no private key can sign for it.A PDA is derived to fall off the curve, so no private key can sign for it.
A PDA is derived to fall off the curve, so no private key can sign for it.

​PDA vs keypair accounts

PropertyKeypair accountPDA account
Address typeOn Ed25519 curveOff Ed25519 curve
Has private keyYesNo
Can sign transactionsYes (with private key)No
Can sign during CPINo (unless signature included in transaction)Yes (via invoke_signed)
DerivationGenerate Ed25519 keypairDeterministic from seeds + program ID
Typical useUser wallets, Program IDProgram-owned data accounts

​Optional Seeds

The optional seeds are user-defined byte strings that serve as inputs to the PDA derivation. They create unique, deterministic addresses scoped to a program. For example, using ["user", user_pubkey] as seeds derives a different PDA for each user. Seeds must follow these constraints:
  • Maximum 16 seeds per derivation (MAX_SEEDS), including the bump seed, so find_program_address takes at most 15 seeds of your own
  • Maximum 32 bytes per seed (MAX_SEED_LEN)

​Bump Seed

The bump seed is a single byte (u8) appended to the optional seeds during derivation. find_program_address searches from 255 down to 1, calling create_program_address with each value until the result falls off the Ed25519 curve. The first value that succeeds is the canonical bump. Programs should always use the canonical bump to ensure a unique, deterministic mapping from seeds to address.
Security: Use the canonical bump onlyMost seed sets have several valid bumps, and each one derives a different address. If your program accepts a bump from the caller, an attacker can pass a non-canonical bump and get your program to accept a second account for the same seeds.Find the canonical bump with find_program_address when the account is created, store it in the account, and verify against the stored value afterwards. In Anchor, seeds = [...], bump finds the canonical bump on init, and bump = account.bump checks the stored one on later instructions. Don’t take the bump from instruction data.
findProgramAddress counts the bump down from 255 until the address is off the curve.findProgramAddress counts the bump down from 255 until the address is off the curve.
findProgramAddress counts the bump down from 255 until the address is off the curve.

​Derivation Algorithm

The PDA derivation is implemented in the SDK’s create_program_address function. The algorithm works as follows:
  1. Validate that the number of seeds does not exceed MAX_SEEDS (16) and no individual seed exceeds MAX_SEED_LEN (32 bytes). If either check fails, return PubkeyError::MaxSeedLengthExceeded.
  2. SHA-256 hash all seeds, the program ID, and the string "ProgramDerivedAddress" together to produce a 32-byte result.
  3. Check if the result is a valid point on the Ed25519 curve.
  4. If the result IS on the curve, return PubkeyError::InvalidSeeds (the address would have a corresponding private key, which violates the PDA security property).
  5. If the result is NOT on the curve, return it as the PDA.

​Compute Unit Costs

The onchain syscall for create_program_address charges 1,500 CUs per call. The try_find_program_address syscall charges 1,500 CUs on entry (before the loop), then an additional 1,500 CUs for each failed bump attempt within the loop.

​Common Seed Patterns

Seeds are application-specific. Common patterns include:
PatternSeedsUse case
Global singleton["global"]Single program-wide config account
Per-user account["user", user_pubkey]One account per user per program
Per-user-per-entity["vault", user_pubkey, mint_pubkey]Token vaults, per-user-per-token
Counter / sequential["order", user_pubkey, &order_id.to_le_bytes()]Sequential records per user
Security: Prevent seed collisionsSeeds are concatenated before hashing, so ["ab", "cd"] and ["abcd"] produce the same PDA. Use fixed-length seeds or a separator to avoid collisions. For example, ["ab", "-", "cd"] is unambiguous. Fixed-length values such as public keys and to_le_bytes() integers are not affected.
Security: Scope signing PDAs narrowlyA PDA that signs for funds should include the user, pool, or mint it controls in its seeds. When one global PDA (["authority"]) is the authority over every user’s token account, a single missing check that lets a caller choose the destination or the account to sign for can drain all of them. Per-entity seeds such as ["vault", user_pubkey, mint_pubkey] limit what one signature can reach.

​Examples: Derive a PDA

Deriving a PDA computes an address only. It does not create an onchain account at that address. The account must be explicitly created through a separate instruction (typically create_account via CPI). The Solana SDKs provide functions for PDA derivation. Each function takes:
  • Program ID: The address of the program used to derive the PDA. This program can sign on behalf of the PDA.
  • Optional seeds: Predefined inputs such as strings, numbers, or other account addresses.
SDKFunction
@solana/kit (TypeScript)getProgramDerivedAddress
@solana/web3.js v3 (TypeScript)PublicKey.findProgramAddress
@solana/web3.js (legacy, TypeScript)findProgramAddressSync
solana_sdk (Rust)find_program_address
The examples below derive a PDA using the Solana SDKs. Click ▷ Run to execute the code.

​Derive a PDA with a string seed

The example below derives a PDA using a program ID and an optional string seed.
The Rust tabs on this page use the 2.x Solana crates. Install the dependencies with (tested with Rust 1.89 and 1.98):

​Derive a PDA with an address seed

The example below derives a PDA using a program ID and an optional address seed.

​Derive a PDA with multiple seeds

The example below derives a PDA using a program ID and multiple optional seeds.

​Iterating All Possible Bumps

The following examples show PDA derivation using all possible bump seeds (255 to 0), illustrating how find_program_address returns the canonical bump:
This is distinct from the current canonical search behavior documented for sol_try_find_program_address, which iterates from 255 down to 1.
Kit example is not included because the createProgramDerivedAddress function isn’t exported.
In this example, bump 255 produces an on-curve address and fails. The first valid bump is 254, making it the canonical bump.