Created
April 7, 2022 13:58
-
-
Save arcticfloyd1984/2dcaba5c18ec8063fe63b554b2225590 to your computer and use it in GitHub Desktop.
arek-contract
This file contains 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.8.9; | |
import "@openzeppelin/contracts/metatx/ERC2771Context.sol"; | |
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
import "@openzeppelin/contracts/utils/Counters.sol"; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
contract Maybe2 is ERC2771Context, ERC721, Ownable { | |
using Strings for uint256; | |
string public baseURI; | |
string public baseExtension = ".json"; | |
uint256 public maxSupply = 8888; | |
uint256 private supply = 0; | |
bool public paused = false; | |
constructor( | |
address trustedForwarder, | |
string memory _name, | |
string memory _symbol, | |
string memory _initBaseURI | |
) ERC721(_name, _symbol) | |
ERC2771Context(trustedForwarder) { | |
setBaseURI(_initBaseURI); | |
} | |
function _msgSender() internal view override(Context, ERC2771Context) returns (address){ | |
return ERC2771Context._msgSender(); | |
} | |
function _msgData() internal view override(Context, ERC2771Context) returns (bytes calldata){ | |
return ERC2771Context._msgData(); | |
} | |
// internal | |
function _baseURI() internal view virtual override returns (string memory) { | |
return baseURI; | |
} | |
// public | |
function mintNFT() public { | |
require(!paused , "its not paused"); | |
_safeMint(_msgSender(), supply++); | |
} | |
function tokenURI(uint256 tokenId) | |
public | |
view | |
virtual | |
override | |
returns (string memory) | |
{ | |
require( | |
_exists(tokenId), | |
"ERC721Metadata: URI query for nonexistent token" | |
); | |
string memory currentBaseURI = _baseURI(); | |
return bytes(currentBaseURI).length > 0 | |
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) | |
: ""; | |
} | |
function setBaseURI(string memory _newBaseURI) public onlyOwner { | |
baseURI = _newBaseURI; | |
} | |
function setBaseExtension(string memory _newBaseExtension) public onlyOwner { | |
baseExtension = _newBaseExtension; | |
} | |
function pause(bool _state) public onlyOwner { | |
paused = _state; | |
} | |
function withdraw(uint amount) public payable onlyOwner { | |
payable(_msgSender()).transfer(amount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment