A Program Derived Address (PDA) on Solana is a deterministically derived account address created using optional seeds, a program ID, and a bump seed (ranging from 255 to 0), which guarantees the resulting address falls off the ed25519 elliptic curve and therefore lacks a corresponding private key; the bump seed serves as an extra byte input that ensures the derived address is valid and unique, with the first valid bump seed being referred to as the canonical bump.
Solana Program Derived Addresses (PDA): Derivation Explained
Added:in this video we're going to go over program derived addresses this is a salon of feature that allows us to deterministically derive account addresses using some predefined inputs the optional inputs we call seeds then a bump seed is an extra bite we add as an input and then the final input is a program ID there are two things to note about pdas one is that pdas do not have corresponding private keys so they cannot cryptographically sign messages the second thing to note is that programs can sign from pdas derived from their program ID when making cross program implications this is a salon feature where one program directly invokes the instructions of another program we'll cover that in a different video for this video we'll just focus on how pdas are derived so here's a visualization of how PDA derivation works when we call find program address we pass in the optional seeds and a program ID under the hood this will add a bump seed starting with a value of 255 our optional seeds and bump seed and program ID are then passed to create program address if a valid PDA is found meaning the address that's generated falls off the 82559 curve and does not have a valid private key then the PDA and bump seed are returned if not we decrease the bump seed by one so going from 255 to 254 then call find program address again with a new bump seed and we go through this Loop until we found a valid bump seed returning the PDA and whatever the bump is that generated the valid PDA next let's walk through this first example so on Solano we generally use the public key of an 825 519 key pair as the address of an account and a public key has 30 2 bytes and has a corresponding private key also known as the secret now a key pair is a point that falls on the 82559 curve so it has a public key and a private key a program derived address is an address with 32 bytes that looks like a public key but falls off of the ed25519 curve so it does not have a corresponding private key a PDA is derived using some optional inputs that we call seeds and a program ID and a bump seed which is an extra bite that we use to guarantee that the output of the PDA is an address that falls off the curve one thing to note is that when you generate a new key pair or derive PDA it does not automatically create an onchain account at that address so at this point there is no data Associated on the network at these addresses we're simply generating addresses that can be used as the address of an account however we would still need to invoke the system program to create an onchain account at any particular address you can think of generating addresses as random coordinates on a map just cuz you have the coordinates doesn't mean there's anything at that location so if we were to run the example we would get the following output here we have the public key and secret key for the key pair that we generated and the is on curve check returns true for the PDA we have the following address that we're calling the program ID and the output PDA along with its bump seed which we've derived here the is on curve check returns false for the PDA because the PDA has no corresponding private key next let's go over two more examples in the first example we're deriving a PDA where the optional seed is a hardcoded value of admin in the second example we're deriving a PDA where we use multiple seeds the first seed is a hard-coded value the second seed is a public key and the third seed is a number when we run the example we get the following outputs in the first example we get the PDA and a bump seed with a value of 255 in the second example we get the following PDA with a bump seed of 253 note that if we run the example again we get the same addresses and the same bump seats next let's go over how pdas are derived when we call this fine program address function we pass in the optional seeds and a program ID and it gives us back a valid PDA and a bump seed the bump seed is an extra bite that's used as an input to guarantee that the program Drive address returned by this function is a valid PDA that falls off the ed25519 curve and therefore does not have a corresponding private key under the hood find program address calls create program address so we can get the same PDA using our optional seats and including the bump seeds and passing the combined seeds to create program address if we were to run the example we' get the following output so here we can see that both addresses output from find program address and from create program address generate the same address using the same bump and just as before if we run the example again we get the same addresses because the PDA was derived using the same optional seed same program ID and same bump seed next let's go through an example to visualize how this works we're going to use the hardcoded seed hello world and some random address that we're calling program ID when we call find program address we pass in the seed and program ID just as before and get back the PDA and bump seed and we're going to go ahead and print the bump and Seed we're also going to Loop through all possible bumps starting from 255 all the way down to zero passing in the same seed and bump seed for every value of the bump and calling create program address printing the bump mpda if a valid one is found and printing invalid PDA if the combination of seed and bump seed generate an invalid PDA so when we run this example we get the following output we have the program ID and the seed and the output from fine program address note that bump seed is 252 and this is the PDA that was found when we iterate through all the bumps and called create program address note that the bump values 255 254 and 253 all have generated invalid pdas and it's at 252 that we get our first valid PDA which is what's returned by find program address now the first bump seed that generates a valid PDA is commonly referred to as the canonical bump note that there are different values of the bump that also generate valid pdas except with different addresses as a security best practice you generally only want to work with a canonical bump when using pdas
Up Next

Understanding Solana CPIs: Cross-Program Invocation Tutorial
@SolanaFndn
4.2K views•2022-09-08

Torrent File Format & Bencoding: A Technical Deep Dive
@AsliEngineering
12.5K views•2022-08-08

Operational Security Essentials: A Guide for Hacktivists (OPSEC)
@hitbsecconf
157.4K views•2012-11-26

Understanding Ethereum: A Comprehensive Beginner's Overview
@99Bitcoins
3.1M views•2018-06-26
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Blockchain & Crypto



![[Solana Bootcamp Summer 2024] #1 - Kick off | Introduction to Solana](https://i.ytimg.com/vi/8kkGIod41rg/maxresdefault.jpg)







![How to call any Solana Program [Solana Tutorial] - Aug 21st '24](https://i.ytimg.com/vi/NGGzw3pzwfY/maxresdefault.jpg)








![Advanced CPI calls in Anchor [Solana Tutorial] - May 9th '23](https://i.ytimg.com/vi_webp/AKOWg65QWbQ/maxresdefault.webp)
![How To Get Started on Solana [Tel Aviv Hacker House Talk] - Jun 26th '23](https://i.ytimg.com/vi/ygtSTydWV-g/maxresdefault.jpg)
![Deep Dive on PDAs and how to use them [Dev Course: M4 P2] - Jan 13th '23](https://i.ytimg.com/vi_webp/Y4a5n1Rs3Ro/maxresdefault.webp)






