Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@giuseppeg
Last active May 16, 2022 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giuseppeg/ae92592af23bded38b45070ed65af8ba to your computer and use it in GitHub Desktop.
Save giuseppeg/ae92592af23bded38b45070ed65af8ba to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract NFTLoremIpsum is ERC721, Ownable {
constructor() ERC721("Lorem Ipsum", "NFTLI") {}
uint public totalSupply;
string private _baseTokenURI;
function mint(address to, uint tokenId) external {
totalSupply++;
_safeMint(to, tokenId);
}
function adminMint(address[] calldata to, uint[] calldata tokenIds) external onlyOwner {
require(to.length == tokenIds.length, "must be same length");
totalSupply += to.length;
for (uint i;i<to.length;i++) {
_safeMint(to[i], tokenIds[i]);
}
}
// Configure Token URI base path.
// See tokenURI implementation https://github.com/OpenZeppelin/openzeppelin-contracts/blob/57725120581e27ec469e1c7e497a4008aafff818/contracts/token/ERC721/ERC721.sol#L93
// Essentially the default tokenURI is _baseTokenURI + tokenId
// therefore your metadata URIs should be something like https://arweave.net/<hash>/<tokenId>
// where https://arweave.net/<hash> (your _baseTokenURI) is the same for every token.
function setBaseURI(string calldata baseURI) external onlyOwner {
_baseTokenURI = baseURI;
}
function _baseURI() internal view override returns (string memory) {
return _baseTokenURI;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment