Cardano-cli: how to use the --mint option?

playing around with the minting example from the Alonzo-testnet repository, once compiled I realized I have no idea on how to interact with it from the cli

trying to construct a transaction as follows

cardano-cli transaction build \
--alonzo-era \
--protocol-params-file path/to/protocol-parameters.json \
--tx-in <mint-script-address utxo (or is it optional when minting?)> \
--mint {"map":{"k":{"bytes": "<policy>"}, "v": {"map":{"k":{"string": "tokenName"},"v":{"int": 1000 }}}}} \
--mint-script-file path/to/minting-policy-purple.plutus \
--mint-redeemer-file mint-redeemer.json \
--tx-in-collateral <payment.addr utxo> \
--change-address $(cat path/to/payment.addr) \
--$testnet \
--out-file tx.raw

where mint-redeemer.json is just a simple constructor:

	"constructor": 0,
	"fields": []

so my questions are:

  • do I need a --tx-in when minting?
  • what is VALUE in the --mint option?
  • how is --mint-redeemer-file's FILE supposed to look like?

just to be clear, the second question is due to the fact that running the above command I get the following error message

option --mint: 
unexpected "{"
expecting multi-asset value expression

I assumed a multiasset value expression is similar to the Value definition in Plutus; meaning it should be

Map (CurrencySymbol,  ( Map ( TokenName, Amount ) )

I don’t know much about Plutus, but without Plutus the --mint option takes arguments of the form "<amount> <policy-id>.<assetname in hex>" with multiple assets separated by +. I suppose it’s the same in your case.

I’m not an expert on minting by any means, but I’ll add to @HeptaSean’s answer for your other questions. Also, there is an example of a cardano-cli mint transaction by Lars Bruenjes here. Lobster challenge mint script

so my questions are:

do I need a --tx-in when minting?

Yes, you’ll need a --tx-in to pay for the transaction. If you are using a Plutus policy script that requires validation, you’ll also need a --tx-in-collateral argument. On the other hand, if your mint transaction is using a time lock policy script (e.g. policy allows minting before slot 123), then no collaral is needed, since there is no need to run a Plutus script validation for this type of mint.

what is VALUE in the --mint option?

It represents the asset being minted as @HeptaSean described.

how is --mint-redeemer-file 's FILE supposed to look like?

For an empty redeemer object, instead of --mint-redeemer-file, you can also use --mint-redeemer-value and pass in json of empty array, e.g. []. Otherwise, I think your file contents should work.