1. 摘要
Tezos链是一条比较小众的公链,国内的技术人员相对比较少。本文作为该公链的第一批中国开发者,以图文并茂的形式介绍如何在Tezos链上发布ERC721资产。
2. 内容
8.4.1 修改配置参数
Moz-Token_FA2.py:
def environment_config():
...
non_fungible = global_parameter("non_fungible", True),
8.4.2 部署合约
部署的合约地址:KT1UWH1SCBTPjoMmTNjGg3iPpBT9UM7bzBGg
https://smartpy.io/explorer.html?address=KT1UWH1SCBTPjoMmTNjGg3iPpBT9UM7bzBGg
Save Contract: NFT@MOZIK
查看Storage的信息在线metadata:
https://tqtezos.github.io/TZComet/#/explorer%3Fgo%3Dtrue%26explorer-input%3DKT1UWH1SCBTPjoMmTNjGg3iPpBT9UM7bzBGg
8.4.3 设置合约的metadata
[1] 目前函数的metadata默认如下,不需要修改。
<1> 其中 ipfs://Qmf6tjsd7kwHESMJhCLYNHF7j6AdGNmtnBrcVC4aS87YwL 转成16进制
网址:https://www.sojson.com/hexadecimal.html
<2> 对应信息:
{
"name": "Mozik",
"description": "Music, Dream & Value",
"version": "",
"interfaces": [
"TZIP-12",
"TZIP-16",
"TZIP-21"
]
}
[2] 如需要修改,参考“8.3 发布ERC20资产”的"[4] Set metadata"进行操作即可。
8.4.4 mint发行NFT
[1] 10个token id = 0;
Address:tz1c4Zma1UmkEfwmEsqYdMcVpFauhNCeKY3U
Amount:10
Metadata: , 0x697066733a2f2f516d5950764e4e317843715a747864475766583458716233454e567170624659723872596a773867794454746b4d
Token_id: 0
[2] 1个token id = 1;
Address:tz1c4Zma1UmkEfwmEsqYdMcVpFauhNCeKY3U
Amount:1
Metadata: , 0x697066733a2f2f516d5950764e4e317843715a747864475766583458716233454e567170624659723872596a773867794454746b4d
Token_id: 1
[3] Token_id: 999
告警信息:
Error while sending transaction to contract: Token-IDs should be consecutive RPC_ParseError (please see the console)undefined
token_id要连续,不要断层。
8.4.5 发布Joseph的NFT
[1] 需求描述
<1> 对应信息:制作成文件 joseph_wooten_token_meta_data.json,然后在https://pinata.cloud/pinmanager上传文件。
定义参考:https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-21/tzip-21.md#example-2
{
"decimals": 0,
"name": "Everything’s Gon Be Alright",
"description": "1. Meet and greet Joseph Wooten and the artists before the concert.
Get a personally autographed copy of Joseph’s book “It All Matters”.
2. Two Front Row tickets to one of two special live NFT concerts by Joseph Wooten and the Hands of Soul on September 11th, 2021, at Rudy’s Jazz Room, Nashville TN. An eclectic, warm and cozy venue. (With Special Guest Artists).
3. Unique Digital artwork limited to 1,086 copies. A Portrait of Joseph Wooten by Kary Lee.
4. Pre-release song limited to 1,086 copies. “Everything’s Gon Be Alright.” The song will not be available for general release until after the live NFT Concert.
",
"creators": ["Joseph Wooten"],
"date": "2021-07-06T20:00:00",
"type": "Pre-release song limited to 1,086 copies and Two Front Row tickets",
"language": "en",
"shouldPreferSymbol": true,
"thumbnailUri": "ipfs://QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
}
IPFS查看方法:
(1) JSON METADATA
https://gateway.pinata.cloud/ipfs/QmYkTgdDpEwwyq3jynAB22Xs4HEAjRgfpjZPsLPmq5ezgr
ipfs://QmYkTgdDpEwwyq3jynAB22Xs4HEAjRgfpjZPsLPmq5ezgr
其对应的16进制编码如下:
0x697066733a2f2f516d596b54676444704577777971336a796e414232325873344845416a526766706a5a50734c506d7135657a6772
(2) 缩略图
https://gateway.pinata.cloud/ipfs/QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF
ipfs://QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF
或者
https://ipfs.io/ipfs/QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF
[2] MINT发布NFT
<1> 发布NFT TOKEN DI:2
Address: tz1c4Zma1UmkEfwmEsqYdMcVpFauhNCeKY3U
Amount: 1
Metadata: , 0x697066733a2f2f516d596b54676444704577777971336a796e414232325873344845416a526766706a5a50734c506d7135657a6772
Token_id: 2
<2> 继续发布 token id : 3
制作成文件 token_meta_data.json,然后在https://pinata.cloud/pinmanager上传文件。
{
"name": "Everything’s Gon Be Alright",
"symbol": "NFT@MOZIK",
"decimals": 0,
"isBooleanAmount": false,
"description": "Meet and greet Joseph Wooten and the artists before the concert.",
"creators": ["Joseph Wooten"],
"type": "song",
"language": "en",
"shouldPreferSymbol": true,
"artifactUri": "ipfs://QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"displayUri": "ipfs://QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"thumbnailUri": "ipfs://QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"externalUri": "https://gateway.pinata.cloud/ipfs/QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF"
}
链接:https://gateway.pinata.cloud/ipfs/QmNmtzsVTY41Hv9FndyoY83TFXzhXQEtvFx2AteQdyr1tq
ipfs://QmNmtzsVTY41Hv9FndyoY83TFXzhXQEtvFx2AteQdyr1tq
对应的16进制编码:0x697066733a2f2f516d4e6d747a735654593431487639466e64796f5938335446587a68585145747646783241746551647972317471
<3> 继续发布 token id : 4
采用推荐的
{
"decimals": 0,
"isBooleanAmount": true,
"name": "Carnival Asada",
"description": "Meet and greet Joseph Wooten and the artists before the concert.",
"minter": "tz1c4Zma1UmkEfwmEsqYdMcVpFauhNCeKY3U",
"creators": ["Joseph Wooten"],
"date": "2020-11-13T00:00:00+00:00",
"type": "Digital Taco",
"tags": ["CryptoTaco", "taco", "collectibles"],
"language": "en",
"artifactUri": "ipfs://QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"displayUri": "ipfs://QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"thumbnailUri": "ipfs://QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"externalUri": "https://gateway.pinata.cloud/ipfs/QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"formats": [
{
"uri": "https://gateway.pinata.cloud/ipfs/QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"hash": "40cd59179c5fe2be194bf3bb37b7af7a21ba098b37b1098c01911f382075211f",
"mimeType": "mage/jpeg",
"dimensions": {
"value": "300x300",
"unit": "px"
}
}
],
"attributes": [
{
"name": "filling",
"value": "carne asada"
},
{
"name": "shell",
"value": "double corn tortilla"
},
{
"name": "salsa",
"value": "mango"
},
{
"name": "garnish",
"value": "pickled red onion"
},
{
"name": "secret sauce",
"value": "ghost pepper"
},
{
"name": "rarity",
"value": "epic"
}
]
}
在线文件SHA356算法:http://www.metools.info/code/c92.html
对应的l:https://gateway.pinata.cloud/ipfs/Qmbx6PbpoCceTqSHeNnyXpzymAbwxzv5qSRQVenA2GrK11
ipfs://Qmbx6PbpoCceTqSHeNnyXpzymAbwxzv5qSRQVenA2GrK11
对应的16进制编码:0x697066733a2f2f516d6278365062706f43636554715348654e6e7958707a796d416277787a76357153525156656e413247724b3131
结论:采用推荐的在temple钱包显示正确的名称和ICON。
<3> 继续发布 token id : 5, 6
{
"decimals": 0,
"isBooleanAmount": true,
"symbol": "NFT@MOZIK",
"name": "Everything’s Gon Be Alright",
"description": "Meet and greet Joseph Wooten and the artists before the concert.",
"minter": "tz1c4Zma1UmkEfwmEsqYdMcVpFauhNCeKY3U",
"creators": ["Joseph Wooten"],
"date": "2021-07-07T00:00:00+00:00",
"type": "Song",
"tags": ["NFT", "MOZIK", "Joseph Wooten"],
"language": "en",
"artifactUri": "ipfs://QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"displayUri": "ipfs://QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"thumbnailUri": "ipfs://QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"externalUri": "https://gateway.pinata.cloud/ipfs/QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"formats": [
{
"uri": "https://gateway.pinata.cloud/ipfs/QmVqM6iVTd7QGFYxM4utojBj7Crb1Z5QTTup1xZhLLAEXF",
"hash": "40cd59179c5fe2be194bf3bb37b7af7a21ba098b37b1098c01911f382075211f",
"mimeType": "mage/jpeg",
"dimensions": {
"value": "300x300",
"unit": "px"
}
}
]
}
在线文件SHA356算法:http://www.metools.info/code/c92.html
5> 对应的l:https://gateway.pinata.cloud/ipfs/QmRX8rEaSVMQmtynVNNcXhLikmRtJfy625AJfZoTz4oKvT
ipfs://QmRX8rEaSVMQmtynVNNcXhLikmRtJfy625AJfZoTz4oKvT
对应的16进制编码:0x697066733a2f2f516d52583872456153564d516d74796e564e4e6358684c696b6d52744a6679363235414a665a6f547a346f4b7654
6>对应的链接:https://gateway.pinata.cloud/ipfs/QmY97XyAyUed8fM8KwJTwzoVNXaSBEnSpRNfMBMU6gfxTd
ipfs://QmY97XyAyUed8fM8KwJTwzoVNXaSBEnSpRNfMBMU6gfxTd
对应的16进制编码:0x697066733a2f2f516d5939375879417955656438664d384b774a54777a6f564e58615342456e5370524e664d424d55366766785464
<3> 合约信息
metadata存储:
https://better-call.dev/florencenet/KT1UWH1SCBTPjoMmTNjGg3iPpBT9UM7bzBGg/storage
操作:
https://better-call.dev/florencenet/KT1UWH1SCBTPjoMmTNjGg3iPpBT9UM7bzBGg/operations
TOKENS:
https://better-call.dev/florencenet/KT1UWH1SCBTPjoMmTNjGg3iPpBT9UM7bzBGg/tokens
【问题】在tokens列表中看不到NFT资产,钱包也不能显示个性化信息。原因应该是使用了 "shouldPreferSymbol": true。这个是FT资产使用的标识。
8.4.6 Temple增加TOKEN
NFT TOKEN自动显示出来了。
3. 参考
(1) 智能合约在线编辑器 https://smartpy.io/ide
(2) smartpy智能合约参考文档 https://smartpy.io/reference.html