-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
Hey! Sorry if this is not the place, Jacob told me to ask here about why a transaction would fail.
So I have this TX: https://solscan.io/tx/5NSH3J3zt5xSndALKWDxk7hsnEaMPHJrA21p193CnnzBpKjbE8iNkREm7VEH9N2pC83t8VAtH5YcSpBcjexfEycy?cluster=devnet (note that it is on Devnet)
That failed with custom program error: 6400
Why would that happen? And how can I prevent it? I'm not doing anything fancy... this is how I'm creating the transaction on my backend:
// Parse addresses for transaction creation
const recipientAddress = new PublicKey(MERCHANT_WALLET);
const usdcMint = new PublicKey(USDC_MINT);
const payerPubkey = new PublicKey(payerPublicKey);
// Get token accounts
const senderTokenAccount = await getAssociatedTokenAddress(
usdcMint,
payerPubkey,
true // allow multisig accounts
);
const receiverTokenAccount = await getAssociatedTokenAddress(
usdcMint,
recipientAddress,
true // allow multisig accounts
);
// Create transaction - amount needs to be adjusted for decimals (USDC has 6 decimals)
const tokenAmount = Math.floor(amount * 1000000);
const transaction = new Transaction().add(
createTransferInstruction(
senderTokenAccount,
receiverTokenAccount,
payerPubkey,
BigInt(tokenAmount),
)
);
// Get recent blockhash
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
transaction.recentBlockhash = blockhash;
transaction.feePayer = payerPubkey;
Thank you!
Metadata
Metadata
Assignees
Labels
No labels