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.
ERC-4400 proposes a consumer role that allows application-specific rights associated with an NFT to be assigned to another address without transferring ownership.
This article translates, summarizes, and expands on the following proposal.
A token ID identifies an individual NFT within its token contract. Numeric identifiers such as 1 and 2 are common examples.
Overview
ERC-4400 defines standardized functions through which the owner of an ERC-721 NFT can assign a consumer role to another address.
Applications can query the consumer associated with a particular token ID. The interface also defines an event for recording changes to that role.
The proposal extends ERC-721 and depends on its ownership and authorization model.
Motivation
NFT contracts often define custom roles for granting application-specific rights associated with tokens.
For example, a metaverse land NFT could have operator or contributor roles that allow another account to construct buildings on the virtual land without receiving ownership of the NFT.
NFTs frequently provide utility beyond ownership. Standardizing the assignment and discovery of usage roles can make that utility easier to integrate into wallets, user interfaces, and external protocols.
The consumer role provides a common foundation on which ERC-721 applications can build services such as general-purpose NFT rental marketplaces.
Potential applications include:
- Virtual land and other digital assets, including construction rights and rentals of land, characters, clothing, and event passes.
- NFT-based yield farming, where an application may recognize a staker's usage rights even after the NFT has been transferred to a staking contract.
The extension does not itself implement rental payments, expiration periods, or staking rewards. These behaviors depend on the consuming application.
Specification
interface IEIP721Consumable {
event ConsumerChanged(address indexed owner, address indexed consumer, uint256 indexed tokenId);
function consumerOf(uint256 _tokenId) view external returns (address);
function changeConsumer(address _consumer, uint256 _tokenId) external;
}ConsumerChanged
Emitted when the consumer associated with an ERC-721 token changes.
A zero consumer address indicates that no consumer is assigned under the usual zero-address convention.
When a token is transferred, its previous consumer assignment must be cleared or reset as required by the extension. The corresponding ConsumerChanged event makes the change observable alongside the ERC-721 Transfer event.
consumerOf
Returns the consumer address associated with the specified token ID.
A zero address indicates that no consumer is assigned. The function must revert when the specified token does not exist.
changeConsumer
Changes or clears the consumer associated with a token.
The caller must be the token owner or an appropriately authorized ERC-721 account. The displayed implementation accepts the owner, the token-specific approved address, or an operator approved for all of the owner's tokens.
Setting the consumer to the zero address clears the role in the displayed implementation.
Additional requirements
Contracts implementing the ERC-721 consumable extension define the application-specific permissions associated with the consumer role.
A consumer does not become the NFT owner or an approved ERC-721 operator merely by receiving that role. Consumer status alone must not grant the authority to transfer the NFT or approve another address to transfer it.
When the NFT is transferred, its consumer assignment must be reset to the default address. The proposal recommends using address(0) as that default.
The supportsInterface function must return true for interface ID 0x953c8dfa.
Rationale
The extension is designed around several principles:
- Keep the interface small to avoid unnecessary contract complexity and bytecode growth.
- Maintain a simple implementation.
- Consider gas efficiency.
- Avoid repurposing existing ownership, operator, or approval mechanisms to represent independent usage rights.
Naming
The term consumer describes an account that can use an asset without necessarily owning it.
The term operator was also considered, but ERC-721 already uses operator to describe an account with a particular kind of approval authority.
Limitations
Many applications need NFT-specific roles that do not convey the rights of an owner.
An implementation that grants the consumer all ownership-related permissions would undermine the purpose of this distinction.
Backward compatibility
The consumer role should not modify the standard ERC-721 ownership and transfer-approval semantics. Existing applications can continue to use the ordinary ERC-721 interface, while applications aware of ERC-4400 can query consumer assignments separately.
Tests
The original article provides the following test suite.
import {ethers} from "hardhat";
import {expect} from 'chai';
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {Erc721Consumable} from "../typechain";
describe("ERC721Consumable", async () => {
let owner: SignerWithAddress, approved: SignerWithAddress, operator: SignerWithAddress, consumer: SignerWithAddress,
other: SignerWithAddress;
let token: Erc721Consumable;
let snapshotId: any;
const tokenID = 1; // The first minted NFT
before(async () => {
const signers = await ethers.getSigners();
owner = signers[0];
approved = signers[1];
operator = signers[2];
consumer = signers[3];
other = signers[4];
const ConsumableToken = await ethers.getContractFactory("ExampleToken");
const deployedContract = await ConsumableToken.deploy();
await deployedContract.deployed();
token = deployedContract as Erc721Consumable;
await token.mint();
})
beforeEach(async function () {
snapshotId = await ethers.provider.send('evm_snapshot', []);
});
afterEach(async function () {
await ethers.provider.send('evm_revert', [snapshotId]);
});
it('should implement ERC165', async () => {
expect(await token.supportsInterface("0x953c8dfa")).to.be.true;
})
it('should successfully change consumer', async () => {
// when:
await token.changeConsumer(consumer.address, tokenID);
// then:
expect(await token.consumerOf(tokenID)).to.equal(consumer.address);
});
it('should emit event with args', async () => {
// when:
const tx = await token.changeConsumer(consumer.address, tokenID);
// then:
await expect(tx)
.to.emit(token, 'ConsumerChanged')
.withArgs(owner.address, consumer.address, tokenID);
});
it('should successfully change consumer when caller is approved', async () => {
// given:
await token.approve(approved.address, tokenID);
// when:
const tx = await token.connect(approved).changeConsumer(consumer.address, tokenID);
// then:
await expect(tx)
.to.emit(token, 'ConsumerChanged')
.withArgs(owner.address, consumer.address, tokenID);
// and:
expect(await token.consumerOf(tokenID)).to.equal(consumer.address);
});
it('should successfully change consumer when caller is operator', async () => {
// given:
await token.setApprovalForAll(operator.address, true);
// when:
const tx = await token.connect(operator).changeConsumer(consumer.address, tokenID);
// then:
await expect(tx)
.to.emit(token, 'ConsumerChanged')
.withArgs(owner.address, consumer.address, tokenID);
// and:
expect(await token.consumerOf(tokenID)).to.equal(consumer.address);
});
it('should revert when caller is not owner, not approved', async () => {
const expectedRevertMessage = 'ERC721Consumable: changeConsumer caller is not owner nor approved';
await expect(token.connect(other).changeConsumer(consumer.address, tokenID))
.to.be.revertedWith(expectedRevertMessage);
});
it('should revert when caller is approved for the token', async () => {
// given:
await token.changeConsumer(consumer.address, tokenID);
// then:
const expectedRevertMessage = 'ERC721Consumable: changeConsumer caller is not owner nor approved';
await expect(token.connect(consumer).changeConsumer(consumer.address, tokenID))
.to.be.revertedWith(expectedRevertMessage);
});
it('should revert when tokenID is nonexistent', async () => {
const invalidTokenID = 2;
const expectedRevertMessage = 'ERC721: owner query for nonexistent token';
await expect(token.changeConsumer(consumer.address, invalidTokenID))
.to.be.revertedWith(expectedRevertMessage);
});
it('should revert when calling consumerOf with nonexistent tokenID', async () => {
const invalidTokenID = 2;
const expectedRevertMessage = 'ERC721Consumable: consumer query for nonexistent token';
await expect(token.consumerOf(invalidTokenID))
.to.be.revertedWith(expectedRevertMessage);
});
it('should clear consumer on transfer', async () => {
await token.changeConsumer(consumer.address, tokenID);
await expect(token.transferFrom(owner.address, other.address, tokenID))
.to.emit(token, 'ConsumerChanged')
.withArgs(owner.address, ethers.constants.AddressZero, tokenID);
})
it('should emit ConsumerChanged on mint', async () => {
await expect(token.mint())
.to.emit(token, 'ConsumerChanged')
.withArgs(ethers.constants.AddressZero, ethers.constants.AddressZero, tokenID + 1);
})
it('should not be able to transfer from consumer', async () => {
const expectedRevertMessage = 'ERC721: transfer caller is not owner nor approved';
await token.changeConsumer(consumer.address, tokenID);
await expect(token.connect(consumer).transferFrom(owner.address, other.address, tokenID))
.to.revertedWith(expectedRevertMessage)
})
});The tests cover interface detection, consumer assignment, event emission, authorization through token-specific and collection-wide approvals, rejection of unauthorized calls, nonexistent tokens, consumer clearing on transfer, and the absence of transfer authority based solely on consumer status.
The example also expects ConsumerChanged to be emitted during minting under the displayed transfer-hook implementation.
Reference implementation
// SPDX-License-Identifier: CC0-1.0
pragma solidity 0.8.11;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "./IERC721Consumable.sol";
contract ERC721Consumable is IERC721Consumable, ERC721 {
// Mapping from token ID to consumer address
mapping(uint256 => address) _tokenConsumers;
constructor (string memory name_, string memory symbol_) ERC721(name_, symbol_) {}
/**
* @dev Returns true if the `msg.sender` is approved, owner or consumer of the `tokenId`
*/
function _isApprovedOwnerOrConsumer(uint256 tokenId) internal view returns (bool) {
return _isApprovedOrOwner(msg.sender, tokenId) || _tokenConsumers[tokenId] == msg.sender;
}
/**
* @dev See {IERC721Consumable-consumerOf}
*/
function consumerOf(uint256 _tokenId) view external returns (address) {
require(_exists(_tokenId), "ERC721Consumable: consumer query for nonexistent token");
return _tokenConsumers[_tokenId];
}
/**
* @dev See {IERC721Consumable-changeConsumer}
*/
function changeConsumer(address _consumer, uint256 _tokenId) external {
address owner = this.ownerOf(_tokenId);
require(msg.sender == owner || msg.sender == getApproved(_tokenId) || isApprovedForAll(owner, msg.sender),
"ERC721Consumable: changeConsumer caller is not owner nor approved");
_changeConsumer(owner, _consumer, _tokenId);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Consumable).interfaceId || super.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(address _from, address _to, uint256 _tokenId) internal virtual override (ERC721) {
super._beforeTokenTransfer(_from, _to, _tokenId);
_changeConsumer(_from, address(0), _tokenId);
}
/**
* @dev Changes the consumer
* Requirement: `tokenId` must exist
*/
function _changeConsumer(address _owner, address _consumer, uint256 _tokenId) internal {
_tokenConsumers[_tokenId] = _consumer;
emit ConsumerChanged(_owner, _consumer, _tokenId);
}
}
The implementation stores consumer addresses in a mapping indexed by token ID.
The internal helper _isApprovedOwnerOrConsumer recognizes the consumer alongside ordinary authorized accounts. Application developers can use this helper for operations that are explicitly intended to permit consumer access.
The changeConsumer function uses ordinary ERC-721 ownership and approval checks, rather than allowing a consumer to reassign the role solely because it is the current consumer.
The transfer hook resets the consumer to the zero address and emits ConsumerChanged.
The code and tests are reproduced unchanged from the original article. They target historical Solidity, OpenZeppelin, and Hardhat APIs and have not been independently compiled or executed as part of this translation. The interface naming and the actual imported interface definition should be checked when integrating the example.
Security
Implementers must carefully define the permissions associated with the consumer role.
Even when NFT transfers and burns are not directly authorized for consumers, other application-specific operations may inadvertently grant equivalent control over an asset or its associated rights.
In particular, an authorization helper that recognizes consumers should not be substituted for ordinary ownership or transfer-approval checks in operations intended exclusively for owners or approved operators.
Applications should also account for the clearing of consumer assignments when NFTs are transferred and define any additional conditions required for rental or staking arrangements.
Conclusion
ERC-4400 introduces a standardized consumer role for ERC-721 NFTs. It allows applications to recognize usage rights independently of ownership and ordinary transfer approvals.
The original article notes that further implementation examples may be added later.
Questions are welcome via Twitter @cardene777.

