The mintEgg
function in the EggstravaganzaNFT
contract utilizes the _mint
method to create new NFTs. This approach does not verify whether the recipient address can handle ERC721 tokens, potentially leading to tokens being irretrievably locked in contracts incapable of processing them.
In the current implementation, the mintEgg
function is defined as follows:
The _mint
function from the ERC721 standard directly assigns ownership of a new token to the specified address without performing checks to confirm if the recipient is a contract capable of handling ERC721 tokens. If to
is a contract that does not implement the onERC721Received
function, the minted NFT could become permanently inaccessible. This scenario is particularly problematic if the recipient contract is not designed to manage ERC721 tokens, leading to a loss of access to the NFT.
Minting NFTs to contracts that are not ERC721-aware can result in tokens being locked and inaccessible, effectively removing them from circulation and causing potential loss of value for users.
Manual code analysis
To prevent the risk of NFTs being locked in non-ERC721-aware contracts, it is advisable to use the _safeMint
function instead of _mint
. The _safeMint
function performs additional checks to ensure that if the recipient is a contract, it implements the onERC721Received
function, thereby confirming its ability to handle ERC721 tokens.
The revised mintEgg
function would be:
Protocol doesn't check if recipient contracts can handle ERC721 tokens
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.