EIPs Explained

ERC-7498 · Draft · ERC · 2023-07-28

ERC-7498: NFT Redeemables

A draft ERC-721/ERC-1155 extension that standardises redemption campaigns, where holders burn, transfer or update an NFT to mint a new token or claim a physical item, with on-chain discovery of the rules.

What problem does it solve?

Creators often use NFTs as entitlements: "burn this NFT to get a hoodie", "hold these two tokens to mint a new one", "use a ticket once and mark it as used". Every project builds this with its own contract logic and website, so wallets and marketplaces cannot tell what an NFT can be redeemed for, whether a campaign is live, or whether a token has already been used.

ERC-7498 defines a common interface for redemption campaigns: what you must give up, what you receive, when the campaign runs, and how off-chain orders (shipping a physical item) link to the on-chain redemption.

How it works

The NFT contract keeps a list of campaigns, created with createCampaign (IDs start at 1) and changed with updateCampaign by the campaign's manager. Each campaign has:

  • Params: startTime, endTime, maxCampaignRedemptions, manager, and an optional signer.
  • Requirements: one or more alternative sets, borrowing Seaport's vocabulary:
    • consideration: tokens the user must hand over, sent to a recipient (0x…dEaD to burn).
    • offer: tokens minted to the user. Offer contracts implement IRedemptionMintable.mintRedemption(...).
    • traitRedemptions: changes to on-chain traits via ERC-7496 Dynamic Traits: set, increment, decrement, or just check a value. This allows "mark as redeemed" without burning.

A user calls redeem(considerationTokenIds, recipient, extraData). extraData packs the campaignId, which requirement set is being satisfied, a redemptionHash (linking to an off-chain order such as a shipping request), trait token IDs and, if the campaign has a signer, a salt and an EIP-712 or ERC-1271 signature. The contract checks that the campaign is active and under its limit, performs the transfers and trait updates, mints the offer and emits Redemption.

The signer lets a shop approve a redemption first (for example, after confirming it ships to the user's country) so the NFT is not burned for an order that cannot be filled. Campaign metadata (name, images, FAQ, products) lives at a metadataURI with a defined JSON schema.

Sample code

Building extraData for a campaign with no signer (ethers v6):

import { AbiCoder, ZeroHash } from "ethers";

const campaignId = 1n;
const requirementsIndex = 0n;           // which requirement set we satisfy
const redemptionHash = ZeroHash;        // or hash of an off-chain order id
const traitRedemptionTokenIds: bigint[] = [];

const extraData = AbiCoder.defaultAbiCoder().encode(
  ["uint256", "uint256", "bytes32", "uint256[]"],
  [campaignId, requirementsIndex, redemptionHash, traitRedemptionTokenIds],
);

// Burn token #42 to redeem
await nft.redeem([42n], await signer.getAddress(), extraData);

Things to know

  • Status is Draft. Field layouts and interface IDs may still change.
  • The token must report support for interface ID 0x1ac61e13 via ERC-165; offer contracts report 0x81fe13c2 for IRedemptionMintable.
  • mintRedemption must be restricted to authorised callers (the redeemable contract), or anyone could mint offer tokens.
  • Setting manager to the zero address makes a campaign immutable.
  • For ERC-1155, a redemption applies to all amounts of a token ID unless each ID has a supply of one.

#nft #redeemables #campaigns #erc721 #erc1155

Details

Authors
Ryan Ghods (@ryanio), 0age (@0age), Adam Montgomery (@montasaurus), Stephan Min (@stephankmin)
Status
Draft
Type
Standards Track / ERC
Created
2023-07-28
Requires

Machine-readable: Markdown · JSON