I followed Minting NFTs | Cardano Developer Portal lately and if I understood that correctly, you don’t need to calculate fees and remaining outputs by hand, anymore, in newer versions of cardano-cli.
I just gave the output that I want to have a specific value and a --change-address for the rest and it works automatically.
Also did not need any protocol parameter JSON file.
Hi yes third time around I did the tutorial again. It does work have to be very very careful not to miss anything I really not sure how the fees work I know the input and output amounts have to be equal. Now I have got this to work once am I able to replicate it ? I need to mint a native token tonight preferably on main net, any up for assisting ?
Anyway heres the output of the succesful transaction on test net
It’s not a whole stage that is missing. It’s more single steps that are not necessary, are done differently. They use the (newer?) cardano-cli transaction build instead of the (old?) cardano-cli transaction build-raw.
So, the whole process:
tokenname="MyToken"
tokenbase16=$(echo $tokenname | basenc --base16)
amount=1000000
cardano-cli address key-gen --verification-key-file payment.vkey --signing-key-file payment.skey
paymentaddr=$(cardano-cli address build --payment-verification-key-file payment.vkey --testnet-magic 109791106)
targetaddr="<The address the minted token should go to, can be $paymentaddr>"
echo $paymentaddr
# Put some tADA in this address!
cardano-cli query utxo --address $paymentaddr --testnet-magic 1097911063
txhash="<The hash from the output above>"
txix="<The index from the output above>"
cardano-cli address key-gen --verification-key-file policy.vkey --signing-key-file policy.skey
echo "{" > policy.script
echo " \"type\": \"sig\"," >> policy.script
echo " \"keyHash\": \"$(cardano-cli address key-hash --payment-verification-key-file policy.vkey)\"" >> policy.script
echo "}" >> policy.script
policyid=$(cardano-cli transaction policyid --script-file policy.script)
output=0
cardano-cli transaction build \
--testnet-magic 1097911063 \
--alonzo-era \
--tx-in $txhash#$txix \
--tx-out $targetaddr+$output+$amount\ $policyid.$tokenbase16 \
--change-address $paymentaddr \
--mint $amount\ $policyid.$tokenbase16 \
--minting-script-file policy.script \
--witness-override 2 \
--out-file matx.raw
# This will probably say that output is too low and give you the minimum output.
output=<This minimum output>
# And the same command again:
cardano-cli transaction build \
--testnet-magic 1097911063 \
--alonzo-era \
--tx-in $txhash#$txix \
--tx-out $targetaddr+$output+$amount\ $policyid.$tokenbase16 \
--change-address $paymentaddr \
--mint $amount\ $policyid.$tokenbase16 \
--minting-script-file policy.script \
--witness-override 2 \
--out-file matx.raw
# Now, there should be no errors.
cardano-cli transaction sign \
--testnet-magic 1097911063 \
--signing-key-file payment.skey \
--signing-key-file policy.skey \
--tx-body-file matx.raw \
--out-file matx.signed
cardano-cli transaction submit --testnet-magic 1097911063 --tx-file matx.signed
Hope, this works. The minted tokens and the small output amount should show up in the target address, the remaining ADA should go back to the payment address. As you can see, there’s no calculation of fees or something like that.
Nope, NFTs are also just tokens. To the network, they are surprisingly similar.
What do you mean? Minting can be done with any node. You can even use the one running in Daedalus.
You mean modifying the policy so that it only allows minting/burning for a short period of time? It’s just an additional key in the policy script. Look at the NFT guide.
Thanks so much that looks like a minting script which could be run in bash ?
My Testnet node is synced when I run Mainnet it does not sync. I have recently installed Daedalus Mainnet its syncing as we speak. So is it possible to run cardano-cli while Daedalus is open and run to Mainnet from terminal or does Daedalus run scripts like you posted ? That would be amazing
The Time Locking looking to do 12 months token lock so after 12 months not sure how that translates into slots / epoch units ?
I just put every command together that I was entering on the shell. But, sure, a script is not much more. But, when writing a script, it should be made a little more comfortable.
First sync probably takes hours, but not syncing at all sounds strange.
While Daedalus is running, there is a cardano-node running in the background. We can connect to that. If cardano-cli is installed outside, it just needs to know the socket, the node inside is running at (don’t know if it matters if the versions don’t match). Otherwise, I can (at least on Linux) enter the system running in the background of Daedalus and use the cardano-cli installed there. No, Daedalus – the graphical interface – cannot run scripts or something like that.
One slot is one second, basically. So, you look at the current tip with cardano-cli query tip --mainnet (for mainnet) or cardano-cli query tip --testnet-magic 1097911063 and add 365Ă—24Ă—60Ă—60=31536000 to get a slot in 12 months.
Oh, sorry for that! I switched from xxd used in the Cardano tutorial to basenc, because the latter was installed on my Arch and the NixOS running inside Daedalus by default, while xxd was not. Seems that on Ubuntu, it is exactly the other way round. (Ah, Ubuntu tends to ship a very old version of coreutils, no basenc, just base32 and base64, which doesn’t help, because we need base16.)
The “threshold not met for tx” message should have a second line: “Minimum required UTxO: Lovelace XXXXXX”
The “XXXXXXX” is the value that is needed for output=.
If you want to mint additional tokens and the policy still allows it, only the cardano-cli transaction build, cardano-cli transaction sign and cardano-cli transaction submit steps are necessary again.
You, of course, have to fill the variables in there again, but you should under no circumstances repeat the cardano-cli address key-gen steps (it would overwrite the keys of the first run, leaving you without access to the Ada in the payment address and/or minting or burning with the policy keys).
They are really not that different. NFTs have time lock and metadata and are typically unique or at least very low numbers, but some people do a very liberal time lock on their NFTs (making the “NF” a bit questionable) and you could also give time lock and metadata for “normal” tokens. So, the difference starts to boil down to if you mint 1, 10 or 10000 of them.
I don’t think you can. Once something is in your wallet, the protocol allows you to do everything with it including resale.
Perhaps, it would be possible to design a Plutus contract that will only send the tokens to the buyers after several months. You could and should time lock the script itself, then, so that people can be sure that it will happen. And even then, I don’t know if people would like that idea.
Yes your most probably right theres general ethics to consider
Just so I am clear on your procedure for minting tokens.
All the code executed now I understood about Output value
Did you see that question about meta data ?
I am wondering how I add the IPFS image I would think its
–metadata-json-file metadata.json in the transaction build right ?
One more …
What address are the tokens now in and can you give me an example of how to transfer that to a deadalus testnet wallet I gather that means building a a new transaction
Yes, I saw and shortly answered it. Yes, it is --metadata-json-file metadata.json. And you would, of course, need to create that metadata.json file beforehand. The relevant standard, how that should look like, is: https://github.com/cardano-foundation/CIPs/tree/master/CIP-0025
They are in that address. It tells you with the values after the +s. First is always ADA/tADA/Lovelace and the rest are other tokens.
A wallet app would decode the base16-encoded token names after the .s for you.
On the one hand, that’s why I included the targetaddr= part in my process. I like to send them immediately to my wallet during minting to safe that extra transaction.
On the other hand:
txhash="ab83c7b35e91e81f511897c667d923fb7bbb0c4d79bb71098a7b5c4849adf55e"
txix="0"
targetaddr="<whereever you want to send>"
output=0
cardano-cli transaction build \
--testnet-magic 1097911063 \
--alonzo-era \
--tx-in $txhash#$txix \
--tx-out $targetaddr+$output+$amount\ $policyid.$tokenbase16 \
--change-address $paymentaddr \
--out-file send.raw
# Should fail again, because output is zero, but tell you what to set output to.
output=<whatever it tells you>
cardano-cli transaction build \
--testnet-magic 1097911063 \
--alonzo-era \
--tx-in $txhash#$txix \
--tx-out $targetaddr+$output+$amount\ $policyid.$tokenbase16 \
--change-address $paymentaddr \
--out-file send.raw
cardano-cli transaction sign \
--testnet-magic 1097911063 \
--signing-key-file payment.skey \
--tx-body-file send.raw \
--out-file send.signed
cardano-cli transaction submit --testnet-magic 1097911063 --tx-file send.signed
This is just the same, but without the minting. So we don’t need --mint, --minting-script-file and --witness-override and we only sign with payment.skey, but not with policy.skey anymore.
If you want to send multiple times, you will have to look at cardano-cli query utxo before every send. The UTXOs change when sending.