Gravitational plate of three masses and a slashed discABC0Static engraved plate. Three-dimensional view is unavailable or reduced motion is requested.

← back to fieldarticle

articleJul 31, 2022

Solana Program Derived Addresses

How Solana PDAs are discovered off the ed25519 curve via seeds and bumps, signed with invoke_signed, and used as program-controlled account indexes.

Solana Program Derived Addresses

sol.png
sol.png

What a PDA is

A Program Derived Address (PDA) is an account address meant to be controlled by a specific program. It looks like a 32-byte public key, but it has no corresponding private key. The program can still "sign" for that address by passing the seeds and bump into invoke_signed.

That design does three jobs at once:

  • Cross-program calls can treat the PDA as a trusted signer for the deriving program.
  • External users cannot produce a valid signature for the same account.
  • The PDA acts like a hashmap key for indexing accounts under known seeds.

Only the program that derived the PDA can sign for it. That same program can also mutate the account data at that address when the runtime allows it.

Finding a PDA (not "creating" one)

Think of a PDA as discovered, not minted. Solana hashes program_id plus a seed byte string (for example "vote_account") with SHA-256 and checks whether the result lands on the ed25519 curve. About half the time it does, which would make it a normal keypair address — useless as a PDA.

So the runtime tweaks the input with a one-byte bump, starting at 255 and walking down (254, 253, …) until the hash falls off the curve. Once found, that (seeds, bump) pair is deterministic: the same inputs always yield the same PDA.

Ed2559-EC
Ed2559-EC

findProgramAddress returns both the address and the bump that pushed it off-curve.

Signing with a PDA

A program that holds the seeds and bump can sign instructions that require that PDA by calling invoke_signed with the instruction, account list, and derivation material. Creating the PDA account itself also goes through invoke_signed.

In practice, programs store the bump (and sometimes the seeds) in account data so later instructions can re-validate the PDA without asking the caller to pass the bump again.

Other resources

related

  1. Jul 31, 2022/articleSolana accounts model
  2. Aug 1, 2022/articleSolana programs and Web3 API
  3. Jul 31, 2022/articleSolana on-chain programs

graphfeed