0

I have issue with transferring NFT or token from wallet to wallet with @solana/wallet-adapter-react or directly window.solana, I keep getting Signature verification failed error with code -32003 in Phantom, Slope etc wallet.

I use sendTransaction function from useWallet hook and it worked couple weeks ago without problems same code, now it fails every time and I haven't changed anything, so my question is what has changed in solana logic and sending token and if someone can provide some working code. This transaction has 2 simple instructions, first creates token in destination wallet, and second one does token transfer. Here is instructions code

    const mintPublicKey = new PublicKey(mint);
    // GET SOURCE ASSOCIATED ACCOUNT
    const associatedSourceTokenAddr: PublicKey = await getAssociatedTokenAddress(
        mintPublicKey,
        ownerKey
    );

    // GET DESTINATION ASSOCIATED ACCOUNT
    const associatedDestinationTokenAddr: PublicKey = await getAssociatedTokenAddress(
        mintPublicKey,
        destinationKey
    );
    console.info('Destination account', associatedDestinationTokenAddr.toBase58())
    const receiverAccount = await connection.getAccountInfo(
        associatedDestinationTokenAddr
    );

    if (receiverAccount === null) {
        console.log("Receiver account is null!");
        instructions.push(
            createAssociatedTokenAccountInstruction(
                destinationKey,
                associatedDestinationTokenAddr,
                destinationKey,
                mintPublicKey
            )
        );
    }

    instructions.push(
        createTransferCheckedInstruction(
            associatedSourceTokenAddr,
            mintPublicKey,
            associatedDestinationTokenAddr,
            ownerKey,
            1,
            0
        )
    );
    return instructions;

This is transaction creation logic

    for (const mint of mints) {
        const mintTransferInstructions = await getInstructions(mint);
        instructions.push(...mintTransferInstructions);
    }

    // This transaction is sending the tokens
    let transaction = new Transaction();
    for (let i = 0; i < instructions.length; i++) {
        transaction.add(instructions[i]);
    }
    return transaction;

If someone has some input about problem, also Phantom transaction preview shows correctly token that I want to transfer in transaction preview, so don't think issue is with instruction or transaction creation. What does this error mean? I don't use Keypair anywhere in logic to add it to signers array in sendTransaction

4
  • Figured it out, seams in createAssociatedTokenAccountInstruction I can not use destination wallet public key to be payer of creation anymore, I need to pay, but then how does Phantom transfer token or nft from wallet to wallet, what instruction it uses to do that without me paying it? Commented Jul 28, 2022 at 20:20
  • please post the solution as an answer instead of a comment so you can accept it
    – trent.sol
    Commented Jul 29, 2022 at 4:13
  • @trent.sol I get what caused the error now but still didn't get why it changed out of sudden and how can I make wallet that is getting the token or NFT to pay account creation fees? Commented Jul 29, 2022 at 9:54
  • create new questions. stack exchange is for building a corpus of knowledge. one question per post
    – trent.sol
    Commented Jul 29, 2022 at 22:16

1 Answer 1

1

Looking at the code it looks like the transaction will require at least 2 signers, ownerKey and destinationKey.

ownerKey: fee payer and associatedSourceTokenAddr transfer authority

destinationKey: payer for createAssociatedTokenAccountInstruction

As a result you need both of those to sign the transaction, otherwise use ownerKey as payer for createAssociatedTokenAccountInstruction.

In wallets it is always the sender who is payer when creating a token account on behalf of the recipient. The transaction has a single signer.

1
  • Why could I add destinationKey as payer like couple weeks ago and it would send transaction without errors and now it complains about this Signature error. How does Phantom and similar wallets do this transaction, where destination wallet is paying for account creation that is needed to received token or nft? Commented Jul 29, 2022 at 9:52

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.