Error while minting tokens using cardano-cli

Hi,

I have successfully minted a token on cardano testnet. Now I am trying to mint more of that token using the same script. But I am facing error while submitting the transaction. I want to know is it possible to mint same token more after the initial mint. Here I am using time bound before script to allow me to mint more tokens before given slot number.

policy.script -

echo "{" >> policy/policy.script 
echo " \"scripts\": [" >> policy/policy.script 

echo "{" >> policy/policy.script 
echo "  \"keyHash\": \"$(cardano-cli address key-hash --payment-verification-key-file policy/policy.vkey)\"," >> policy/policy.script 
echo "  \"type\": \"sig\"" >> policy/policy.script 
echo "}," >> policy/policy.script


echo "{" >> policy/policy.script
echo "  \"slot\": 86969600," >> policy/policy.script 
echo "  \"type\": \"before\"" >> policy/policy.script 
echo "}" >> policy/policy.script

echo "]," >> policy/policy.script
echo "  \"type\": \"all\"" >> policy/policy.script 
echo "}" >> policy/policy.script
1 Like

What’s the error message you are receiving ? And could you give more details as to what exactly you are doing, the steps?

1 Like

Error message-

Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 99816547 (fromList [(PolicyID {policyID = ScriptHash “6bff6873aceab4ff4ab0d876aa3c926675679a490d6cd6505cc82e3d”},fromList [(“FifthTesttoken”,20000000)])])) (Value 99816547 (fromList [(PolicyID {policyID = ScriptHash “6bff6873aceab4ff4ab0d876aa3c926675679a490d6cd6505cc82e3d”},fromList [(“FifthTesttoken”,10000000)])])))))])

Details -
I want to mint a token with a time bound. Means till particular time period you should be able to mint more of the same token. And after that period you cannot mint.

So, it tells you that you have more of your tokens in the inputs than in the outputs.

I would guess that there already tokens on the --tx-in that you consume and then you --mint some more. The amount in --tx-out then has to be the sum of both amounts.

Hi @HeptaSean ,

This is my transaction build command -

cardano-cli transaction build-raw \
 --fee $fee \
 --tx-in $txhash#$txix \
 --tx-out $address+$output+"$tokenamount $policyid.$tokenname1" \
 --mint="$tokenamount $policyid.$tokenname1" \
 --minting-script-file policy/policy.script \
 --out-file matx.raw \
 --invalid-hereafter 56842706

Do I need to make any changes in this when I mint for the second time?
Please help me what changes I should make according to you.

When you do the cardano-cli query utxo step, it should tell you that there are already tokens on the UTxO that you later use in –tx-in $txhash#$txix.

Those have to be included in the --tx-out.

The minimal fix according to your original post would be:

cardano-cli transaction build-raw \
–fee $fee \
–tx-in $txhash#$txix \
–tx-out $address+$output+"20000000 $policyid.$tokenname1" \
–mint="10000000 $policyid.$tokenname1" \
–minting-script-file policy/policy.script \
–out-file matx.raw \
–invalid-hereafter 56842706

I.e.: Just replace the $tokenamount variable with the concrete amounts needed in this case.

Hi @HeptaSean ,

Thanks for your reply. It really helped.

Now I am trying to burn the minted 20000000 tokens, using the command -

cardano-cli transaction build-raw \
 --fee $burnfee \
 --tx-in $txhash#$txix \
 --tx-out $address+$burnoutput+"10000000 $policyid.$tokenname1" \
 --mint="-10000000 $policyid.$tokenname1" \
 --minting-script-file policy/policy.script \
 --out-file burning.raw

But it is throwing an error -

Command failed: transaction submit Error: Error while submitting tx: ShealidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedEraFailure (ScriptWitnessNotValidatingUTXOW (fromList [ScriptHash “e808235ce75d9ac5c3f7f274955cb57c5617dedc0365a00ab”])))])

Can you guide me where am I going wrong? I am performing burn after the time period for minting is over.

This is the main cause for the error. Usually, it means that you forgot to sign with one of the needed keys, but …

… this could also be the reason. If the slot in the policy is over, you can neither mint nor burn.

Thanks @HeptaSean .

I am trying to burn tokens within time period using -

cardano-cli transaction build-raw \
 --fee $burnfee \
 --tx-in $txhash#$txix \
 --tx-out $address+$burnoutput+"19000000 $policyid.$tokenname1" \
 --mint="-10000000 $policyid.$tokenname1" \
 --minting-script-file policy/policy.script \
 --out-file burning.raw

But getting error -

Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (ScriptWitnessNotValidatingUTXOW (fromList [ScriptHash “27e7865b907c3c9595e36834b09b3e3131769a45f9c0e1a985c5c4d9”])))])

As said:

Did you sign with both, the payment key belonging to the --tx-in and the policy key belonging to the hash in the policy script?