-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLock.sol
47 lines (29 loc) · 1.25 KB
/
Lock.sol
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
38
39
40
41
42
43
44
45
46
47
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
contract TVCharactersNFT is ERC721URIStorage{
uint256 private _tokenId;
uint256 public constant MAX_NFTS = 3000;
uint256 public nftCount;
mapping (uint256 => string) private _tokenURIs;
constructor() ERC721("TVCharactersNFT", "TVNFT") {}
function mintNFT(address recipient, string memory tokenURI) public returns (uint256) {
require(nftCount < MAX_NFTS, "Maximum number of NFTs reached");
uint256 newItemId = _tokenId + 1;
_tokenId = newItemId;
_mint(recipient, newItemId);
_setTokenURI(newItemId, tokenURI);
nftCount++;
return newItemId;
}
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual override {
_tokenURIs[tokenId] = _tokenURI;
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
return _tokenURIs[tokenId];
}
function changeImage(uint256 tokenId, string memory newTokenURI) public {
require(ownerOf(tokenId) == _msgSender(), "Caller is not owner");
_setTokenURI(tokenId, newTokenURI);
}
}