Last active
March 15, 2021 19:41
-
-
Save ngmachado/cb0e03ffd873502e8c5cd6c46e572ae4 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
pragma solidity 0.7.6; | |
pragma experimental ABIEncoderV2; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0/contracts/token/ERC721/ERC721.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0/contracts/utils/Counters.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0/contracts/access/AccessControl.sol"; | |
contract SuperERC721 is ERC721, AccessControl { | |
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); | |
using Counters for Counters.Counter; | |
Counters.Counter private _tokenIds; | |
constructor(string memory name, string memory symbol) ERC721 (name, symbol) public { | |
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender); | |
} | |
function mint(address to, string memory tokenURI) public returns(uint256 tokenId) { | |
require( | |
hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || | |
hasRole(MINTER_ROLE, msg.sender), | |
"Not a minter role user"); | |
_tokenIds.increment(); | |
tokenId = _tokenIds.current(); | |
_mint(to, tokenId); | |
_setTokenURI(tokenId, tokenURI); | |
} | |
function batchMint(address to, string[] memory tokensURI) public { | |
for(uint256 i = 0; i < tokensURI.length; i++) { | |
mint(to, tokensURI[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment