Fatal Error while running calculate-min-value "TODO alonzo: runTxCalculateMinValue"

I’m running into this error while trying to do a fee calculation for a smartcontract tx, in particular spending the UTxO of the smart contract plutus script:

cardano-cli: FatalError {fatalErrorMessage = "TODO alonzo: runTxCalculateMinValue using new protocol params"}

Here is the python function I’m using when this error is generated (also it doesn’t kill my tx, just seems I can’t predetermine the fee):

def calculate_min_value(tmp, token_string):
    func = [
        tmp + 'protocol.json',
    p = subprocess.Popen(func, stdout=subprocess.PIPE).stdout.read().decode('utf-8')
        p.split(' ')[1].replace('\n', '')
    except IndexError:
        p = 2000000
    return p

For reference, the above python script (transactions.py) and the related smart contract source code along with the cabal.project file I used to compile (I’m using based on the 1.29.0 cardano-node cabal file), etc are at my git here:

cardano-cli transaction build (not build-raw) will automatically compute the fee and it works for 1.29.0.

Yeah it’s been working regardless the error, I’ll need to rework the python script a bit it seems to eliminate this.

1 Like

were you able to fix the error? I am trying to calculate the minimum ada amount to be sent along with other tokens. I get the same error as the one you posted. I cant find any solution on the web.

Not looked at it since, and since it wasn’t really stopping me. Per @bwbush reply, it isn’t necessary to do the build-raw if using build, etc. My plan is to rewrite the python scripts to avoid this.

I’m running into this same problem. Has anyone found a solution? I switched to using “cardano-cli transaction build” and see that it automatically calculates the fee but when wanting to mint or transfer NFTs I haven’t found a way to get it to automatically calculate the minimum ada value.

Previously I was using “cardano-cli transaction calculate-min-required-utxo” with version 1.30.0 but that has been removed from version 1.30.1. With version 1.30.1 and “cardano-cli transaction calculate-min-value” I get the same error as above.

can you paste your transaction framework here for your build-raw and your fee calc both?

I currently have something like this using “build”, I thought if I leave the ADA value off --tx-out for the NFT being transferred but build command will automatically calculate it.

cardano-cli transaction build --alonzo-era --tx-in 6a412006e9abf24bdcaa41bf8eb0f9367115491bbe7c97e243c4dde8fd66a7a4#1 --tx-out “addr_test1vzwyk8nwfh5esy09z79nzyxe69y8u5wdx60vgxsnu0w0q7cxqx50m+1 3d6d8a031b309c0181be1c618a9762fee47bf1e28646bc7dab63ecdb.TNx003x0001x1” --change-address addr_test
1qz85m8qms55jw0vf8lvxkl6ae5c47cv27vvak5glrc0pqc575v3zsngxtma9ul5efvwuut80dsgqv76zdu8fc72472hs9g4yk6 “–mint=1 3d6d8a031b309c0181be1c618a9762fee47bf1e28646bc7dab63ecdb.TNx00
3x0001x1” --minting-script-file policy/testnet/tn_policy1.script --metadata-json-file nft/testnet/tn_series_3/nft_metadata/nft_merged_metadata_1634703158.json --invalid-her
eafter 46811097 --out-file transaction/mint_nft_external_unsigned_tx --protocol-params-file testnet_protocol_parameters.json --testnet-magic 1097911063

Fails with: Error: Minimum UTxO threshold not met for tx output: addr_test1vzwyk8nwfh5esy09z79nzyxe69y8u5wdx60vgxsnu0w0q7cxqx50m + 1 3d6d8a031b309c0181be1c618a9762fee47bf1e28646bc7dab63ecdb.TNx003x0001x1

So my guess that “build” would set the minimum ADA value is wrong.

I previously had this working using “build-raw”, but having no such luck anymore since calculate-min-required-utxo has been removed and calculate-min-value isn’t working.

I made that same assumption, here’s a script I created and just used yesterday to mint with a known fee which does not kick any errors…(it’s still a little rough but I’ll clean it up as I’m able/have time)…you then just need to sign and send, just remember to sign with 2 witnesses, your wallet and your policy skey file:

read -p 'Minting Wallet: ' MINT_ADDR
read -p 'Token Name: ' nftName
read -p 'Token Qty: ' tknQTY
read -p 'Slot: ' nftSlot

mintAddr=$(cat wallets/${MINT_ADDR}.addr) # the answer to Minting Wallet should be the filename of a file ending in .addr residing in a wallets folder inside this folder, and it only contains the wallets address.  Same wallet should have an skey and vkey file by the same wallet name in the same wallets folder for these scripts to work

LOGFOLDER=logs/payments # optional, keep files clean and log them in a logs folder in this folder
TIMESTAMP=`date "+%Y-%m-%d_%H-%M-%S"`

# Get UTxO
$CARDANO_CLI query utxo \
    --address ${mintAddr} \
    --testnet-magic ${TESTNET_MAGIC_NUM} > fullUtxo.out
tail -n +3 fullUtxo.out | sort -k3 -nr > balance.out
cat balance.out
while read -r utxo; do
    in_addr=$(awk '{ print $1 }' <<< "${utxo}")
    idx=$(awk '{ print $2 }' <<< "${utxo}")
    utxo_balance=$(awk '{ print $3 }' <<< "${utxo}")
    echo TxHash: ${in_addr}#${idx}
    echo ADA: ${utxo_balance}
    tx_in="${tx_in} --tx-in ${in_addr}#${idx}"
done < balance.out
txcnt=$(cat balance.out | wc -l)
echo Total ADA balance: ${total_balance}
echo Number of UTXOs: ${txcnt}
echo TXIn: ${tx_in}
newbal=$((${total_balance}-4000000)) # <-- subtracting the 2 following instances of token utxos
# Draft the tx
$CARDANO_CLI transaction build-raw \
    ${tx_in} \
    --tx-out ${mintAddr}+${newbal} \
    --tx-out ${mintAddr}+2000000+"1 some_other_already_mintedTokenID.NAME" \
    --tx-out ${mintAddr}+2000000+"${tknQTY} $(cat nativetokens/${nftName}.id).${nftName}" \
    --invalid-hereafter 0 \
    --fee 0 \
    --mint="${tknQTY} $(cat nativetokens/${nftName}.id).${nftName}" \
    --minting-script-file nativetokens/${nftName}.script \
    --metadata-json-file nativetokens/${nftName}.json \
    --alonzo-era \
    --out-file tx_nft.tmp

# Calculate the fee
fee=$($CARDANO_CLI transaction calculate-min-fee \
    --tx-body-file tx_nft.tmp \
    --tx-in-count ${txcnt} \
    --tx-out-count 3 \ # <-- make sure your count is accurate
    --witness-count 2 \
    --testnet-magic ${TESTNET_MAGIC_NUM} \
    --protocol-params-file params.json | awk '{ print $1 }')
echo fee: $fee
txOut=$((${total_balance}-${fee}-4000000)) # again, account for the 2 (or other) tx-outs
echo Change Output: ${txOut}

# Build the TX
echo "=========================="
echo "....Building for: ${tx_in}"
echo "=========================="
echo ""
$CARDANO_CLI transaction build-raw \
    ${tx_in} \
    --tx-out ${mintAddr}+${txOut} \
    --tx-out ${mintAddr}+2000000+"1 some_other_already_mintedTokenID.NAME" \
    --tx-out ${mintAddr}+2000000+"${tknQTY} $(cat nativetokens/${nftName}.id).${nftName}" \
    --invalid-hereafter ${nftSlot} \
    --fee ${fee} \
    --mint="${tknQTY} $(cat nativetokens/${nftName}.id).${nftName}" \
    --minting-script-file nativetokens/${nftName}.script \
    --metadata-json-file nativetokens/${nftName}.json \
    --alonzo-era \
    --out-file tx_nft.raw

mv fullUtxo.out $LOGFOLDER/${TIMESTAMP}_fullUtxo.out
mv balance.out $LOGFOLDER/${TIMESTAMP}_balance.out
mv tx_nft.tmp $LOGFOLDER/${TIMESTAMP}_tx_nft.tmp
cp tx_nft.raw $LOGFOLDER/${TIMESTAMP}_tx_nft.raw
echo ""
echo "===== Finished ====="
echo "Get and Move tx_nft.raw file to Cold for signing"
echo ""    

and to sign it is something like this:

read -p 'Signing Wallet: ' WALLET_NAME
$CARDANO_CLI transaction sign \
    --tx-body-file tx_nft.raw \
    --signing-key-file wallets/${WALLET_NAME}.skey \
    --signing-key-file wallets/policy.skey \
    --testnet-magic ${TESTNET_MAGIC_NUM} \
    --out-file tx_nft.signed
rm tx_nft.raw
echo ""
echo "===== Finished ====="
echo "move tx_nft.signed back to node for sending!"

where wallets/policy.skey is your policy skey file whereever it lives. Then just send the resulting file using something like this:

TIMESTAMP=`date "+%Y-%m-%d_%H-%M-%S"`
$CARDANO_CLI transaction submit \
    --tx-file tx_nft.signed \
    --testnet-magic ${TESTNET_MAGIC_NUM}
mv tx_nft.signed $LOGFOLDER/${TIMESTAMP}_tx_nft.signed
echo ""
echo "======= Finished ======"
echo "TX Sent! Check for errors ^"
echo ""