Cardano NFTs, a simple howto,
by ACOL Pool,
The nice momentum when you realize how NFTs can take real benefits from Cardano.
Artists and their Digital Artwork are living now an important moment and it comes with almost no cost using Cardano, and even before Smart Contracts and Dapps, it’s already a race to be part of Cardano NFTs pioneers.
Artworks can are published combining IPFS technology and Cardano blockchain.
#CNFTs, is to be read here as: Cardano Non Fungible Token.
If you don’t feel confortable with technical aspects, you can also use our tool https://easycnft.art
(https://seb-acol-pool.medium.com/lets-talk-about-easycnft-art-800ed846ed07)
Here are basic steps and how to get it done, with simple requirements.
- Use Cardano Relay, full synched and online with the network.
- Simple way to deposit your Artwork and make it available is to use an IPFS service. You’ll se later what is important for it.
First steps
On usefull step before everything is to insert your node0.socket PATH, all depend your installation, I personaly use defaults from Guild Operators
export CARDANO_NODE_SOCKET_PATH=/opt/cardano/cnode/sockets/node0.socket
and
cardano-cli query protocol-parameters — mainnet — out-file protocol.params.json
Both above will be usefull for next steps.
You’ll need first to setup a payment keys:
cardano-cli address key-gen — verification-key-file payment.vkey — signing-key-file payment.skey
build payment address from keys:
cardano-cli address build — payment-verification-key-file payment.vkey — out-file payment.addr — mainnet
Show address:
cat payment.addr
addr1vyajnyv75j9zz6c6z6l90gvsu0ktlhuf0r2drye3tn0r2zsjkf0qq
Verify UTXo of the address
cardano-cli query utxo — address $(cat payment.addr) — mainnet
TxHash TxIx Amount
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
Send some funds to it from your fovorite wallet, Daedalus or Yoroi, wher you are probably delegating to ACOL :)
verify again what’s in your fresh wallet
cardano-cli query utxo — address $(cat payment.addr) — mainnet
TxHash TxIx Amount
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
2e8ec773c3a34b64b0e4b8928f8701ceee737e2f1e20447451da42b333b27b11 6 39000000 lovelace
the amount is always shown in lovelace (1 Ada = 1 000 000 lovelace)
Here come the CNFT setup part
Now you’ll need a policy, where you refer your policy vkey hash and define what you are looking to mint and rules to apply to it
First create policy keys
cardano-cli address key-gen — verification-key-file policy.vkey — signing-key-file policy.skey
and get the vkey hash
cardano-cli address key-hash — payment-verification-key-file policy.vkey
ce8a6654fb0680a2035eb67974074ddbaec117a865472208a4f9fb70
create then a policy.script where you refer to your vkey hash
nano policy.script
and insert your policy, (respect json writing for better reading :)
here I wanted my token to be mintable before current slot + 10000 (a slot is a second)
{
“type” : “all”,
“scripts” : [
{
“keyHash”: “ce8a6654fb0680a2035eb67974074ddbaec117a865472208a4f9fb70”,
“type”: “sig”
},
{
“type” : “before”,
“slot” : 26444410
}
]
}
now mint your token/asset
cardano-cli transaction policyid — script-file policy.script
178384e5c84a539875e94a3395ffb4de46470e4c1af8a8664303e90f
the output is to keep and use later in metadata of your token for example
nano metadata.json
and add whet you need to be in
{
“721”: {
“178384e5c84a539875e94a3395ffb4de46470e4c1af8a8664303e90f”: {
“ACOLBeeOrigin”: {
“name”: “ACOL Bee Origin”,
“image”: “ipfs://ipfs/QmPRZ7CN9scYDvQzLWev11DhgcrqpMC1Jk3y9EFi4i8CYt”,
“traits”: [
“Bee”
]
}
},
“publisher”: [
“Pool Ticker ACOL”
],
“version”: “1”
}
}
consider to store your token image or gif on ipfs, hare above I used blockfrost and adding the image by post it with curl
curl “https://ipfs.blockfrost.io/api/v0/ipfs/add" -X POST -H “project_id: YOUR_PROJECT_ID” -F “file=@./BeeACOL_1.2.3.png”
it will result with
{“name”:”BeeACOL_1.2.3.png”,”ipfs_hash”:”QmPRZ7CN9scYDvQzLWev11DhgcrqpMC1Jk3y9EFi4i8CYt”,”size”:”115698"}cardano@adarelay:~/CNFT
where the ipfs hash is needed above in the metadata file
Now come the time to build, sign and submit transaction
Let set some variables
FROM=$( cat payment.addr )
TX=$(cardano-cli query utxo — mainnet — address “$FROM” | grep “^[^- ]” | sort -k 2n | tail -1)
UTXO=$( echo “$TX” | awk ‘{ print $1 }’)
ID=$( echo “$TX” | awk ‘{ print $2 }’)
BALANCE=$( echo “$TX” | awk ‘{ print $3 }’)
INPUT=”${UTXO}#${ID}”
Transaction preparation
cardano-cli transaction build-raw — mary-era — fee 0 \
— tx-in “$UTXO”#”$ID” \
— tx-out “$FROM”+”$RESTE”+”1 178384e5c84a539875e94a3395ffb4de46470e4c1af8a8664303e90f.ACOLBeeOrigin” \
— mint=”1 178384e5c84a539875e94a3395ffb4de46470e4c1af8a8664303e90f.ACOLBeeOrigin” \
— invalid-hereafter 26444410 \
— metadata-json-file metadata.json \
— out-file tx.raw
calcul fees to submit it
FEE=$(cardano-cli transaction calculate-min-fee \
— tx-body-file tx.raw \
— tx-in-count 1 \
— tx-out-count 1 \
— witness-count 2 \
— mainnet \
— protocol-params-file protocol.params.json \
| awk ‘{ print $1}’)
Rebuild your transaction with fee
RESTE=$(( $BALANCE — $FEE ))
cardano-cli transaction build-raw — mary-era — fee “$FEE” \
— tx-in “$UTXO”#”$ID” \
— tx-out “$FROM”+”$RESTE”+”1 178384e5c84a539875e94a3395ffb4de46470e4c1af8a8664303e90f.ACOLBeeOrigin” \
— mint=”1 178384e5c84a539875e94a3395ffb4de46470e4c1af8a8664303e90f.ACOLBeeOrigin” \
— invalid-hereafter 26444410 \
— metadata-json-file metadata.json \
— out-file tx.raw
sign it
cardano-cli transaction sign \
— signing-key-file payment.skey \
— signing-key-file policy.skey \
— script-file policy.script \
— mainnet \
— tx-body-file tx.raw \
— out-file tx.signed
and submit it
cardano-cli transaction submit \
— tx-file tx.signed \
— mainnet
Verify that your token is added to your wallet
cardano-cli query utxo — mainnet — address “$FROM”
TxHash TxIx Amount
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
11f13d2438b2aa8b71c15487350ad34cc266676ea4ebb136f962777dd0b1d1dc 0 1000000 lovelace
45ee067c6620b2a701043da4ec7480d9ff07f227051744dc762e412395277f32 0 36456241 lovelace + 1 178384e5c84a539875e94a3395ffb4de46470e4c1af8a8664303e90f.ACOLBeeOrigin
go to see it on https://pool.pm/tokens
I am cooking a dedicated webpage to facilitate your CNFTs creation
and for our Delegators, some special Bee Tokens will be withdraw to their wallet.
I hope you enjoyed this reading
please econsider staking with ACOL pool.
See ACOL web site for more info.
Thanks, Bees are keys of each single days we are here :)