-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8ed1da
commit 593d22f
Showing
2 changed files
with
68 additions
and
1 deletion.
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,67 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.2; //Do not change the solidity version as it negatively impacts submission grading | ||
|
||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | ||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; | ||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "@openzeppelin/contracts/utils/Counters.sol"; | ||
|
||
contract YourCollectible is | ||
ERC721, | ||
ERC721Enumerable, | ||
ERC721URIStorage, | ||
Ownable | ||
{ | ||
using Counters for Counters.Counter; | ||
|
||
Counters.Counter public tokenIdCounter; | ||
|
||
constructor() ERC721("YourCollectible", "YCB") {} | ||
|
||
function _baseURI() internal pure override returns (string memory) { | ||
return "https://ipfs.io/ipfs/"; | ||
} | ||
|
||
function mintItem(address to, string memory uri) public returns (uint256) { | ||
tokenIdCounter.increment(); | ||
uint256 tokenId = tokenIdCounter.current(); | ||
_safeMint(to, tokenId); | ||
_setTokenURI(tokenId, uri); | ||
return tokenId; | ||
} | ||
|
||
// The following functions are overrides required by Solidity. | ||
|
||
function _beforeTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 tokenId, | ||
uint256 quantity | ||
) internal override(ERC721, ERC721Enumerable) { | ||
super._beforeTokenTransfer(from, to, tokenId, quantity); | ||
} | ||
|
||
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, ERC721Enumerable, ERC721URIStorage) | ||
returns (bool) | ||
{ | ||
return super.supportsInterface(interfaceId); | ||
} | ||
} |
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