Skip to content

Instantly share code, notes, and snippets.

@QingyangKong
Last active May 10, 2024 02:25
Show Gist options
  • Save QingyangKong/f90dafdb0aa28d5e347084c1826fc3e9 to your computer and use it in GitHub Desktop.
Save QingyangKong/f90dafdb0aa28d5e347084c1826fc3e9 to your computer and use it in GitHub Desktop.
// 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