Hi,
I noticed an insecure practice in the following example (GameItem.sol), from the documentation: https://docs.openzeppelin.com/contracts/4.x/erc721#constructing_an_erc721_token_contract
// contracts/GameItem.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract GameItem is ERC721URIStorage {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor() ERC721("GameItem", "ITM") {}
function awardItem(address player, string memory tokenURI)
public
returns (uint256)
{
uint256 newItemId = _tokenIds.current();
_mint(player, newItemId);
_setTokenURI(newItemId, tokenURI);
_tokenIds.increment();
return newItemId;
}
}
💻 Environment
Any
📝 Details
In the provided example you use the _mint function, that is said to be discouraged in the documentation:
https://docs.openzeppelin.com/contracts/4.x/api/token/erc721#ERC721-_mint-address-uint256-
Usage of this method is discouraged, use _safeMint whenever possible
I think that _mint function should be changed to _safeMint to encourage best practices. This practical example is the entry point for lots of new Solidity developers.
Thanks
🔢 Code to reproduce bug
You can find the code in the documentation.
Hi,
I noticed an insecure practice in the following example (GameItem.sol), from the documentation: https://docs.openzeppelin.com/contracts/4.x/erc721#constructing_an_erc721_token_contract
💻 Environment
Any
📝 Details
In the provided example you use the _mint function, that is said to be discouraged in the documentation:
https://docs.openzeppelin.com/contracts/4.x/api/token/erc721#ERC721-_mint-address-uint256-
Usage of this method is discouraged, use _safeMint whenever possible
I think that _mint function should be changed to _safeMint to encourage best practices. This practical example is the entry point for lots of new Solidity developers.
Thanks
🔢 Code to reproduce bug
You can find the code in the documentation.