-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArteDigital.sol
42 lines (33 loc) · 1.37 KB
/
ArteDigital.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
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;
import "@openzeppelin/[email protected]/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/[email protected]/access/Ownable.sol";
contract ArteDigital is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
constructor(string memory _name, string memory _symbol, string memory _initBaseURI)
ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
}
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
function mint(address _to) public onlyOwner {
uint256 tokenId = totalSupply() + 1;
_safeMint(_to, tokenId);
}
function tokenURI(uint256 tokenId)
public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString(), baseExtension))
: "";
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
}