0

I'm coming to you with yet another Transaction signature verification failure. I read few other posts about it but it did not helped me (including adding prio fee ix)

Context: I'm using anchor to call my program in my React App and signing the tx with phantom wallet results in invalid signature full decoded tx here

I'm certain that only 1 signature from the user is needed so other accounts involved in tx are not signers.

I also tried adding priority fee transaction but did not help


async function createAuction ( ... ) {

...


const ix = await program.methods         
  .initializeAuction3(                   
    <params>             
  )                                      
  .preInstructions([computeUnitLimitTx]) 
  .accounts(<accounts>)                    
  .instruction();                        

const result = await signAndSendTransaction( 
  ix,                                        
  wallet,                                    
  connection,                               
  true                                       
);                                           

}



async function signAndSendTransaction(
  ix: anchor.web3.TransactionInstruction,
  wallet: AnchorWallet,
  connection: Connection,
  withDebug: boolean = false
): Promise<{ txSig?: string; lastValidBlockHeight?: number }> {
  if (!ix || !wallet || !connection) {
    throw new Error(
      "[signAndSendTransaction] Err - ix/wallet/connection undefined"
    );
  }

  const PRIORITY_RATE = 100;
  const PRIORITY_FEE_IX = ComputeBudgetProgram.setComputeUnitPrice({
    microLamports: PRIORITY_RATE,
  });

  try {
    const { value: context } = await connection.getLatestBlockhashAndContext(
      "finalized"
    );
    const messageV0 = new TransactionMessage({
      payerKey: wallet.publicKey,
      recentBlockhash: context.blockhash,
      instructions: [ix, PRIORITY_FEE_IX],
    }).compileToLegacyMessage();
    const tx = new VersionedTransaction(messageV0);

    await wallet.signTransaction(tx);

    if (withDebug) {
      console.log(
        "[signAndSendTransaction][tx:]",
        Buffer.from(tx.serialize()).toString("base64")
      );
    }

    const sig = await connection.sendTransaction(tx);
    return {
      txSig: sig,
      lastValidBlockHeight: context.lastValidBlockHeight,
    };
  } catch (err) {
    const errMsg = err instanceof Error ? err.message : (err as string);
    console.error(errMsg);

    throw err;
  }
}

If I try to call my program via rpc method:

const sig = await program.methods         
  .initializeAuction3(                   
    <params>             
  )                                      
  .preInstructions([computeUnitLimitTx]) 
  .accounts(<accounts>)                    
  .rpc();  

Everything works fine.

What am I missing here?

Really appreciate your help!

0

Your Answer

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

Browse other questions tagged or ask your own question.