Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article covers ERC-6105, a proposal that enables NFT trading without relying on NFT marketplaces.

This article translates, summarizes, and expands on the following specification.

Overview

This ERC (Ethereum Request for Comments) extends ERC-721 with marketplace functionality, allowing non-fungible tokens (NFTs) to be traded without intermediary trading platforms. It also enables creators to implement a variety of royalty schemes.

Motivation

At the time of writing, most NFT trades rely on intermediary trading platforms.

This approach presents several problems.

Security concerns associated with setApprovalForAll

Approvals granted using the setApprovalForAll function present security concerns in NFT trading. The function allows an NFT owner to authorize a particular account to operate their tokens. However, this approach creates a risk of unauthorized access and fraud. A vulnerability in a trading platform's contract could affect many people and cause significant damage to the industry as a whole. Furthermore, if users have authorized a trading platform to operate their NFTs, phishing attacks may trick them into signing low-priced orders created by a fraudster who designates themselves as the recipient. This is a threat that ordinary users may find difficult to prevent.

Platforms for buying and selling NFTs, such as OpenSea, have requested that users call setApprovalForAll from their connected wallets as part of the login process. Calling the function grants the platform permission to transfer NFTs held by the user.

A recurring problem was users mistakenly connecting their wallets to sites impersonating OpenSea and approving a setApprovalForAll call. In this situation, a malicious address controlled by the fake site's operator can manipulate the user's NFTs, potentially taking all the NFTs covered by the approval.

High transaction costs

The cost of trading NFTs is another problem. As the number of trading platforms grows, NFT liquidity becomes fragmented, and users need to trade across multiple platforms. They must consequently grant approvals and place orders on multiple platforms, increasing their exposure to risk. For example, consider trading Bored Ape Yacht Club (BAYC) NFTs. At the time of writing, the collection had a total supply of 10,000 NFTs and more than 6,000 holders, with fewer than two BAYC NFTs per holder on average. setApprovalForAll saves gas on pending orders within a single platform, but granting approvals to multiple platforms increases users' total gas expenditure. Trading platforms may also charge trading fees that often exceed the gas costs of approvals.

Calling setApprovalForAll costs gas because the function updates data stored in the smart contract. Every additional call therefore incurs some gas cost.

Centralized decision-making by aggregators

Aggregators combine liquidity from multiple trading platforms. This can make NFT trading more efficient. However, because the aggregator itself consolidates trading information, its decision-making process can become centralized. The aggregator's operator decides which trades to prioritize and which platforms to collect information from, among other things.

The way trading information is consolidated and the criteria used to select it therefore depend on the operator's judgment, potentially undermining transparency and decentralization. If users are not given detailed information about which trades are selected or which platforms receive priority, they may find the aggregator's decision-making process opaque.

Trading platforms also typically manage their order information off-chain. To retrieve that information, aggregators must use the trading platforms' APIs (Application Programming Interfaces). However, these APIs may impose limits on frequent requests or become temporarily unavailable. As a result, aggregators may fail to retrieve accurate trading information, affecting the user experience and the accuracy of the information presented.

In short, aggregators can improve liquidity, but centralized decision-making and restrictions on access to trading information may create transparency and decentralization problems.

Centralization of royalty revenue

Royalty revenue for NFT project stakeholders depends on the centralized decisions of trading platforms. Some trading platforms may introduce optional royalties without the consent of project stakeholders, potentially undermining their interests.

For more on NFT royalties, see the following resources.

[ERC-2981] Understanding NFT royalties and whether ERC-2981 enforces them

https://chaldene.net/erc721-extension#st-toc-h-62

Insufficient censorship resistance

Some NFT trading platforms lack censorship resistance. They can remove particular NFTs from their listings, and the rules and processes governing those removals can be centralized and opaque. In the past, mistaken removal of particular NFTs has caused market disruption.

Consider OpenSea again. When a project issues a new NFT collection, counterfeit collections can appear alongside the official collection, using the same images and descriptions. Users may accidentally purchase NFTs from one of those fake collections. OpenSea has removed counterfeit collections to address this problem, but there have been cases where an official collection was removed by mistake. The ability of a platform to remove collections at its discretion therefore has both advantages and disadvantages.

Specification

Contracts compliant with this proposal must implement the following interface.

javascript
interface IERC6105 {
royalties
  event UpdateListing(
    uint256 indexed tokenId,
    address indexed from,
    uint256 salePrice,
    uint64 expires,
    address supportedToken,
    uint256 benchmarkPrice
    );

  event Purchased(
    uint256 indexed tokenId,
    address indexed from,
    address indexed to,
    uint256 salePrice,
    address supportedToken,
    uint256 royalties
    );

  function listItem(
    uint256 tokenId,
    uint256 salePrice,
    uint64 expires,
    address supportedToken
    ) external;

  function listItem(
    uint256 tokenId,
    uint256 salePrice,
    uint64 expires,
    address supportedToken,
    uint256 benchmarkPrice
    ) external;
 
  function delistItem(uint256 tokenId) external;
 
  function buyItem(uint256 tokenId, uint256 salePrice, address supportedToken) external payable;

  function getListing(uint256 tokenId) external view returns (uint256, uint64, address, uint256);
}

UpdateListing

  • Event

Emitted when a token is listed for sale or delisted.

Parameters

  • tokenId
    • ID of the token being listed.
  • from
    • Address listing the token for sale.
  • salePrice
    • Sale price of the token.
  • expires
    • UNIX timestamp of the purchase deadline.
  • supportedToken
    • Contract address of the supported payment token (the zero address, 0, for ETH).
  • benchmarkPrice
    • Additional price parameter used to calculate royalties.

Purchased

  • Event

Emitted when a token is purchased.

Parameters

  • tokenId
    • ID of the purchased token.
  • from
    • Address that listed the token.
  • to
    • Address that purchased the token.
  • salePrice
    • Purchase price of the token.
  • supportedToken
    • Contract address of the supported payment token (the zero address, 0, for ETH).
  • royalties
    • Amount of royalties paid on the purchase.

listItem

  • Function

Lists a token for sale.

Parameters

  • tokenId
    • ID of the token to list.
  • salePrice
    • Sale price of the token.
  • expires
    • UNIX timestamp of the purchase deadline.
  • supportedToken
    • Contract address of the supported payment token (the zero address, 0, for ETH).

delistItem

  • Function

Removes a token's listing.

Parameters

  • tokenId
    • ID of the token to delist.

buyItem

  • Function

Purchases a token and executes the trade. Checks that the token is listed and that the price and supported payment token match.

Parameters

  • tokenId
    • ID of the token to purchase.
  • salePrice
    • Purchase price of the token.
  • supportedToken
    • Contract address of the supported payment token (the zero address, 0, for ETH).

getListing

  • Function

Retrieves listing information for a particular token.

Parameters

  • tokenId
    • ID of the token whose information is requested.

Return value

Listing information (sale price, purchase deadline, supported payment token, and benchmark price).

Collection offer extension

javascript
interface IERC6105CollectionOffer {

  event UpdateCollectionOffer(address indexed from, uint256 amount, uint256 salePrice ,uint64 expires, address supportedToken);

  function makeCollectionOffer(uint256 amount, uint256 salePrice, uint64 expires, address supportedToken) external;

  function acceptCollectionOffer(uint256 tokenId, uint256 salePrice, address supportedToken, address buyer) external;

  function acceptCollectionOffer(uint256 tokenId, uint256 salePrice, address supportedToken, address buyer, uint256 benchmarkPrice) external;

  function cancelCollectionOffer() external;

  function getCollectionOffer(address buyer) external view returns (uint256, uint256, uint64, address);
}

UpdateCollectionOffer

  • Event

Emitted when an offer is made on a collection or an offer is canceled.

Parameters

  • from
    • Address that made the collection offer.
  • amount
    • Number of tokens the offer maker wishes to purchase at salePrice per token.
  • salePrice
    • Offer price for each token in the collection.
  • expires
    • UNIX timestamp of the offer deadline.
  • supportedToken
    • Contract address of the supported payment token.

makeCollectionOffer

  • Function

Creates or updates a collection offer.

Checks

  • The offer maker holds enough of the supported payment token and has granted the contract a sufficient allowance.
  • salePrice is not 0.
  • amount is not 0.
  • expires is valid.
  • Emit the UpdateCollectionOffer event.

Parameters

  • amount
    • Number of tokens the offer maker wishes to purchase at salePrice per token.
  • salePrice
    • Offer price for each token in the collection.
  • expires
    • UNIX timestamp of the offer deadline.
  • supportedToken
    • Contract address of the supported payment token.

acceptCollectionOffer

  • Function

Accepts a collection offer and transfers the token to the buyer.

Checks

  • tokenId exists and is covered by an offer.
  • The caller is the owner, an approved operator, or the address approved for the token.
  • Emit the Purchased event.

Parameters

  • tokenId
    • ID of the token covered by the offer.
  • salePrice
    • Offer price of the token.
  • supportedToken
    • Contract address of the supported payment token.
  • buyer
    • Address seeking to purchase the token.

cancelCollectionOffer

  • Function

Cancels a collection offer.

Parameters

  • buyer
    • Address seeking to purchase the token.

Return value

Offer information (quantity, offer price, expiration, and supported payment token address).

Item offer extension

javascript
interface IERC6105ItemOffer {

  event UpdateItemOffer(
    uint256 indexed tokenId,
    address indexed from,
    uint256 salePrice,
    uint64 expires,
    address supportedToken
    );

  function makeItemOffer(uint256 tokenId, uint256 salePrice, uint64 expires, address supportedToken) external;

  function cancelItemOffer(uint256 tokenId) external;

  function acceptItemOffer(uint256 tokenId, uint256 salePrice, address supportedToken, address buyer) external;

  function acceptItemOffer(uint256 tokenId, uint256 salePrice, address supportedToken, address buyer, uint256 benchmarkPrice) external;

  function getItemOffer(uint256 tokenId, address buyer) external view returns (uint256, uint64, address);
}

UpdateItemOffer

  • Event

Emitted when an offer is made on a token or an offer is canceled.

Parameters

  • tokenId
    • ID of the token covered by the offer.
  • from
    • Address seeking to purchase the token.
  • salePrice
    • Offer price of the token.
  • expires
    • UNIX timestamp of the offer deadline.
  • supportedToken
    • Contract address of the supported payment token.

makeItemOffer

  • Function

Creates or updates an offer on a token.

Checks

  • tokenId exists.
  • The offer maker holds enough of the supported payment token and has granted the contract a sufficient allowance.
  • salePrice is not 0.
  • expires is valid.
  • Emit the UpdateItemOffer event.

Parameters

  • tokenId
    • ID of the token covered by the offer.
  • salePrice
    • Offer price of the token.
  • expires
    • UNIX timestamp of the offer deadline.
  • supportedToken
    • Contract address of the supported payment token.

cancelItemOffer

  • Function

Cancels an offer on a token.

Checks

  • tokenId exists and is covered by an offer.
  • The caller is the address that made the offer.
  • Emit the UpdateItemOffer event.

Parameters

  • tokenId
    • ID of the token whose offer is being canceled.

acceptItemOffer

  • Function

Accepts an offer on a token and transfers the token to the buyer.

Checks

  • tokenId exists and is covered by an offer.
  • The caller is the owner, an approved operator, or the address approved for the token.
  • Emit the Purchased event.

Parameters

  • tokenId
    • ID of the token covered by the offer.
  • salePrice
    • Offer price of the token.
  • supportedToken
    • Contract address of the supported payment token.
  • buyer
    • Address seeking to purchase the token.

getItemOffer

  • Function

Retrieves offer information for a particular token and buyer.

Parameters

  • tokenId
    • ID of the token whose offer information is requested.
  • buyer
    • Address seeking to purchase the token.

Return value

Offer information (offer price, expiration, and supported payment token address).

Additional considerations

Considerations for local variables

The salePrice parameter in listItem cannot be set to 0.

  • Callers rarely intend to set a price of 0. When they do, it is usually an operational error that could result in loss of assets.
  • Because the caller must spend gas to call the function, setting the token price to 0 would result in negative net proceeds and is economically irrational under the assumptions described here.
  • A token price of 0 indicates that the item is not for sale, simplifying the reference implementation.

If the token price could be set to 0, a caller could spend gas to execute the function without earning any revenue. Specifically, even though the token's sale price is 0, gas is still required to execute the function, and the caller must pay that cost. From an economic perspective, this is considered irrational. In economics, individuals making economic decisions are often modeled as rational actors seeking to maximize their own interests. However, with a token price of 0, paying gas to call the function leads to negative net proceeds for the caller, which is not rational under that model.

Furthermore, a token price of 0 indicates that the item is not currently for sale. Encoding this information in the token's state provides a concise representation of whether it is listed. Other functions and processes can then check the item's listing status more easily, making the code for interpreting token state clearer.

Setting expires in listItem allows callers to manage listings more effectively. When a listing expires automatically, the token owner no longer needs to call delistItem manually, saving gas.

Setting supportedToken in listItem lets the caller or contract owner select accepted payment tokens without being restricted to a single token.

The rationale for setting the variables in acceptCollectionOffer and acceptItemOffer is the same as described above.

More diverse royalty schemes

Introducing the benchmarkPrice parameter in listItem, acceptCollectionOffer, and acceptItemOffer allows _salePrice in the ERC-2981 interface's royaltyInfo(uint256 _tokenId, uint256 _salePrice) function to be replaced with taxablePrice, enabling more varied ERC-2981 royalty schemes. Here are several examples.

javascript
(address royaltyRecipient、uint256 royalties)= royaltyInfo(tokenId、taxablePrice)
  1. Value-added royalties (VAR, royalties are charged only on part of the seller's profit)
    • taxablePrice = max(salePrice - historicalPrice, 0)
  2. Sale royalties (SR)
    • taxablePrice = salePrice
  3. Capped royalties (CR)
    • taxablePrice = min(salePrice, constant)
  4. Quantity royalties (QR, each token trade pays a fixed royalty)
    • taxablePrice = constant

Optional blocklist

Some argue that token trades on intermediary marketplaces that do not comply with royalty schemes should be prevented. However, this standard provides functionality for NFT trading without intermediaries and does not provide a standardized interface for preventing trades on those marketplaces. To better protect the interests of project teams and communities, they may consider adding a blocklist to their implementation contracts to prevent NFT trading on platforms that do not comply with the project's royalty scheme.

Some people believe NFT (non-fungible token) trading should be prevented on intermediary marketplaces that do not comply with a project's royalty scheme, which requires payment of a trading fee or portion of the proceeds. In other words, they argue that trades should be prevented on exchanges or platforms that do not respect the project's trading rules or royalties.

However, while the proposed NFT standard provides functionality for markets without intermediaries (direct token trading), it does not provide a standardized way to prevent or regulate trades on intermediary marketplaces. There is therefore no clear guideline or standard governing how a project should control NFT trading on markets that do not comply with its own royalty scheme.

Project teams and communities are consequently considering ways to prevent NFT trading on platforms that do not comply with their royalty schemes in order to protect their own interests and value. One proposal is to introduce a blocklist identifying particular addresses or platforms to prevent trades inconsistent with the project's policy. The goal is to respect the project's chosen royalty scheme, maintain community trust, and preserve a healthy trading environment.

Backward compatibility

This standard is compatible with ERC-721 and ERC-2981.

Reference implementation

I have provided a reference implementation below.

Source: https://eips.ethereum.org/EIPS/eip-6105

Security considerations

From a security perspective, buyItem, acceptCollectionOffer, and acceptItemOffer are potentially vulnerable to front-running. To prevent front-running attacks, implementations need to verify that salePrice and supportedToken match the expected price and token.

A front-running attack is a security risk in blockchain and cryptocurrency transactions. An attacker attempts to profit unfairly by detecting another user's pending transaction and submitting a transaction with copied contents before it is processed.

If an attacker's transaction is processed first, the other user's transaction may no longer succeed, and the attacker may obtain the benefit intended for that user. This type of attack exploits transaction ordering and timing, including opportunities created by price movements.

Front-running is a particular concern in decentralized environments and is a security risk to consider in cryptocurrency trading and decentralized applications. Protocol and smart contract designers should account for this risk when designing their security mechanisms.

The acceptCollectionOffer and acceptItemOffer functions also present a reentrancy risk. To address it, implementations should follow the checks-effects-interactions (CEI) pattern or use a reentrancy guard.

For more on reentrancy attacks, see the following resource.

https://chaldene.net/solidity-reentrancy-attack

When purchasing an NFT with an ERC-20 token, the buyer must first call the ERC-20 token's approve(address spender, uint256 amount) function to authorize the NFT contract to access a specified amount of tokens. Ensure that the approved amount is appropriate. Exercise caution when interacting with unaudited contracts. These precautions help minimize security risks when trading.

Citation

5660-eth (@5660-eth), Silvere Heraudeau (@lambdalf-dev), Martin McConnell (@offgridgecko), Abu team10kuni@gmail.com, Wizard Wang, "ERC-6105: No Intermediary NFT Trading Protocol," Ethereum Improvement Proposals, no. 6105, December 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6105.

Discussion

I found the idea of a specification that enables buying and selling without relying on marketplaces interesting. However, even NFTs conforming to this specification can still be traded through marketplaces that ignore it, so that is worth keeping in mind. The ability to manage offers for NFT collections and individual NFTs through extensions is particularly interesting because multiple platforms can refer to the same standard and process offers consistently. Building something with the standard would likely involve NFT marketplaces: either creating a marketplace or creating a contract that supplies information to marketplaces. Both seem like worthwhile challenges, and I am interested in trying them.

Conclusion

The original article's closing sentence refers to ERC-5570, a proposal for recording purchase receipts in NFT metadata and on the blockchain. This is a mismatched reference in the Japanese source; the subject of this article is ERC-6105.