5

There is two ways of ensuring the bump

First: Client side passed as parameter to be stored program side

const [pubkey, bump] = findProgramAddress()

program.methods.myMethod({bump})

Second: Solana progam side using

let bump = ctx.bumps.get("some_str")

I was wondering, does anyone know if there are any difference between using either method?

1 Answer 1

7

The second approach is a feature provided by Anchor that eliminates the need to find and pass the bump for a PDA from the client-side. It also ensures you get the correct bump for the PDA.

Previously, I think the first approach was not recommended because it allowed passing in non-canonical bumps. A "canonical bump" is the first bump found that results in a valid PDA. However, I believe Anchor now enforces the use of canonical bumps with the seeds and bump constraints, so this may no longer be an issue. In any case, the second option is simpler.

Here is a sec3 article that explains how bumps work with PDAs: https://www.sec3.dev/blog/pda-bump-seeds

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.