Closed ritikbhatt20 closed 1 day ago
hey, you need to pass the destination as some account type (System Account in your case mostly) and get the key property. In solana we need to pass all accounts that will be used for the instruction not just as pubkey. the Poseidon instruction should look like:
import { AssociatedTokenAccount, Mint, Pubkey, Signer, SystemAccount, TokenProgram, u64, UncheckedAccount } from '@solanaturbine/poseidon';
export default class TransferTokensProgram {
static PROGRAM_ID = new Pubkey('CSqtsYXnt2UfXttszwG6rGFFY7EedJ5kmn4xEyas4LeE');
transferTokens(
owner: Signer,
sourceAta: AssociatedTokenAccount,
destination: SystemAccount,
destinationAta: AssociatedTokenAccount,
mint: Mint,
transferAmount: u64,
) {
sourceAta.derive(mint, owner.key).initIfNeeded(owner);
destinationAta.derive(mint, destination.key).initIfNeeded(owner);
TokenProgram.transfer(sourceAta, destinationAta, owner, transferAmount);
}
}
hey, you need to pass the destination as some account type (System Account in your case mostly) and get the key property. In solana we need to pass all accounts that will be used for the instruction not just as pubkey. the Poseidon instruction should look like:
import { AssociatedTokenAccount, Mint, Pubkey, Signer, SystemAccount, TokenProgram, u64, UncheckedAccount } from '@solanaturbine/poseidon'; export default class TransferTokensProgram { static PROGRAM_ID = new Pubkey('CSqtsYXnt2UfXttszwG6rGFFY7EedJ5kmn4xEyas4LeE'); transferTokens( owner: Signer, sourceAta: AssociatedTokenAccount, destination: SystemAccount, destinationAta: AssociatedTokenAccount, mint: Mint, transferAmount: u64, ) { sourceAta.derive(mint, owner.key).initIfNeeded(owner); destinationAta.derive(mint, destination.key).initIfNeeded(owner); TokenProgram.transfer(sourceAta, destinationAta, owner, transferAmount); } }
Aghh gotcha.. thanks a lot for correcting buddy.
Found out that the issue is specifically in this line:
Poseidon Code:
Transpiled Anchor Code:
The Expected Anchor Program should be: