1

I have a PDA generated with:

const SEED: &str = "My Seed";
let pda = Pubkey::create_with_seed(program_id, SEED, &owner_id).unwrap();

Where program_id and owner_id are some fixed Pubkey's.

I want to call this:

invoke_signed(
    &my_instruction,
    &[...], \\Slice of AccountInfos, pda is among them
    &[&[...]],\\Seeds for accounts to be signed
)

Then I pass SEED.as_bytes()a as a seed, I get InvalidSeed error. What to use in this field?

1 Answer 1

6

This isn't working for you because create_with_seed doesn't generate a PDA! Use Pubkey::find_program_address if you want that.

So your code will look like:

const SEED: &[u8] = b"My Seed";
let (pda, bump) = Pubkey::find_program_address(&[SEED], program_id);
2
  • Then what is the purpose of CreateWithSeed instruction?
    – totikom
    Commented Jul 23, 2022 at 14:05
  • new questions deserve new posts
    – trent.sol
    Commented Jul 23, 2022 at 17:15

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.