-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A boilerplater ERC721 and an ERC998 Top Down composable and enumerabl…
…e NFT. ERC998 for Solidity ^0.8.2: info here: ethereum/EIPs#998 Most of the functionality is there. feel free to use.
- Loading branch information
Spazzaroth
committed
Sep 17, 2021
0 parents
commit 1f4105e
Showing
5 changed files
with
1,215 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.2; | ||
|
||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | ||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; | ||
import "@openzeppelin/contracts/security/Pausable.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; | ||
import "@openzeppelin/contracts/utils/Counters.sol"; | ||
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; | ||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | ||
|
||
contract Capture12 is ERC721, ERC721Enumerable, ERC721URIStorage, Pausable, Ownable, ERC721Burnable { | ||
using Counters for Counters.Counter; | ||
|
||
Counters.Counter private _tokenIdCounter; | ||
|
||
constructor() ERC721("ERC721", "NFT") {} | ||
|
||
event NFTMinted(uint indexed tokenId, address indexed to); | ||
function pause() public onlyOwner { | ||
_pause(); | ||
} | ||
|
||
function unpause() public onlyOwner { | ||
_unpause(); | ||
} | ||
|
||
function safeMint(address to, string calldata _ipfsUri) public returns(uint){ | ||
|
||
uint256 tokenId = _tokenIdCounter.current(); | ||
// require(_ipfsURI == whitelisted, "we should add some logic to whitelist this or something maybe?"); | ||
_safeMint(to, tokenId); | ||
_setTokenURI(tokenId, _ipfsUri); | ||
_tokenIdCounter.increment(); | ||
|
||
emit NFTMinted(tokenId, address(to)); | ||
|
||
return tokenId; | ||
} | ||
|
||
function _beforeTokenTransfer(address from, address to, uint256 tokenId) | ||
internal | ||
whenNotPaused | ||
override(ERC721, ERC721Enumerable) | ||
{ | ||
super._beforeTokenTransfer(from, to, tokenId); | ||
} | ||
|
||
// The following functions are overrides required by Solidity. | ||
|
||
function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { | ||
super._burn(tokenId); | ||
} | ||
|
||
// function addToPortfolio() { | ||
// uint256 tokenId = 6; | ||
// bytes memory tokenIdBytes = new bytes(32); | ||
// assembly { mstore(add(tokenIdBytes, 32), tokenId) } | ||
// safeTransferFrom(msg.sender, address(), 3, tokenIdBytes); | ||
// } | ||
|
||
function tokenURI(uint256 tokenId) | ||
public | ||
view | ||
override(ERC721, ERC721URIStorage) | ||
returns (string memory) | ||
{ | ||
return super.tokenURI(tokenId); | ||
} | ||
|
||
function supportsInterface(bytes4 interfaceId) | ||
public | ||
view | ||
override(ERC721, ERC721Enumerable) | ||
returns (bool) | ||
{ | ||
return super.supportsInterface(interfaceId); | ||
} | ||
} |
Oops, something went wrong.