1

I got this answer


Hey @notdanilo! Solana Pay transaction requests can work for any Solana transaction, so as long as you can do it in a single transaction it'll work.

If you're struggling to write such a transaction then please ask your question on solana.stackexchange.com - that's the best way to get help with things like this. You won't need to narrow your question to Solana Pay there, so should be able to get help from a much wider group of people. Thanks! :)

https://github.com/solana-labs/solana-pay/issues/209

But I couldn't find any way to do it in the docs.

2 Answers 2

2

Update: here is a minimal example of how you can mint nfts using Solana Pay

Here is the solana-pay-scaffold repo that you can reference to get started. Specifically, you can reference this file under /src/pages/api/transaction.ts.

At a high-level, you can think of a Solana Pay transaction request as any other transaction on Solana. In other words, you can create a transaction and add multiple instructions to the transaction.

In the transaction.ts file you'll find a transaction with a single SOL transfer instruction. You can just as easily create two SOL transfer instructions and add them to the same transaction.

  // Create any transaction
  const transaction = new Transaction({
    feePayer: account,
    blockhash,
    lastValidBlockHeight,
  });

  const transferInstruction = SystemProgram.transfer({
    fromPubkey: account,
    toPubkey: Keypair.generate().publicKey,
    lamports: LAMPORTS_PER_SOL / 1000,
  });

  // Add reference as a key to the instruction
  // This allows us to listen for this transaction
  transferInstruction.keys.push({
    pubkey: reference,
    isSigner: false,
    isWritable: false,
  });

  transaction.add(transferInstruction);

The comment to your question above is suggesting that you can build a transaction which mints multiple nfts by including multiple instructions in the transaction.

If you are unfamiliar with how tokens (and nfts) work on Solana, it may be helpful to check out the metaplex docs

You can then reference the scripts in day of recent Solana Pirate bootcamp for how to build transactions with instructions to mint tokens.

0

Is it possible to do-or-make cNFTs i.e. multiple NFTs regarding the above SINGLE QR Solana Pay code ? transfer createMintCNFTInstruction function.

async function createMintCNFTInstruction(merkleTree: PublicKey, user: PublicKey, authority: PublicKey, collectionMint: PublicKey) {

const [treeAuthority, _bump] = PublicKey.findProgramAddressSync(
    [merkleTree.toBuffer()],
    BUBBLEGUM_PROGRAM_ID,
);

const [collectionMetadataAccount, _b1] = PublicKey.findProgramAddressSync(
    [
        Buffer.from("metadata", "utf8"),
        TOKEN_METADATA_PROGRAM_ID.toBuffer(),
        collectionMint.toBuffer(),
    ],
    TOKEN_METADATA_PROGRAM_ID
);

const [collectionEditionAccount, _b2] = PublicKey.findProgramAddressSync(
    [
        Buffer.from("metadata", "utf8"),
        TOKEN_METADATA_PROGRAM_ID.toBuffer(),
        collectionMint.toBuffer(),
        Buffer.from("edition", "utf8"),
    ],
    TOKEN_METADATA_PROGRAM_ID
);

const [bgumSigner, __] = PublicKey.findProgramAddressSync(
    [Buffer.from("collection_cpi", "utf8")],
    BUBBLEGUM_PROGRAM_ID
);

const tix = await createMintToCollectionV1Instruction({
    treeAuthority: treeAuthority,
    leafOwner: user,
    leafDelegate: user,
    merkleTree: merkleTree,
    payer: user,
    treeDelegate: authority,
    logWrapper: SPL_NOOP_PROGRAM_ID,
    compressionProgram: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
    collectionAuthority: authority,
    collectionAuthorityRecordPda: BUBBLEGUM_PROGRAM_ID,
    collectionMint: collectionMint,
    collectionMetadata: collectionMetadataAccount,
    editionAccount: collectionEditionAccount,
    bubblegumSigner: bgumSigner,
    tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID,
}, {
    metadataArgs: {
        collection: { key: collectionMint, verified: false },
        creators: [],
        isMutable: true,
        name: "NameHere",
        primarySaleHappened: true,
        sellerFeeBasisPoints: 0,
        symbol: "CAS",
        uri: "https://shdw-drive.genesysgo.net/....json",
        uses: null,
        tokenStandard: TokenStandard.NonFungible,
        editionNonce: null,
        tokenProgramVersion: TokenProgramVersion.Original
    }
});
return tix;

}

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.