I want to find and initialize a PDA for Token Swap Program https://spl.solana.com/token-swap
It keeps throwing this error:
transactionMessage: 'Transaction simulation failed: Error processing Instruction 0: custom program error: 0xe',
transactionLogs: [
'Program SwapsVeCiPHMUAtzQWZw7RjsKjgCjhwU55QGu4U1Szw invoke [1]',
'Program log: Error: InvalidInstruction',
'Program SwapsVeCiPHMUAtzQWZw7RjsKjgCjhwU55QGu4U1Szw consumed 1071 of 200000 compute units',
'Program SwapsVeCiPHMUAtzQWZw7RjsKjgCjhwU55QGu4U1Szw failed: custom program error: 0xe'
]
Here is my code, I was following the tutorial at https://solanacookbook.com/references/accounts.html#create-a-pda
const masterPayerPubKey = masterPayerKeypair.publicKey;
const programId = splTokenSwap.TOKEN_SWAP_PROGRAM_ID;
let [pdaPubKey, bumpSeed] = await solanaWeb3.PublicKey.findProgramAddress(
[masterPayerPubKey.toBuffer()],
programId,
);
let connection = new solanaWeb3.Connection(solanaWeb3.clusterApiUrl("devnet"), "confirmed");
// Transaction Instruction for initializing PDA (Program Derived Address)
// https://solanacookbook.com/references/accounts.html#create-a-pda
const data_size = 0;
let initializePDATx = new solanaWeb3.Transaction().add(
new solanaWeb3.TransactionInstruction({
keys: [
{
pubkey: masterPayerPubKey,
isSigner: true,
isWritable: true,
},
{
pubkey: pdaPubKey,
isSigner: false,
isWritable: true,
},
{
pubkey: solanaWeb3.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
{
pubkey: solanaWeb3.SystemProgram.programId,
isSigner: false,
isWritable: false,
},
],
data: Buffer.from(new Uint8Array([data_size, bumpSeed])),
programId: programId
})
);
let transactionHash = await connection.sendTransaction(initializePDATx, [masterPayerKeypair]);
await connection.confirmTransaction(transactionHash);