2

I am generating a transaction on the backend to create an NFT. I would like to add a signer and send this transaction on the frontend. How do I do this?

3 Answers 3

1

1st step: you create your transaction in the backend with your instructions.

2nd step: you sign your transaction with your wallet in your backend (with transaction.partialSign(walletProvider);)

3rd step: you serialize and base64 encode your transaction with const serializedTransaction = transaction.serialize({requireAllSignatures: false}); and const base64Transaction = serializedTransaction.toString('base64');

4th step: you get back your transaction in the frontend and decode it, with const transaction = Transaction.from(Buffer.from(backendResponse.transaction, 'base64'))

then in the frontend you can use your transaction object (sign it with a wallet, etc)

4
  • I am using a versioned transaction and that is failing
    – Jimii
    Commented Sep 29, 2023 at 8:28
  • i never tried with a versioned transaction, only classic transaction... but i guess there must be a solution for versioned transaction too. What is your error ?
    – Effe2
    Commented Sep 29, 2023 at 13:59
  • I am missing a signature. I am creating a mint ix on the backend. Here, the mint keypair signs the tx. on the frontend when trying to use sign, it fails. My best guess is that maybe the mint signature is being invalidated but that shouldn't be the case.
    – Jimii
    Commented Sep 29, 2023 at 15:19
  • which signature are you missing ? try console log your transaction, and check "signatures" in it, which one(s) are null ?
    – Effe2
    Commented Sep 29, 2023 at 23:19
0

As per my understanding, To create and send a transaction for creating an NFT on the Solana blockchain from the front end, you'll need to perform several steps. Here's an overview of the process:

Set Up Your Development Environment: Ensure you have the necessary tools and libraries installed. You'll need Solana's JavaScript SDK, a wallet library like @solana/wallet-adapter, and a frontend framework of your choice (e.g., React).

Generate a Wallet: Users need a wallet to sign and send transactions. You can use @solana/wallet-adapter to create a wallet instance.

Connect to Solana Network: Initialize a connection to the Solana network using the SDK.

Create and Sign the Transaction: Construct a transaction that includes the necessary instructions for creating the NFT. This might involve interacting with a smart contract or a specific program on the Solana blockchain. Sign the transaction with the user's wallet.

Send the Transaction: Send the signed transaction to the Solana network using the Solana SDK. This will broadcast the transaction to the network.

Here is Solana web3.js ref link and Solana wallet adapter demo link.

Hope this will help you!

-1

This is not possible via the backend.

You need to integrate the web3 libraries on the front end to get the transaction popup.

The backend can only sign the transaction via the wallet private key stored locally, it doesn't require any UI.

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.