Last active
May 16, 2022 09:02
-
-
Save giuseppeg/ae92592af23bded38b45070ed65af8ba to your computer and use it in GitHub Desktop.
This file contains hidden or 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.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