Apparently creating PDA account is possible from both the client-side and the contract side. So I want to know what is the best way to create it. Are there any pros and cons on choosing the client side rather than the contract side or vice versa?

// client side
await PublicKey.createWithSeed(publicKey,SEED,new PublicKey(programId));

// contract side

1 Answer 1


You're much better off with the second option, since the first requires the publicKey keypair to sign the transaction, which will be much more limiting.

If you look at the instruction implementation, you'll see that from (the payer) and base (the key used to generate the account with seed) are both required as signers: https://github.com/solana-labs/solana/blob/b2ece6368f4e2c2d63225c2fd30a0a19e7605ccd/sdk/program/src/system_instruction.rs#L557

With a PDA, you don't need any external signers at all. By proving how it derived the address, the program can "sign" for any PDA.

  • I am not sure if I understand your answer. Apparently, anyone can create an account using await PublicKey.createWithSeed there is no restriction on who can sign the signature.
    – JohnVersus
    Nov 11, 2022 at 6:06
  • I clarified my answer
    – Jon C
    Nov 11, 2022 at 8:56

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.