Created
March 25, 2023 20:28
-
-
Save cygaar/b728caecf96ec49860b5ae83dc44eff1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.13; | |
import {ERC721A} from "erc721a/contracts/ERC721A.sol"; | |
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; | |
error MintLimitExceeded(); | |
contract SampleNFT is ERC721A, Ownable { | |
uint256 public constant MINT_LIMIT = 10; | |
string public _baseTokenURI = ""; | |
constructor() ERC721A("Sample Scroll NFT", "SAMPLE") {} | |
function mint(uint256 qty) external { | |
if (qty > MINT_LIMIT) revert MintLimitExceeded(); | |
_mint(msg.sender, qty); | |
} | |
// ========================================================================= | |
// Metadata | |
// ========================================================================= | |
function setBaseURI(string calldata baseURI) external onlyOwner { | |
_baseTokenURI = baseURI; | |
} | |
function _baseURI() internal view override returns (string memory) { | |
return _baseTokenURI; | |
} | |
function tokenURI(uint256 tokenId) public view override returns (string memory) { | |
if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); | |
string memory baseURI = _baseURI(); | |
return bytes(baseURI).length != 0 ? baseURI : ""; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
<3