0

Is there any function to generate PDAs using seeds manually?

I dont want to create PDAs using client modules but I want to create PDAs inside the rust functions in the contract/program.

Is there a way to do that ?

1 Answer 1

3

you can use this piece of code :

let (address, bump) = Pubkey::find_program_address(
        &[
            ... your seeds ...
        ],
        ctx.program_id,
    );

please note that in anchor you can't use the address variable you get here like if it was passed as an account in the instruction (in a transfer for example).

in many cases, you need to have the account in your instruction's accounts

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.