EIPs Explained

ERC-6672 · Final · ERC · 2023-02-21

ERC-6672: Multi-redeemable NFTs

An ERC-721 extension that records on-chain redemptions per operator, token and campaign, so one NFT can be redeemed many times for different physical or digital perks.

What problem does it solve?

NFTs are often used as vouchers: hold the NFT, claim merchandise, a ticket or a discount. Most redemption schemes are one-shot (a single "redeemed" flag per token) or entirely off-chain, so a second brand or a second campaign cannot reuse the same NFT, and there is no shared record of what has been claimed.

ERC-6672 lets the same NFT be redeemed in multiple scenarios, for example an online concert, then exclusive merch, then a meet-and-greet, with each redemption tracked on-chain.

How it works

A redemption is keyed by three values:

  • _operator: the address running the redemption (a brand, event organizer, shop).
  • _tokenId: the NFT being redeemed.
  • _redemptionId: a bytes32 chosen by the operator to identify a campaign.

The interface (ERC-165 ID 0x4dddf83f) adds:

Function / event Purpose
redeem(redemptionId, tokenId, memo) Mark a redemption; operator is msg.sender
cancel(redemptionId, tokenId, memo) Undo a redemption created by the same operator
isRedeemed(operator, redemptionId, tokenId) Check the flag
getRedemptionIds(operator, tokenId) List an operator's redemptions for a token
Redeem / Cancel events Indexable history, including the redeemer

Because the operator is always msg.sender, an operator can only touch its own redemptions; two operators can run independent campaigns on the same NFT.

An optional metadata extension lets tokenURI JSON include a redemptions object keyed operator-tokenId-redemptionId, each with a free-form status (e.g. redeemed, paid, shipping) and description.

Sample code

Minimal operator-scoped redemption logic on top of OpenZeppelin ERC721:

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

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

contract RedeemableTicket is ERC721 {
    event Redeem(address indexed _operator, uint256 indexed _tokenId, address redeemer, bytes32 _redemptionId, string _memo);
    event Cancel(address indexed _operator, uint256 indexed _tokenId, bytes32 _redemptionId, string _memo);

    mapping(address => mapping(uint256 => mapping(bytes32 => bool))) private _redeemed;
    mapping(address => mapping(uint256 => bytes32[])) private _ids;

    constructor() ERC721("Ticket", "TKT") {}

    function isRedeemed(address op, bytes32 rid, uint256 tokenId) external view returns (bool) {
        return _redeemed[op][tokenId][rid];
    }

    function getRedemptionIds(address op, uint256 tokenId) external view returns (bytes32[] memory) {
        return _ids[op][tokenId];
    }

    function redeem(bytes32 rid, uint256 tokenId, string calldata memo) external {
        address owner = _requireOwned(tokenId);
        require(!_redeemed[msg.sender][tokenId][rid], "already redeemed");
        _redeemed[msg.sender][tokenId][rid] = true;
        _ids[msg.sender][tokenId].push(rid);
        emit Redeem(msg.sender, tokenId, owner, rid, memo);
    }

    function cancel(bytes32 rid, uint256 tokenId, string calldata memo) external {
        require(_redeemed[msg.sender][tokenId][rid], "not redeemed");
        _redeemed[msg.sender][tokenId][rid] = false;
        emit Cancel(msg.sender, tokenId, rid, memo);
    }
}

Things to know

  • Status: Final.
  • Redemption flags must be strictly scoped to msg.sender. A buggy implementation that lets one operator update another's flags would allow cancelling other campaigns. The spec also recommends keeping redeem/cancel separate from ERC-721 approvals.
  • The standard records that a redemption happened, not who is allowed to redeem. Eligibility checks (is the caller the holder, did they sign a request?) are up to the operator's off-chain or on-chain logic.
  • Redemption status persists across transfers. Buyers on a secondary market should check isRedeemed for the campaigns they care about.

#nft #erc721 #redemption #commerce #extension

Details

Authors
RE:DREAMER Lab <[email protected]>, Archie Chang (@ArchieR7) <[email protected]>, Kai Yu (@chihkaiyu) <[email protected]>, Yonathan Randyanto (@Randyanto) <[email protected]>, Boyu Chu (@chuboyu) <[email protected]>, Boxi Li (@boxi79) <[email protected]>, Jason Cheng (@JasonCheng0729) <[email protected]>
Status
Final
Type
Standards Track / ERC
Created
2023-02-21
Requires

Machine-readable: Markdown · JSON