File size: 1,318 Bytes
cc183a1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import {IERC4906} from "@openzeppelin/contracts/interfaces/IERC4906.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
contract MutableMetadataCollection is ERC721, IERC4906 {
address public immutable issuer;
mapping(uint256 => string) private _tokenURIs;
constructor() ERC721("Collection", "NFT") {
issuer = msg.sender;
}
function mint(address to, uint256 tokenId) external {
require(msg.sender == issuer, "only issuer");
_mint(to, tokenId);
}
function setTokenURI(uint256 tokenId, string calldata uri) external {
address owner = _requireOwned(tokenId);
require(msg.sender == owner || msg.sender == issuer, "not authorized");
_tokenURIs[tokenId] = uri;
emit MetadataUpdate(tokenId);
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
_requireOwned(tokenId);
return _tokenURIs[tokenId];
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, IERC165) returns (bool) {
return interfaceId == bytes4(0x49064906) || super.supportsInterface(interfaceId);
}
}
|