1

BACKEND:

    const wallet_pubkey = new PublicKey(wallet_pubkey_string);
    const wallet2 = Keypair.fromSecretKey(bs58.decode(wallet2_key));
    const amount = 0.5;
    
    const signer_wallet = createNoopSigner(fromWeb3JsPublicKey(wallet_pubkey));
    
    const umi = createUmi(rpcUrl);
    umi.use(mplTokenMetadata());
    umi.use(signerIdentity(signer_wallet))
    const umiMintSigner = generateSigner(umi);
    
    const nftData = {
        mint: umiMintSigner,
        isMutable: true,
        name: 'test',
        symbol: 'test',
        uri: url,
        sellerFeeBasisPoints: percentAmount(10,2),
        creators: creators,
        tokenOwner: fromWeb3JsPublicKey(wallet_pubkey),
    };
    const transferData = {
        destination: fromWeb3JsPublicKey(wallet2.publicKey),
        amount: sol(amount),
    };
    let transaction = await transactionBuilder()
        .add(createNft(umi, nftData))
        .add(transferSol(umi, transferData))
        .setFeePayer(signer_wallet)
        .useV0()
        .buildWithLatestBlockhash(umi);
    
    
    const web3jsVersionedTransaction = toWeb3JsTransaction(transaction);
    const web3jsVersionedTransactionSerialized = web3jsVersionedTransaction.serialize()
    const transaction_serialize_string = Buffer.from(web3jsVersionedTransactionSerialized).toString('base64');

FRONTEND:

On the frontend, the transaction is signed by the wallet wallet_pubkey.

    if (window.solana && window.solana.isPhantom) {
      try {
        const connection = new Connection(url, "confirmed");
        const transaction_array = Buffer.from(transactionBuildValue, 'base64');
        const decodedTransaction = VersionedTransaction.deserialize(transaction_array);
        const { blockhash } = await connection.getLatestBlockhash();
        decodedTransaction.recentBlockhash = blockhash;
        const signedTransaction = await window.solana.signTransaction(decodedTransaction);
        const signature = await connection.sendRawTransaction(signedTransaction.serialize());
        await connection.confirmTransaction(signature, 'processed');
        return { success: true, signature };
        console.log(signature);
      } catch (error) {
        console.error(error);
      }
    }

I get an error when trying to confirm a transaction via wallet.

Error:

> Failed to send transaction Error: Simulation failed.  Message:
> Transaction signature verification failure.

If I don't use the string .add(createNft(umi, nftData)) then the problem doesn't occur and the code works correctly.

How to fix the problem?

1 Answer 1

1

update: If you are sending the transaction to be signed on the frontend,

  1. initialize with an empty umi signer identity and the public key that's supposed to sign the transaction
umi.use(
        signerIdentity({
            publicKey: publicKey(authority),
            signTransaction: async (tx) => tx,
            signMessage: async (data) => data,
            signAllTransactions: async (txs) => txs,
        })
    );
  1. convert to web3 js and sign with the mint
let web3JsTx = toWeb3JsTransaction(transaction);

web3JsTx.sign([Keypair.fromSecretKey(umiMintSigner.secretKey)]);

let b64EncodedTx = Buffer.from(umi.transactions.serialize(fromWeb3JsTransaction(web3JsTx)).toString("base64");
3
  • 1
    Yeah, my other problem was that in creators the verified field was set to true. This was causing an additional signature error.
    – Leo Loki
    Commented Aug 20 at 12:47
  • 1
    you need to verify them one by one IIRC -> developers.metaplex.com/token-metadata/creators
    – Jimii
    Commented Aug 20 at 12:48
  • sorry, can you help with this question ? i get error when i try add updateAuthority in nftData.
    – Leo Loki
    Commented Aug 20 at 14:55

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.