• EIP-3664合约研究笔记01--项目介绍


    上周开始研究EIP3664合约,网上资料特别少,没有对合约进行分析解构的,只能自己一点点阅读,摸索设计思想和应用方法。 本文就是对合约源码中的Legoot.sol分析,记录下了合约的目的、用途、代码结构、调用流程,与721的衔接关系。

    1 Legoot项目说明

    在 2021 年的5月份,DRepublic 团队提出了一个叫做EIP-3664 的协议方案(又叫做NFT 属性扩展协议),其使用了一种较为巧妙的方式,来进一步解决了主流NFT标准比如ERC-721 或 ERC-1155等,在属性上表现力不足,NFT之间难以融合,且在存储上中心化(目前主要存储在服务器上)的种种问题,并且该提案进一步实现了NFT 属性的动态扩展。
    目前有三个基于该协议的应用,
    (1) MM3NFT( https://mm3nft.com/)  玛丽莲.梦露的组合首饰。
    (2) MetaCore( MetaCore | First Metaverse Identity) 可组合 NFT 平台 MetaCore 及基于该系统的NFT产品 Legoot。
    (3)Cradles( Cradles | Prehistoric Metaverse) 首个在GameFi领域应用EIP-3664 协议的链游,由DRepublic Labs开发。
    Legoot是一个可拆分可组合NFT项目,项目方意图成为NFT领域的积木大王“乐高(Lego)”,因此命名为Legoot。为了验证可拆分可组合特型,设计了一个游戏类的应用场景。游戏人物可以穿戴各种武器、盔甲,分别具备各种属性, 可以组合到一个NFT上,也可以单独拆分出来买卖转移。
    【MetaCore项目源码】 GitHub - ar4s-eth/MetaNFT: university project EIP3664 NFT  可以打开查看,这应该是早期的一份代码,正式的代码应该到区块链浏览器上查看。 本系列笔记就研究这份合约源码。

    2  Legoot链上情况说明--Opensea

    观察#7677号NFT,这是一个完整的Legoot,包含有8个子NFT,分别是:
                 
                "legoot #7677",
                "[weapon] Club",
                "[chest] Divine Robe of Rage",     神袍之怒 
                "[head] \"Ghoul Tear\" War Cap of Rage",   食尸鬼的战争帽之怒
                "[waist] \"Fate Sun\" Heavy Belt of the Fox",  命运太阳之重型狐狸腰带
                "[foot] Dragonskin Boots of Enlightenment",   恐龙皮靴子之启迪
                "[hand] Gloves",
                "[neck] Pendant",
                "[ring] Titanium Ring"
    这些装备的名称构造规则:   【 名称前缀_名称后缀 +  物品名 + 后缀 】 名称就是一些称号, 后缀是一些特殊性质,例如 诸神之怒,诸神之大怒,诸神之暴怒,埃拉西亚之光。 这些前缀和后缀物品很稀有,价值较高。
    Legoot项目是个纯文字描述的装备,没有对应的物品图片。这个特点正好给应用实现各种界面图片带来了完全的自由性。
    这些套装Legoot总数是8000套, 在铸造NFT时随机生成8种子装备。后面会详细说明随机算法以及概率。
    套装可以分解成单独的装备出售, 玩家购买后可以组合到自己的套装中,这样只要有钱玩家就可以组装一套氪金神装。
    这些子装备类型不同,对应不同的属性。但是各种属性的数据结构是一致的:
    【ID、Name、Suffix、NamePrefix, NameSuffix】

    3 Legoot链上情况说明- 区块链浏览器

    主合约源码可以在这里查看,可能与之前的【MetaCore项目源码】有所不同。
    在下面可以读取一些数据,查看NFT的具体数据:
    例如 读取 #7677号NFT
    获得的URI数据是Base64编码的,经过Base64解码--json格式化的结果如下:
    {
        "name":"legoot #7677",
        "description":"Legoot is the first assembly toy that can be freely disassembled and assembled any  times you want. It is a true NFT LEGO, players can freely assemble and disassemble their own legoot parts and sell each part or the whole legoot individually! Not only that, players can mount legoot to metacore for NFT digital identity purposes. This incredible capability is supported by EIP-3664.",
        "image":"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaW5ZTWluIG1lZXQiIHZpZXdCb3g9IjAgMCAzNTAgMzUwIj48c3R5bGU+LmJhc2UgeyBmaWxsOiB3aGl0ZTsgZm9udC1mYW1pbHk6IHNlcmlmOyBmb250LXNpemU6IDE0cHg7IH08L3N0eWxlPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9ImJsYWNrIiAvPjx0ZXh0IHg9IjEwIiB5PSIyMCIgY2xhc3M9ImJhc2UiPmxlZ29vdCAjNzY3NzwvdGV4dD48dGV4dCB4PSIxMCIgeT0iNDAiIGNsYXNzPSJiYXNlIj5bd2VhcG9uXSBDbHViPC90ZXh0Pjx0ZXh0IHg9IjEwIiB5PSI2MCIgY2xhc3M9ImJhc2UiPltjaGVzdF0gRGl2aW5lIFJvYmUgb2YgUmFnZTwvdGV4dD48dGV4dCB4PSIxMCIgeT0iODAiIGNsYXNzPSJiYXNlIj5baGVhZF0gIkdob3VsIFRlYXIiIFdhciBDYXAgb2YgUmFnZTwvdGV4dD48dGV4dCB4PSIxMCIgeT0iMTAwIiBjbGFzcz0iYmFzZSI+W3dhaXN0XSAiRmF0ZSBTdW4iIEhlYXZ5IEJlbHQgb2YgdGhlIEZveDwvdGV4dD48dGV4dCB4PSIxMCIgeT0iMTIwIiBjbGFzcz0iYmFzZSI+W2Zvb3RdIERyYWdvbnNraW4gQm9vdHMgb2YgRW5saWdodGVubWVudDwvdGV4dD48dGV4dCB4PSIxMCIgeT0iMTQwIiBjbGFzcz0iYmFzZSI+W2hhbmRdIEdsb3ZlczwvdGV4dD48dGV4dCB4PSIxMCIgeT0iMTYwIiBjbGFzcz0iYmFzZSI+W25lY2tdIFBlbmRhbnQ8L3RleHQ+PHRleHQgeD0iMTAiIHk9IjE4MCIgY2xhc3M9ImJhc2UiPltyaW5nXSBUaXRhbml1bSBSaW5nPC90ZXh0Pjwvc3ZnPg==",
        "attributes":[
            {
                "trait_type":"WEAPON NAME",
                "value":"Club"
            },
            {
                "trait_type":"WEAPON ID",
                "value":"69409"
            },
            {
                "trait_type":"CHEST NAME",
                "value":"Divine Robe"
            },
            {
                "trait_type":"CHEST ID",
                "value":"69410"
            },
            {
                "trait_type":"CHEST suffix",
                "value":"of Rage"
            },
            {
                "trait_type":"HEAD NAME",
                "value":"War Cap"
            },
            {
                "trait_type":"HEAD ID",
                "value":"69411"
            },
            {
                "trait_type":"HEAD suffix",
                "value":"of Rage"
            },
            {
                "trait_type":"HEAD namePrefixes",
                "value":"Ghoul"
            },
            {
                "trait_type":"HEAD nameSuffixes",
                "value":"Tear"
            },
            {
                "trait_type":"WAIST NAME",
                "value":"Heavy Belt"
            },
            {
                "trait_type":"WAIST ID",
                "value":"69412"
            },
            {
                "trait_type":"WAIST suffix",
                "value":"of the Fox"
            },
            {
                "trait_type":"WAIST namePrefixes",
                "value":"Fate"
            },
            {
                "trait_type":"WAIST nameSuffixes",
                "value":"Sun"
            },
            {
                "trait_type":"FOOT NAME",
                "value":"Dragonskin Boots"
            },
            {
                "trait_type":"FOOT ID",
                "value":"69413"
            },
            {
                "trait_type":"FOOT suffix",
                "value":"of Enlightenment"
            },
            {
                "trait_type":"HAND NAME",
                "value":"Gloves"
            },
            {
                "trait_type":"HAND ID",
                "value":"69414"
            },
            {
                "trait_type":"NECK NAME",
                "value":"Pendant"
            },
            {
                "trait_type":"NECK ID",
                "value":"69415"
            },
            {
                "trait_type":"RING NAME",
                "value":"Titanium Ring"
            },
            {
                "trait_type":"RING ID",
                "value":"69416"
            },
            {
                "trait_type":"SYNTHETIC",
                "value":"true"
            }
        ]
    }
    中间的Image数据也是Base64编码, 经过解码、转换后内容如下:
    {
        "style":".base { fill: white; font-family: serif; font-size: 14px; }",
        "rect":{
            "@width":"100%",
            "@height":"100%",
            "@fill":"black"
        },
        "text":[
            [
                "legoot #7677",
                "[weapon] Club",
                "[chest] Divine Robe of Rage",
                "[head] \"Ghoul Tear\" War Cap of Rage",
                "[waist] \"Fate Sun\" Heavy Belt of the Fox",
                "[foot] Dragonskin Boots of Enlightenment",
                "[hand] Gloves",
                "[neck] Pendant",
                "[ring] Titanium Ring"
            ],
            ""
        ],
        "@xmlns":"http://www.w3.org/2000/svg",
        "@preserveAspectRatio":"xMinYMin meet",
        "@viewBox":"0 0 350 350"
    }
    查看武器装备#69409
    解析出来的URI:
    {
        "name":"weapon #69409",
        "description":"Legoot is the first assembly toy that can be freely disassembled and assembled any  times you want. It is a true NFT LEGO, players can freely assemble and disassemble their own legoot parts and sell each part or the whole legoot individually! Not only that, players can mount legoot to metacore for NFT digital identity purposes. This incredible capability is supported by EIP-3664.",
        "image":"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaW5ZTWluIG1lZXQiIHZpZXdCb3g9IjAgMCAzNTAgMzUwIj48c3R5bGU+LmJhc2UgeyBmaWxsOiB3aGl0ZTsgZm9udC1mYW1pbHk6IHNlcmlmOyBmb250LXNpemU6IDE0cHg7IH08L3N0eWxlPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9ImJsYWNrIiAvPjx0ZXh0IHg9IjEwIiB5PSIyMCIgY2xhc3M9ImJhc2UiPndlYXBvbiAjNjk0MDk8L3RleHQ+PHRleHQgeD0iMTAiIHk9IjQwIiBjbGFzcz0iYmFzZSI+Q2x1YjwvdGV4dD48L3N2Zz4=",
        "attributes":[
            {
                "trait_type":"WEAPON NAME",
                "value":"Club"
            },
            {
                "trait_type":"WEAPON ID",
                "value":"69409"
            }
        ]
    }
    图像解析结果:
    {
        "style":".base { fill: white; font-family: serif; font-size: 14px; }",
        "rect":{
            "@width":"100%",
            "@height":"100%",
            "@fill":"black"
        },
        "text":[
            [
                "weapon #69409",
                "Club"
            ],
            ""
        ],
        "@xmlns":"http://www.w3.org/2000/svg",
        "@preserveAspectRatio":"xMinYMin meet",
        "@viewBox":"0 0 350 350"
    }
  • 相关阅读:
    基于golang的swagger超贴心、超详细使用指南【有很多坑】
    537、RabbitMQ详细入门教程系列 -【消费者Consumer(一)】 2022.08.31
    TS---类型设置
    Redis(五)发布与订阅
    vue组件
    java计算机毕业设计ssm前途招聘求职网站的设计与实现
    数组的赋值
    【OS】进程通信
    记录一次由cnpm引发的问题
    计算机毕业设计(附源码)python游戏资讯网站
  • 原文地址:https://blog.csdn.net/u012084827/article/details/127118476