-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathNFT.sol
More file actions
33 lines (25 loc) · 866 Bytes
/
NFT.sol
File metadata and controls
33 lines (25 loc) · 866 Bytes
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract NFT is ERC721, Ownable {
using Counters for Counters.Counter;
Counters.Counter public currentTokenId;
string public baseTokenURI;
constructor() ERC721("NFTTutorial2", "NFT2") {
baseTokenURI = "";
}
function mintNFT() public returns (uint256) {
currentTokenId.increment();
uint256 newItemId = currentTokenId.current();
_safeMint(msg.sender, newItemId);
return newItemId;
}
function _baseURI() internal view virtual override returns (string memory) {
return baseTokenURI;
}
function setBaseTokenURI(string memory _baseTokenURI) public onlyOwner {
baseTokenURI = _baseTokenURI;
}
}