Skip to content

Instantly share code, notes, and snippets.

@omeganoob
Created October 26, 2021 16:26
Show Gist options
  • Save omeganoob/57d496eb1e8e62db199061c6070ea698 to your computer and use it in GitHub Desktop.
Save omeganoob/57d496eb1e8e62db199061c6070ea698 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.9+commit.e5eed63a.js&optimize=false&runs=200&gist=
//Contract based on [https://docs.openzeppelin.com/contracts/3.x/erc721](https://docs.openzeppelin.com/contracts/3.x/erc721)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
contract MedChainNFT is ERC721URIStorage, ERC721Enumerable, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
address contractAddress;
constructor(/*address marketplaceAddress*/) ERC721("MedChainNFT Token", "MCT") {
/*contractAddress = marketplaceAddress;*/
}
// string memory tokenURI is a string that should resolve to a JSON document that describes the NFT's metadata.
// An NFT's metadata is really what brings it to life, allowing it to have configurable properties, such as a name, description, image, and other attributes
function createToken(string memory _tokenURI)
public returns (uint256)
{
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(msg.sender, newItemId);
_setTokenURI(newItemId, _tokenURI);
/*setApprovalForAll(contractAddress, true);*/
return newItemId;
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal virtual override (ERC721, ERC721Enumerable)
{
super._beforeTokenTransfer(from, to, amount);
}
function _burn(uint256 tokenId)
internal override(ERC721, ERC721URIStorage)
{
super._burn(tokenId);
}
function supportsInterface(bytes4 interfaceId)
public view override(ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
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