I'm trying to create a qr code so people can scan it and mint a cNFT. I'm using a transaction request as shown in the Solana Pay docs and using Metaplex Bubblegum for state compression. This is on Devnet for now.
My question here is that I'm signing a transaction with the authority Keypair, but the API logs return 2 signatures, and I don’t understand why...nor why a null one (the null one corresponds to the pubkey of the wallet requesting the transaction) ?!?!?!
Can someone explain to me what the problem is?
Thanks a lot :)
Here’s the relevant part of my code:
let accountField = req.body?.account;
if (!accountField) throw new Error('missing account');
const user = new PublicKey(accountField)
const authoritySecret = JSON.parse(process.env.AUTHORITY_KEY ?? "") as number[]
const authoritySecretKey = Uint8Array.from(authoritySecret)
const authority = Keypair.fromSecretKey(authoritySecretKey)
const tree = new PublicKey("ERkz...X97T");
const collectionMint = new PublicKey("3Xfk...Fvfz");
const ix = await createMintCNFTInstruction(tree, user, authority.publicKey, collectionMint);
let transaction = new Transaction();
transaction.add(ix);
const connection = new Connection(devnet url here)
const bh = await connection.getLatestBlockhash();
transaction.recentBlockhash = bh.blockhash;
transaction.feePayer = user
transaction = Transaction.from(transaction.serialize({
verifySignatures: false,
requireAllSignatures: false,
}));
transaction.sign(authority)
Here's the 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;
}
Here’s the API logs:
the transaction.signature: [
{
signature: null,
publicKey: PublicKey [PublicKey(c9M…GHK)] {
_bn: <BN: 900c8…ecce>
}
},
{
signature: <Buffer 2a b1 ... 14 more bytes>,
publicKey: PublicKey [PublicKey(E8a…pD)] {
_bn: <BN: c3189…196>
}
}
]