简体   繁体   English

NFT 是否可以拥有基于智能合约变量值更新的元数据?

[英]Can an NFT have metadata that updates based on smart contract variable values?

Can someone please explain the specifics of how NFT metadata is stored (both on and off chain examples?) and how it's called by apps like Opensea or Decentlraland?有人可以解释一下 NFT 元数据是如何存储的(链上和链下示例?)的细节,以及 Opensea 或 Decentlraland 等应用程序如何调用它?

Additionally, would it be especially challenging to utilize dynamic metadata for an NFT, which updates regularly based on changing smart contract variables, which themselves change due to user interactions with the smart contracts?此外,将动态元数据用于 NFT 是否会特别具有挑战性,它会根据不断变化的智能合约变量定期更新,而这些变量本身会因用户与智能合约的交互而发生变化? Eg imagine an updatable "Countdown" NFT where the jpeg shows a picture of the integer "days until X", which updates each day as time passes but can also updated based on changing X in the NFT smart contacts... made this up on the spot but actually an interesting idea?例如,想象一个可更新的“倒计时”NFT,其中 jpeg 显示整数“直到 X 天”的图片,随着时间的推移每天更新,但也可以根据 NFT 智能联系人中 X 的变化进行更新......现场,但实际上是一个有趣的想法? :) :)

Is this doable?这是可行的吗? Are there storage challenges?是否存在存储挑战? Do apps call metadata repeatedly or would they call it once and never reflect updates?应用程序是重复调用元数据还是调用一次就从不反映更新?

From my understanding you generally set a baseURI in a erc721 contract.根据我的理解,您通常会在 erc721 合同中设置 baseURI。 And then if you have an auto incrementing token id.然后,如果您有一个自动递增的令牌 ID。 The first token will be the baseURI plus "1".第一个标记将是 baseURI 加“1”。

In other words: baseURI: "https://myserver.com/api/metadata", tokenId: 1换句话说:baseURI: "https://myserver.com/api/metadata", tokenId: 1

the token metadata is hosted at https://myserver.com/api/metadata/1令牌元数据托管在https://myserver.com/api/metadata/1

And that takes some storage off the chain, if every token has it's own unique url it adds a bit of unnecessary junk to the chain.这会占用链上的一些存储空间,如果每个令牌都有自己唯一的 url,则会向链中添加一些不必要的垃圾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM