ERC-5507: Refundable Tokens

Adds refund functionality to ERC-20, ERC-721, and ERC-1155 tokens


Metadata
Status: FinalStandards Track: ERCCreated: 2022-08-19
Authors
elie222 (@elie222), Gavin John (@Pandapip1)

Abstract


This ERC adds refund functionality for initial token offerings to ERC-20, ERC-721, and ERC-1155. Funds are held in escrow until a predetermined time before they are claimable. Until that predetermined time passes, users can receive a refund for tokens they have purchased.

Motivation


The NFT and token spaces lack accountability. For the health of the ecosystem as a whole, better mechanisms to prevent rugpulls from happening are needed. Offering refunds provides greater protection for buyers and increases legitimacy for creators.

A standard interface for this particular use case allows for certain benefits:

  • Greater Compliance with EU "Distance Selling Regulations," which require a 14-day refund period for goods (such as tokens) purchased online
  • Interoperability with various NFT-related applications, such as portfolio browsers, and marketplaces
    • NFT marketplaces could place a badge indicating that the NFT is still refundable on listings, and offer to refund NFTs instead of listing them on the marketplace
    • DExes could offer to refund tokens if doing so would give a higher yield
  • Better wallet confirmation dialogs
    • Wallets can better inform the user of the action that is being taken (tokens being refunded), similar to how transfers often have their own unique dialog
    • DAOs can better display the functionality of smart proposals that include refunding tokens

Specification


The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

All implementations MUST use and follow the directions of ERC-165.

ERC-20 Refund Extension


ERC-721 Refund Extension


Optional ERC-721 Batch Refund Extension


ERC-1155 Refund Extension


Optional ERC-1155 Batch Refund Extension


Rationale


refundDeadlineOf uses blocks instead of timestamps, as timestamps are less reliable than block numbers.

The function names of refund, refundOf, and refundDeadlineOf were chosen to fit the naming style of ERC-20, ERC-721, and ERC-1155.

ERC-165 is required as introspection by DApps would be made significantly harder if it were not.

Custom ERC-20 tokens are not supported, as it needlessly increases complexity, and the refundFrom function allows for this functionality when combined with a DEx.

Batch refunds are optional, as account abstraction would make atomic operations like these significantly easier. However, they might still reduce gas costs if properly implemented.

Backwards Compatibility


No backward compatibility issues were found.

Security Considerations


There is a potential re-entrancy risk with the refund function. Make sure to perform the ether transfer after the tokens are destroyed (i.e. obey the checks, effects, interactions pattern).

Copyright


Copyright and related rights waived via CC0.