Skip to content

Instantly share code, notes, and snippets.

@cygaar
Created March 25, 2023 20:28
Show Gist options
  • Save cygaar/b728caecf96ec49860b5ae83dc44eff1 to your computer and use it in GitHub Desktop.
Save cygaar/b728caecf96ec49860b5ae83dc44eff1 to your computer and use it in GitHub Desktop.
// 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 : "";
}
}
@uwaifo18
Copy link

❤️

@Ronny03tesarus
Copy link

<3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment