0

I'm working on a Solana-based NFT minting project using Candy Machine and I'm encountering a Transaction signature verification failure error when sending transactions from my backend to frontend. Could someone help me identify and resolve this issue?

I've tried following this answer here but in no luck:

Accept payment, mint specific NFT to user's wallet using Metaplex (but not candymachine)

Here's a brief overview of my setup:

Backend code:

"use server";
import {
  mintV2,
  fetchCandyMachine,
  CandyMachine,
  mplCandyMachine,
} from "@metaplex-foundation/mpl-candy-machine";
import {
  createTokenIfMissing,
  setComputeUnitLimit,
} from "@metaplex-foundation/mpl-toolbox";
import {
  transactionBuilder,
  generateSigner,
  createNoopSigner,
  signerIdentity,
  createSignerFromKeypair,
} from "@metaplex-foundation/umi";
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { publicKey } from "@metaplex-foundation/umi";

import {
  fetchMetadataFromSeeds,
  Metadata,
} from "@metaplex-foundation/mpl-token-metadata";
import bs58 from "bs58";
import { env } from "@/env";
export const doMintV2 = async () => {
  
  const minter = createNoopSigner(publicKey(feePayer));

  const umi = createUmi(rpcURL).use(mplCandyMachine());

  const s = bs58.decode(SECRETKEY);
  const k = umi.eddsa.createKeypairFromSecretKey(s);
  const backendSigner = createSignerFromKeypair(umi, k);
  umi.use(signerIdentity(backendSigner));

  const candyMachinePublicKey = publicKey(candyMachineId);
  const candyMachine = await fetchCandyMachine(umi, candyMachinePublicKey);
  // Generate keypair for the mint
  const nftMint = generateSigner(umi);
  const collectionMetadata = await fetchMetadataFromSeeds(umi, {
    mint: candyMachine.collectionMint,
  });
  // Build the mint function
  const builder = transactionBuilder()
    .add(setComputeUnitLimit(umi, { units: 800_000 }))

    .add(
      mintV2(umi, {
        minter,
        candyMachine: candyMachine.publicKey,
        candyGuard: candyMachine.mintAuthority,
        // Auto creates mint account if nftMint is a signer
        nftMint: nftMint,
        collectionMint: candyMachine.collectionMint,
        collectionUpdateAuthority: collectionMetadata.updateAuthority,
        tokenStandard: candyMachine.tokenStandard,
        mintArgs: {
          solPayment: {
            destination: publicKey(treasury),
          },
        },
      })
    );
  const ix = builder.getInstructions();
  const blockhash = await umi.rpc.getLatestBlockhash();

  const tx = umi.transactions.create({
    version: 0,
    payer: backendSigner.publicKey,
    instructions: ix,
    blockhash: blockhash.blockhash,
  });
  const signedTx = await backendSigner.signTransaction(tx);
  const serializedTx = umi.transactions.serialize(signedTx);
  return { tx: bs58.encode(serializedTx) };
};

Frontend code:

// umi uses WalletAdapterIdentity
const deserialized = umi.transactions.deserialize(base58.decode(tx));
// Get the user to sign the transaction
const signedTx = await umi.identity.signTransaction(deserialized);
const signature = await umi.rpc.sendTransaction(signedTx);

Error Message: failed to send transaction: Transaction signature verification failure

Any insights into what might be causing this issue and how to fix it would be greatly appreciated! Thank you!

Edit 1: We don't really need backend transaction signing (But we need to create the transaction on the backend), tried removing the backendSigner and still doesn't work and throws the same error

2
  • You may want to dump the full transaction to see which signature might be incorrect or invalid. My hunch is that the noop signer might be causing the problem, but I could also be misunderstanding how umi works.
    – Jon C
    Commented May 20 at 12:04
  • I will try checking the transaction and see which accounts or keypairs are labeled as signers. The noop signature shouldn't really cause any error as it is the same as the wallet signing it on the front end.
    – Shahid H.
    Commented May 21 at 4:36

0

Your Answer

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