主页EIPs
EIPsERC-4944
ERC-4944

Contract with Exactly One Non-fungible Token

An ERC-721 compatible single-token NFT
StagnantStandards Track: ERC
创建时间: 2022-03-25
关联 EIP: EIP-721
Víctor Muñoz (@victormunoz), Josep Lluis de la Rosa (@peplluis7), Andres El-Fakdi (@Bluezfish)
社区讨论原文链接编辑
1 分钟了解
欢迎补充好内容
去提交
相关视频
欢迎补充好内容
去提交
正文

Abstract

The following describes standard functions for an ERC-721 compatible contract with a total supply of one. This allows an NFT to be associated uniquely with a single contract address.

Motivation

If the ERC-721 was modified to mint only 1 token (per contract), then the contract address could be identified uniquely with that minted token (instead of the tuple contract address + token id, as ERC-721 requires). This change would enable automatically all the capabilities of composable tokens ERC-998 (own other ERC-721 or ERC-20) natively without adding any extra code, just forbidding to mint more than one token per deployed contract. Then the NFT minted with this contract could operate with his "budget" (the ERC-20 he owned) and also trade with the other NFTs he could own. Just like an autonomous agent, that could decide what to do with his properties (sell his NFTs, buy other NFTs, etc).

The first use case that is devised is for value preservation. Digital assets, as NFTs, have value that has to be preserved in order to not be lost. If the asset has its own budget (in other ERC-20 coins), could use it to autopreserve itself.

Specification

The constructor should mint the unique token of the contract, and then the mint function should add a restriction to avoid further minting.

Also, a tokenTransfer function should be added in order to allow the contract owner to transact with the ERC-20 tokens owned by the contract/NFT itself. So that if the contract receives a transfer of ERC-20 tokens, the owner of the NFT could spend it from the contract wallet.

Rationale

The main motivation is to keep the contract compatible with current ERC-721 platforms.

Backwards Compatibility

There are no backwards compatibility issues.

Reference Implementation

Add the variable _minted in the contract:

bool private _minted;

In the constructor, automint the first token and set the variable to true:

constructor(string memory name, string memory symbol, string memory base_uri) ERC721(name, symbol) { baseUri = base_uri; mint(msg.sender,0); _minted = true; }

Add additional functions to interact with the NFT properties (for instance, ERC-20):

modifier onlyOwner() { require(balanceOf(msg.sender) > 0, "Caller is not the owner of the NFT"); _; } function transferTokens(IERC20 token, address recipient, uint256 amount) public virtual onlyOwner { token.transfer(recipient, amount); } function balanceTokens(IERC20 token) public view virtual returns (uint256) { return token.balanceOf(address(this)); }

Security Considerations

No security issues found.

Copyright and related rights waived via CC0.

扩展阅读
欢迎补充好内容
去提交
相关项目
欢迎补充好内容
去提交

不想错过最新的 EIP 动态?

订阅 EIPs Fun 周刊以跟进相关更新,建⽴你与 EIP 之间的连接 ,更好地建设以太坊。

详情
支持以太坊贡献者,推动生态建设
资源
GitHub
支持社区