To follow the lecture you need a 100% sync node, follow the steps in lesson 3 that you find here

Send funds for minting

Inside our folder excerise01 we should send some funds to the wallet we built in the last lesson that you can find here.

The address can be shown with the command

cat payment.addr

Create the policy keys

To create the key to control the policyid we will use the command:

cardano-cli address key-gen --verification-key-file policy.vkey --signing-key-file policy.skey

we need to get also the key hash and we get it with:

cardano-cli address key-hash --payment-verification-key-file policy.vkey

let’s take note of the output, we will use it in the minting script

Create the policy script

let’s open the editor and create the script:

nano policy.script

and then:


"keyHash":
"HASHOFOURPOLICY",
"type":"sig"

Let’s save and close with “CTRL+S CTRL+X”

Get the policyID of the NFT

To get the policy instead it is enough to run the following command:

cardano-cli transaction policyid --script-file policy.script

And the output is the policyid our nft will have

Create the metadata

The metadata is the content of the NFT, to create it we just write the command:

nano metadata.json

and inside the editor

{
"721":
{
"POLICYID":
{
"assetname_you_wish":
{
"name":"My first NFT"
"image":"ipfs://QmVxruSdQHiiwRStw8WE52siqpvYYAuDFaSsaXqYRTmW88"
}
}
}
}

let’s save and close the editor with “CTRL+S CTRL+X”

how do you get the IPFS hash?

easy, upload your file to https://app.pinata.cloud/

Mint the NFT

Let’s get the funds transaction hash with

cardano-cli query utxo --mainnet --address $(cat payment.addr)

let’s build the transaction

cardano-cli transaction build-raw --fee 0 --tx-in HASHOFFUNDS#INDEXFUNDS --tx-out $(cat payment.addr)
+0+"1 policyidwegotbefore.assetname_you_wish" --mint="1 policyidwegotbefore.assetname_you_wish" --script-file policy.script
--json-metadata-no-schema --metadata-json-file metadata.json --out-file matx.raw

Now we can evaluate the fee as shown in lesson 3

cardano-cli transaction calculate-min-fee --tx-body-file matx.raw --tx-in-count 1 --tx-out-count 1 --witness-count 2 --mainnet --protocol-params-file protocol.json

and we get the fee to mint, as you see the minting fee is really low

let’s rewrite again the transaction with the actual fee:

cardano-cli transaction build-raw --fee fee_we_got --tx-in HASHOFFUNDS#INDEXFUNDS --tx-out $(cat payment.addr)+balance_before_minus_fee+"1 policyidwegotbefore.assetname_you_wish" --mint="1 policyidwegotbefore.assetname_you_wish" --script-file policy.script --json-metadata-no-schema --metadata-json-file metadata.json --out-file matx.raw

Sign and mint the nft

Finally we can sign the transaction with

cardano-cli transaction sign --signing-key-file payment.skey --signing-key-file policy.skey --mainnet --tx-body-file matx.raw --out-file matx.signed

and

cardano-cli trasaction submit --tx-file matx.signed  --mainnet

And we have just minted our first NFT!

Support the project

You can support our videos and development you can check one of our NFT project:

@jurassikchained 10k onchain dinos
@cardano_waifus 1/1 waifus that can change background
@fabul_art   Interactive 3D art Fabergè eggs