Created
July 4, 2022 11:23
-
-
Save ngmachado/8295a0f75b988ba6e519c216ed79aa32 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.10; | |
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
import "@openzeppelin/contracts/access/AccessControl.sol"; | |
import "@openzeppelin/contracts/utils/Counters.sol"; | |
contract SuperfluidETHAmsterdam22 is ERC721, ERC721URIStorage, AccessControl { | |
using Counters for Counters.Counter; | |
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); | |
Counters.Counter private _tokenIdCounter; | |
constructor() ERC721("SuperfluidETHAmsterdam22", "SAMS22") { | |
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender); | |
_grantRole(MINTER_ROLE, msg.sender); | |
_tokenIdCounter.increment(); | |
} | |
function safeMint(address to, string memory uri) public onlyRole(MINTER_ROLE) { | |
uint256 tokenId = _tokenIdCounter.current(); | |
_tokenIdCounter.increment(); | |
_safeMint(to, tokenId); | |
_setTokenURI(tokenId, uri); | |
} | |
function batchSafeMint(address to, string[] memory uris) public onlyRole(MINTER_ROLE) { | |
for(uint256 i = 0; i < uris.length; i++) { | |
safeMint(to, uris[i]); | |
} | |
} | |
function batchTransfer(address[] calldata to, uint256[] calldata tokenIds) public { | |
require(to.length == tokenIds.length, "wrong arrary size"); | |
for(uint256 i = 0; i < to.length; i++) { | |
safeTransferFrom(msg.sender, to[i], tokenIds[i]); | |
} | |
} | |
function safeTransfer(address to, uint256 tokenId) public { | |
safeTransferFrom(msg.sender, to, tokenId); | |
} | |
// The following functions are overrides required by Solidity. | |
function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { | |
super._burn(tokenId); | |
} | |
function tokenURI(uint256 tokenId) | |
public | |
view | |
override(ERC721, ERC721URIStorage) | |
returns (string memory) | |
{ | |
return super.tokenURI(tokenId); | |
} | |
function supportsInterface(bytes4 interfaceId) | |
public | |
view | |
override(ERC721, AccessControl) | |
returns (bool) | |
{ | |
return super.supportsInterface(interfaceId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment