Skip to main content
2 of 4
Added a detailed example
georgeos
  • 1.7k
  • 6
  • 17

You can find good examples here:

Here is another example to calculate fees when minting an NFT:

  • UTxO Lovelace = 200000000
  1. Build transaction without fees: specify your UTxO and your NFT related files
cardano-cli transaction build-raw \
  --fee 0 \
  --tx-in 722f716a16286dfaf21925e7f7013f2e8248223ed8f04b455c9a745751a4c6d9#0 \
  --tx-out $(cat key1/payment.addr)+200000000+"1 $(cat policy.id).mynft" \
  --mint="1 $(cat policy.id).mynft" \
  --minting-script-file policy.json \
  --metadata-json-file metadata.json \
  --invalid-hereafter=40590754 \
  --out-file transaction.raw
  1. Calculate min fee: specifying the number of TxIn's, TxOut's and witness count (in this case it's 2 because there'll be two signing keys in the Sign transaction step)
cardano-cli transaction calculate-min-fee \
  --tx-body-file transaction.raw \
  --tx-in-count 1 \
  --tx-out-count 1 \
  --witness-count 2 \
  --testnet-magic 1097911063 \
  --protocol-params-file protocol-params.json
  • Min fee: 194541 Lovelace
  • Change: 200000000 - 194541 = 199805459
  1. Build final transaction: using calculated fees and change
cardano-cli transaction build-raw \
  --fee 194541 \
  --tx-in 722f716a16286dfaf21925e7f7013f2e8248223ed8f04b455c9a745751a4c6d9#0 \
  --tx-out $(cat key1/payment.addr)+199805459+"1 $(cat policy.id).mynft" \
  --mint="1 $(cat policy.id).mynft" \
  --minting-script-file policy.json \
  --metadata-json-file metadata.json \
  --invalid-hereafter=40593754 \
  --out-file transaction.raw
  1. Sign the transaction
cardano-cli transaction sign \
  --signing-key-file key1/payment.skey \
  --signing-key-file policy.skey \
  --testnet-magic 1097911063 \
  --tx-body-file transaction.raw \
  --out-file transaction.signed
  1. Submit the transaction
cardano-cli transaction submit \
  --tx-file transaction.signed \
  --testnet-magic 1097911063
georgeos
  • 1.7k
  • 6
  • 17