简体   繁体   English

如何识别谁持有 NFT 多长时间?

[英]How to identify Who holds an NFT for how long?

I am developing an NFT collection using ERC721 token.我正在使用 ERC721 令牌开发 NFT 集合。 But I would like to know how a particular nft is held by a particular customer?但我想知道特定客户如何持有特定的 nft?

I am sensing there are two selling option one is minting fropm my website another one is buying from opensea?我感觉有两种销售选择,一种是从我的网站铸造另一种是从 opensea 购买?

Is that any way I can do that?这是我能做到的吗?

The ERC-721 contract uses this mapping(uint256 => address) private _owners; ERC-721 合约使用这个mapping(uint256 => address) private _owners; to store the owner.存储所有者。 If you want to keep track of how long an address has holded a particular NFT you can create a struct如果您想跟踪地址持有特定 NFT 的时间,您可以创建一个结构

struct Owner {
  address ownerAddress;
  uint256 sinceWhen;
}

You then need to modify some functions (like mint , transfer , ...) and you set the sinceWhen as the block.timestamp .然后,您需要修改一些函数(如minttransfer等)并将sinceWhen设置为block.timestamp

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

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