EIPs Explained

ERC-6806 · Draft · ERC · 2023-03-30

ERC-6806: ERC-721 Holding Time Tracking

A draft ERC-721 extension that reports who currently holds an NFT and for how many seconds, so apps can reward long-term holders without an indexer.

What problem does it solve?

Projects often want to reward people who have held an NFT for a long time: extra airdrops, access to content, or other perks. Standard ERC-721 only knows who owns a token right now, not since when. Today this usually means scanning transfer events off-chain.

ERC-6806 adds one read function so contracts and apps can get holding time directly from the token.

How it works

The whole interface is one function:

interface IERC6806 {
    function getHoldingInfo(uint256 tokenId)
        external view returns (address holder, uint256 holdingTime);
}

It returns the current holder and how long, in seconds, that account has held the token.

The holder is returned separately from ownerOf on purpose. An implementation may choose to ignore some owners when tracking time. For example, if an NFT is deposited into a lending contract as collateral, that contract can be skipped, so the real owner keeps accumulating holding time. The reference implementation does this with an owner-managed allow-list: transfers to or from listed addresses do not reset the clock.

Sample code

An OpenZeppelin v5 version of the idea (the spec's reference uses the older _afterTokenTransfer hook):

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

contract HoldTimeNFT is ERC721, Ownable {
    mapping(uint256 => address) private _holder;
    mapping(uint256 => uint256) private _since;
    mapping(address => bool) public ignored; // e.g. escrow / lending contracts

    constructor() ERC721("Hold", "HOLD") Ownable(msg.sender) {}

    function mint(address to, uint256 id) external onlyOwner { _mint(to, id); }

    function setIgnored(address a, bool v) external onlyOwner { ignored[a] = v; }

    function _update(address to, uint256 id, address auth) internal override returns (address from) {
        from = super._update(to, id, auth);
        if (ignored[from] || ignored[to]) return from;
        if (_holder[id] != to) {
            _holder[id] = to;
            _since[id] = block.timestamp;
        }
    }

    function getHoldingInfo(uint256 id) external view returns (address holder, uint256 holdingTime) {
        return (_holder[id], block.timestamp - _since[id]);
    }
}

Reading it (ethers v6):

const [holder, seconds] = await nft.getHoldingInfo(42n);
const days = Number(seconds) / 86_400;

Things to know

  • Status: Draft. It may change or stall.
  • Holding time is based on block.timestamp, which block producers can shift slightly; do not use it where exact precision matters.
  • The spec does not define what happens for burned or never-minted tokens; check the implementation.
  • An ignore/allow-list is powerful: whoever controls it decides which transfers count. Make that role trustworthy.
  • Holding time can be gamed by holding with one wallet and selling the wallet's control off-chain; treat it as a signal, not proof of loyalty.
  • For time-limited use rights rather than ownership history, see ERC-4907 rental NFTs.

#nft #erc-721 #holding-time #loyalty #extension

Details

Authors
Saitama (@saitama2009), Combo <[email protected]>, Luigi <[email protected]>
Status
Draft
Type
Standards Track / ERC
Created
2023-03-30
Requires

Machine-readable: Markdown · JSON