I used the following Rust code (now updated) to try to transfer spl tokens between wallets using ATAs of the respective wallets for the given token.
The from.key is the authority for the transfer.
let transfer_instruction = spl_token::instruction::transfer_checked(&spl_token_2022::ID, from_acct.key, mint.key, to_acct.key, from.key, // was storage&[from.key], amount, 5).unwrap(); msg!("Transfer Inst Formed{:?}!"); // Doesn't make it to here let required_accounts_for_transfer = [ from_acct.clone(), mint.clone(), to_acct.clone(), from.clone(), ]; invoke_signed(&transfer_instruction,&required_accounts_for_transfer,&[], ).unwrap();
The accounts were created (in ts) with the following :
tokenAccount = await getOrCreateAssociatedTokenAccount( connection, keypair, mintPK, keypair.publicKey, // This for "From"// escwallet.publicKey, //Then this for "To" false, null, {}, TOKEN_2022_PROGRAM_ID );
keypair.publicKey
was used for the From Account andescwallet.publicKey
was used for the desination Account
Token22 PID is being used because the mint token includes a 2022 metadata extension!
It doesn't make it past the creation of the instruction.
I get the following error at the ende of the Tx creation:
"Program log: Transfer 100000 from: 4Qeo9ttdf4vCZTC4d2pGq4eqFfkQpxj95t4WGYc2buXV to: 86YUbdsc7z2Y5NdLXeFLwVYfbzVdLjUb1en9XxmJbfb2!","Program log: for mint: GSLS3jfAf6F8Bimab8dvAgc3Xz5rewa2KBKumjhoNn11","Program log: panicked at 'called `Result::unwrap()` on an `Err` value: IncorrectProgramId', 574155a2-81d8-4c76-b5d1-fff88cd66c8d/src/lib.rs:221:12",
TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb is being used!
What I don't understand, I did the same transaction with Phantom (successfully) and get this
The Phantom transaction calculates compute unit budgets, which I don't, but I don't think this causes my error!
All the parameters are the same !!!HELP!!!