-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNuftu.sol
More file actions
69 lines (57 loc) · 2.23 KB
/
Copy pathNuftu.sol
File metadata and controls
69 lines (57 loc) · 2.23 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
/**
*
*/
contract Nuftu is Context, ERC721Enumerable, ERC721Burnable {
using Counters for Counters.Counter;
address private _creator;
Counters.Counter private _tokenIdTracker;
string private _baseTokenURI;
/**
* Token URIs will be autogenerated based on `baseURI` and their token IDs.
* See {ERC721-tokenURI}.
*/
constructor(string memory baseTokenURI) ERC721("Nuftu NFT", "NUFTU") {
_baseTokenURI = baseTokenURI;
_creator = _msgSender();
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
/**
* @dev Creates a new token for `to`. Its token ID will be automatically
* assigned (and available on the emitted {IERC721-Transfer} event), and the token
* URI autogenerated based on the base URI passed at construction.
*
* See {ERC721-_mint}.
*
* Requirements:
*
* - the caller must be the creator.
*/
function mint(address to) public virtual returns (uint256) {
require(_creator == _msgSender(), "Nuftu: must be creator to mint");
// We cannot just use balanceOf to create the new tokenId because tokens
// can be burned (destroyed), so we need a separate counter.
uint256 tokenId = _tokenIdTracker.current();
_mint(to, tokenId);
_tokenIdTracker.increment();
_approve(_msgSender(), tokenId);
return tokenId;
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable) {
super._beforeTokenTransfer(from, to, tokenId);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
}