-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArtBlockNFT.sol
63 lines (51 loc) · 2.04 KB
/
ArtBlockNFT.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// SPDX-License-Identifier: MIT
// Compatible with OpenZeppelin Contracts ^5.0.0
pragma solidity ^0.8.20;
import { console } from "forge-std/Test.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract ArtBlockNFT is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable {
uint256 private _nextTokenId;
mapping(bytes4 productId => uint256 tokenId) public productToTokenId;
constructor(address MainEngine) ERC721("ArtBlockNFT", "ATBNFT") Ownable(MainEngine) { }
function safeMint(address to, string memory uri, bytes4 productId) external onlyOwner {
uint256 tokenId = _nextTokenId++;
_safeMint(to, tokenId);
_setTokenURI(tokenId, uri);
productToTokenId[productId] = tokenId;
}
function safeTransfer(address from, address to, uint256 tokenId) external onlyOwner {
safeTransferFrom(from, to, tokenId);
}
function getTokenId(bytes4 productId) external view returns (uint256) {
return productToTokenId[productId];
}
// The following functions are overrsides required by Solidity.
function _update(
address to,
uint256 tokenId,
address auth
)
internal
override(ERC721, ERC721Enumerable)
returns (address)
{
return super._update(to, tokenId, auth);
}
function _increaseBalance(address account, uint128 value) internal override(ERC721, ERC721Enumerable) {
super._increaseBalance(account, value);
}
function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) {
return super.tokenURI(tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721Enumerable, ERC721URIStorage)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}