Chào các bạn, chắc hản các bạn đang rất hype và thích thú về trends NFT gần đây. Thực tế thì NFT không phải là trend (xu thế) nữa, mà NFT đã/đang đựoc áp dụng rộng rãi vào đời sống thực tế , cụ thể là phát hành tranh số, nhạc số, sách số …
Nội dung của bài viết này sẽ huớng dẫn bạn cách đúc (mint) 1 NFT (1ADA) của 1 bức hình (đuợc lưu theo IPFS) trên nền Cardano
- Yêu cầu đầu tiên: bạn phải là chủ (owner) sở huữ 1 pool, vì tại thời điểm viết bài này, thì cardano chưa support smart contract cho nên đây là điều kiện tiên quyết
- Tạo policy, tất nhiên đây là policy của pool bạn, với policy do bạn phát hành và chưa có smart contract, thì việc bạn đúc NFT thành công vẫn chưa huớng đến tính decentralize mà Cardano huớng đến. anw, chúng ta cứ làm truớc đón đầu vậy
- Tạo key cho policy
cardano-cli address key-gen –verification-key-file policy.vkey –signing-key-file policy.skey
- Tạo policy
- Tạo key cho policy
touch policy.script && echo "" > policy.script
echo "{" >> policy.script
echo " \"keyHash\": \"$(cardano-cli address key-hash --payment-verification-key-file policy.vkey)\"," >> policy.script
echo " \"type\": \"sig\"" >> policy.script
echo "}" >> policy.script
cat policy.script
{
"keyHash": "5805823e303fb28231a736a3eb4420261bb42019dc3605dd83cccd04",
"type": "sig"
}
> Lấy policy id cardano-cli transaction policyid --script-file policy.script > 677d3bbe3e01eeab498cd8786f7d261d92bd6ecea12109a332e86374 policy id trên đc dùng để mint token bên duới theo cú pháp --mint="1 677d3bbe3e01eeab498cd8786f7d261d92bd6ecea12109a332e86374.AhaXuPic002"
- Truy vấn lịch sử giao dịch
cardano-cli query utxo –address xxxxxxx –mainnet
xxxxxxx là địa chỉ vi của pool của bạn
kết quả truy vấn:
TxHash TxIx Amount2244c6b9011dbdf6e4139f56a252eadfa6744a21b221662d18dc05xxxxxxxxxx 0 385445197 lovelace + 1 8a7ab85ce0533d7ad7d6f8f120eb4486f9c69ab2261825xxxxxxxxxx.AHAXU01
47da69657fa1d6c740e0b5001431e577c3310e50cc6441a3661a6exxxxxxxxxx 0 5000000 lovelace
…
- Upload hình ảnh/ nội dung cần đúc NFT lên nền tảng IPFS
- https://docs.blockfrost.io/#tag/IPFS-Add 100 MB free
- https://pinata.cloud/documentation#GettingStarted 1GB free Free đủ xài
Đây là bức hình đuợc uploaded lên ipfs qua blockfrost
https://ipfs.blockfrost.dev/ipfs/QmYA9R8Z1TjaWYhgGHDYbYJmqPfioxznvqvXsKj4ANBJ9f
- Chuẩn bị file json cho bức hình bạn sẽ đúc (mint)
{
file json mẫu
“6868”: {
“8a7ab85ce0533d7ad7d6f8f120eb4486f9c69ab226182557cf2ee2f2”: {
“AhaXuPic002”: {
“image”: “ipfs://QmfNeaNfgooYtVFcB1SXjmttnSB87UzURwwdEoRrBcEcxg”,
“latitude”: “18.3698441”,
“longitude”: “105.8503294”,
“name”: “KyAnhBeach”,
“description”: “My lovely hometown beach – Ky Xuan, Ky Anh, Ha Tinh, Vietnam”
}
}
}
}
- Build draft transaction có kèm metadata
cardano-cli transaction build-raw \
build draft transaction
–fee 0 \
–tx-in xxxxb9de515023e84cc3b75efc5e08b3682df040e6a5fc8ce3ca87bf1cxxxx#0 \
–tx-out $(cat payment.addr)+0+”1 xxxx85ce0533d7ad7d6f8f120eb4486f9c69ab226182557cf2xxxx.AhaXuPic002″ \
–mint=”1 xxxx85ce0533d7ad7d6f8f120eb4486f9c69ab226182557cf2xxxx.AhaXuPic002″ \
–metadata-json-file AhaXuPic002.json \
–out-file AhaXuPic002.raw
- Tính fee
Giả sử tôi chọn tnx input này
47da69657fa1d6c740e0b5001431e577c3310e50cc6441a3661a6exxxxxxxxxx 0 5000000 lovelace
cardano-cli transaction calculate-min-fee \
output ví dụ:
–tx-body-file AhaXuPic002.raw \
–tx-in-count 1 \
–tx-out-count 1 \
–witness-count 2 \
–mainnet \
–protocol-params-file protocol.json
123456 Lovelace là fee
expr 5000000 – 123456
–> 4876544 số tiền đựoc cộng vào cho tx-out
- Build lại transaction có fee (+ kèm theo meta data json)
cardano-cli transaction build-raw \
build lại raw message
–mary-era \
–fee 123456 \
–tx-in xxxxxb9de515023e84cc3b75efc5e08b3682df040e6a5fc8ce3ca87bf1cxxxx#0 \
–tx-out $(cat payment.addr)+4876544+”1 xxxxx85ce0533d7ad7d6f8f120eb4486f9c69ab226182557cf2xxxxx.AhaXuPic002″ \
–mint=”1 8xxxxx5ce0533d7ad7d6f8f120eb4486f9c69ab226182557cf2xxxxx.AhaXuPic002″ \
–metadata-json-file AhaXuPic002.json \
–out-file AhaXuPic002.raw
- Ký transaction
cardano-cli transaction sign \
ký transaction
–signing-key-file payment.skey \
–signing-key-file policy.skey \
–script-file policy.script \
–mainnet \
–tx-body-file AhaXuPic002.raw \
–out-file AhaXuPic002.signed
- Submit transaction
cardano-cli transaction submit –tx-file AhaXuPic002.signed –mainnet
- Và, tận huởng cảm giác khi đúc đuợc NFT đầu tiên 😉
- Tài liệu tham khảo
- https://cardano-ledger.readthedocs.io/en/latest/explanations/features.html
- https://developers.cardano.org/en/development-environments/native-tokens/multi-asset-tokens-explainer/
- https://silas-stulz.medium.com/you-want-to-create-your-own-nft-heres-how-you-do-it-on-the-cardano-blockchain-9a0bbf8caa39
Giới thiêu về các NFTs đựoc đúc bởi AhaXu
link: https://pool.pm/stake1u8axvsqt8y8qrr98nmtucyz6qtatvmckkuq43xav4hh43ucvwua2c
Chúc các bạn may mắn! Hãy delegate và ủng hộ AHA pool nhé! link bài viết hướng dẫn ở đây.
Lưu ý: bài huớng dẫn này trên mainnet, bạn hãy cản thận khi thực hành và dùng số luợng là 1ADA để thử nghiệm nếu cần 😉