Mint 2 NFTs per transaction

I am trying to mint 2 NFT per transaction and the transaction build code looks like this:

cmd.runSync([
    `${CARDANO_CLI} transaction build`,
    CARDANO_NETWORK_TYPE,
    CARDANO_ERA,
    `--tx-in ${utxo}#${txid}`,
    `--tx-out ${sender_address}+${minimum_lovelace}+"1 ${policy_id}.${hashed_token_name}"`,
    `--change-address ${SEND_CHANGE_TO_ADDRESS}`,
    `--mint="1 ${policy_id}.${hashed_token_name}"`,
    `--minting-script-file ${_account}/policy/policy.script`,
    `--metadata-json-file ./_nft/metadata/${metadata_pathname}`,
    `--invalid-hereafter ${slot_number}`,
    `--witness-override 2`,
    `--out-file ${_account}/tx/matx.raw`
  ].join(" "));

My question is about this line here --metadata-json-file ./_nft/metadata/${metadata_pathname}
Is it possible to include this line more than once and have more than one metadata file attached to the build query or how would go about combining 2 metadata files to be able to send 2 nfts in one transaction?

Yes, you can mint as many NFTs in one transaction, as long as you don’t go over the transaction limit (16 KB). You can take a look on a cardano blockchain explorer at some NFTs from known series and see how the metadata looks like when you mint multiple NFTs in one transaction.

Thank you, do you know of any known NFT series that have multiple mints as an example?

We had an example in an eatlier discussion:

Oh thank you very much and doing it like this won’t mess up the metadata of the individual NFT? Like how does that look on pool.pm or on JPG Store? Are all the traits correct on each NFT?

No, it won’t, each NFT has its own unique name.

So would the following query work for minting 2 nfts in one transaction or would I get an error?

cmd.runSync([
    `${CARDANO_CLI} transaction build`,
    CARDANO_NETWORK_TYPE,
    CARDANO_ERA,
    `--tx-in ${utxo}#${txid}`,
    `--tx-out ${sender_address}+${minimum_lovelace}+"1 ${policy_id}.${first_hashed_token_name}"+"1 ${policy_id}.${second_hashed_token_name}"${batched_tokens}`,
    `--change-address ${SEND_CHANGE_TO_ADDRESS}`,
    `--mint="1 ${policy_id}.${first_hashed_token_name}"`,
    `--mint="1 ${policy_id}.${second_hashed_token_name}"`,
    `--minting-script-file ${_account}/policy/policy.script`,
    `--metadata-json-file ./_nft/metadata/tempMetadat.json`,
    `--invalid-hereafter ${slot_number}`,
    `--witness-override 2`,
    `--out-file ${_account}/tx/matx.raw`
  ].join(" "));

It should be something like this, but this one will fail. On the --tx-out line you included the ${batched_tokens} 2 times.

So if I have batched tokens in there just once it should work? I’ve edited it above, please take a look.

I cannot tell if it will work or not, you need to test it. I never used the library you seem to use.
Ideally you should test on Preview or Preprod, and when you are satisfied with the result, then do it on mainnet.