I am looking to deploy an ERC721 contract. As per the docs I am using this:
// 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)
{
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(player, newItemId);
_setTokenURI(newItemId, tokenURI);
return newItemId;
}
}
Generally my question is how does one go about adding modifiers to inherited functions from the ERC721.sol and ERC721URIStorage.sol? As part of this contract, once minted, users will not be able to transfer the NFT - it is locked to the wallet it is minted too. As a result I will either need to remove or else add the onlyOwner
modifier to the various transfer function to prevent being able to transfer. This is the same for the various approval functions etc.
Also, would it be correct to say that the only way to mint a token via the above contract is via the awardItem
function?
Thank you