Created
February 16, 2022 16:03
-
-
Save himawari2021/2cf97d8fb8048b91bcf0232b0ef8905b to your computer and use it in GitHub Desktop.
Simple NFT
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol"; | |
contract MyNFT2 is ERC721 { | |
address owner; | |
uint public nextTokenId = 0; | |
string uri = "https://crypto.salamat.tokyo/sandbox/nft1/nft_metadata3.json?id="; | |
constructor() ERC721("Stop NFT MoneyMonger NFT", "SNFT"){ | |
owner = msg.sender; | |
} | |
function mint() public { | |
uint256 tokenId = nextTokenId; | |
nextTokenId = nextTokenId + 1; | |
super._safeMint(msg.sender, tokenId); | |
} | |
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { | |
return string(abi.encodePacked(uri, Strings.toString(tokenId))); | |
} | |
//万一画像の置き場所を変えたくなったとき用 | |
function changeUri(string memory _uri) public { | |
require(owner == msg.sender); | |
uri = _uri; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment