Last active
December 15, 2021 02:49
-
-
Save robsoncezario/bdfee5779ba7c136df8d4d0d78951bd4 to your computer and use it in GitHub Desktop.
NFT.sol for solidity ^0.8.10
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: MIT | |
pragma solidity ^0.8.10; | |
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
import "@openzeppelin/contracts/utils/Counters.sol"; | |
contract NFT is ERC721, ERC721URIStorage { | |
using Counters for Counters.Counter; | |
Counters.Counter private _tokenIds; | |
address private marketplaceAddress; | |
constructor(address _marketplaceAddress) ERC721("CollectibleNFT", "NFT") { | |
marketplaceAddress = _marketplaceAddress; | |
} | |
function mint(string memory _tokenURI) | |
public | |
returns (uint256) | |
{ | |
_tokenIds.increment(); | |
uint256 newItemId = _tokenIds.current(); | |
_mint(msg.sender, newItemId); | |
_setTokenURI(newItemId, _tokenURI); | |
setApprovalForAll(marketplaceAddress, true); | |
return newItemId; | |
} | |
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 _baseURI() | |
internal | |
view | |
override | |
returns (string memory) | |
{ | |
return "http://localhost:5000/static/"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment