lemooljiang avatar

NFT tokenURI的参数设计 / 学习智能合约#56

lemooljiang

Published: 07 Nov 2021 › Updated: 07 Nov 2021

NFT tokenURI的参数设计 / 学习智能合约#56

NFT主要由tokenID和tokenURI来定义,它的价值也主要来源来此。在铸造合约中也要定义好这两个值。tokenID可以设为自增,tokenURI则要自己设计好,填充好值,这样才能被OpenSea正确索引。tokenURI的格式如下所示:

{
  "name": "天天向上",
  "description": "要上好每一课",
  "external_url": "https://hive.blog/@"+author,
  "image": "https://image.com/xx.jpg",
  "attributes": [
    {
      "trait_type": "author",
      "value": author
    },
    {
      "trait_type": "hive.blog",
      "value": "https://hive.blog/@"+author+"/posts"
    },
    {
      "display_type": "date",
      "trait_type": "created",
      "value": Date.parse(new Date()) * 1e-3
    }
  ]
}

tokenURI的格式要和OpenSea的要求一致,否则没法显示。再有就是OpenSea会缓存你的图片,如果要看原图,还得去查下合约,查它的图片地址是哪个,这样才能得到原图。

https://docs.opensea.io/docs/metadata-standards

这是OpenSea的metadata的格式要求,要求一致。

这几步整好了,铸造NFT也就轻松简单了。

Leave NFT tokenURI的参数设计 / 学习智能合约#56 to:

Written by

Designer , Poet , Technology enthusiasts

Read more #smartcontract posts


Best Posts From lemooljiang

We have not curated any of lemooljiang's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From lemooljiang