Last active
May 10, 2024 02:25
-
-
Save QingyangKong/f90dafdb0aa28d5e347084c1826fc3e9 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.19; | |
import "@openzeppelin/[email protected]/token/ERC721/ERC721.sol"; | |
import "@openzeppelin/[email protected]/token/ERC721/extensions/ERC721URIStorage.sol"; | |
contract MyNFT is ERC721, ERC721URIStorage { | |
uint256 private _nextTokenId; | |
string public constant METADATA_URI = "ipfs://QmXw7TEAJWKjKifvLE25Z9yjvowWk2NWY3WgnZPUto9XoA"; | |
constructor() | |
ERC721("MyNFT", "MNT") | |
{} | |
function safeMint(address to) public { | |
uint256 tokenId = _nextTokenId++; | |
_safeMint(to, tokenId); | |
_setTokenURI(tokenId, METADATA_URI); | |
} | |
function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { | |
super._burn(tokenId); | |
} | |
// The following functions are overrides required by Solidity. | |
function tokenURI(uint256 tokenId) | |
public | |
view | |
override(ERC721, ERC721URIStorage) | |
returns (string memory) | |
{ | |
return super.tokenURI(tokenId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment