0

Can I transfer SPL tokens from the seed account (PDA) based on the System Program Id created this way:

let derivedAccount = await PublicKey.createWithSeed(usualAccountPublicKey, seed, SystemProgram.programId)

to a usual account with JavaScript and web3 libraries?

1 Answer 1

1

A account-with-seed is unfortunately not the same thing as a program-derived address, and cannot be used as the owner of an SPL token account.

If you want to transfer from an account owned by a PDA, then it must be done from within a program. It's only possible to "sign" for PDAs from within a program, so there's no way to do it with JavaScript / web3.js.

You can learn more about program-derived addresses at https://solanacookbook.com/core-concepts/pdas.html#facts

2
  • Actually, this is possible to have an account-with-seed as an owner of SPL token account. You can reproduce it by these steps: 1. await PublicKey.createWithSeed() 2. transfer from some wallet (I used Phantom) tokens to created address 3. call method await connection.getParsedTokenAccountsByOwner(accountWithSeed, {mint: mintPubkey}), so you will receive SPL token account, owned to account-with-seed Apr 8 at 6:25
  • You can certainly create the token account and transfer tokens into it, but it's impossible transfer any tokens out of those accounts
    – Jon C
    Apr 8 at 9:43

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.