Search code examples
rustsolanasolana-web3jsanchor-solanasolana-cli

Derive multiple PDAs for one Public Key with a UUID


I am trying to derive multiple PDAs with a generated seed and get the error shown in the screenshot. If i don't use the uuid and only the seed and the public key for the PDA it works fine.

create_planet

planet_struct

rpc_call

error


Solution

  • In your lib.rs in the planet struct the seeds are not in the correct format

    it should be like this seeds=[b"planet",payer.key.as_ref(),&[uuid as u8]]

    and in your rpc call file

    [anchor.utils.bytes.utf8.encode("planet"),
              wallet.publicKey.toBuffer(),
              new anchor.BN(80).toArrayLike(Buffer)]