0

I have a problem with sending tokens. I need to send NFT from my Phantom wallet. Most likely the problem is with Assosiated Token Account, because somewhere in this process I catch errors. I'm trying to create an instruction for ATA, and add it to the transaction before executing the instruction to transfer the tokens (NFT)

Errors like this: Error processing Instruction 2: Provided seeds do not result in a valid address

                let receiverATA = await getAssociatedTokenAddress(mintAddress, receiverPublicKey);

            
                const destination = await createAssociatedTokenAccountIdempotentInstruction(
                        window.solana.publicKey, // presumably your wallet
                        receiverATA,
                        mintAddress,  // of the token you are sending
                        receiverPublicKey, // person you are sending the token to
                        TOKEN_PROGRAM_ID,
                        ASSOCIATED_TOKEN_PROGRAM_ID
                );
                transaction.add(destination);
                console.log("destination:", destination);
                
                


                await sleep(350);

                if (amount > 0) {
                    const transferInstruction = createTransferInstruction(
                        senderTokenAccountAddress, 
                        receiverATA,
                        senderPublicKey, 
                        amount * Math.pow(10, decimals),
                        [],
                        TOKEN_PROGRAM_ID
                    );
                    transaction.add(transferInstruction);
                    await sleep(300);
                }
                
            }               


          transaction.feePayer = window.solana.publicKey;
          let blockhashObj = await connection.getRecentBlockhash();
          transaction.recentBlockhash = await blockhashObj.blockhash;
          
            
          const signed = await window.solana.signTransaction(transaction);

          let txid = await connection.sendRawTransaction(signed.serialize());
          await connection.confirmTransaction(txid);

1 Answer 1

2

The params are in the incorrect order for creating the associated-token-account, try doing:

                const destination = await createAssociatedTokenAccountIdempotentInstruction(
                        window.solana.publicKey, // presumably your wallet
                        receiverATA,
                        receiverPublicKey, // person you are sending the token to
                        mintAddress,  // of the token you are sending
                        TOKEN_PROGRAM_ID,
                        ASSOCIATED_TOKEN_PROGRAM_ID
                );

Source code at https://github.com/solana-labs/solana-program-library/blob/6366ad9b689a4139ec5ae70c180e0f08f750d0e3/token/js/src/instructions/associatedTokenAccount.ts#L48

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.