Last active
September 19, 2022 06:31
-
-
Save danielkhoo/5f9f5e2a8169670f656a347d108bd1c1 to your computer and use it in GitHub Desktop.
Digital Collectible Contract on Ethereum at https://etherscan.io/address/0x6a12d4e7fd06996f8ca970a1840b6460d73d6c30
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.0 <0.9.0; | |
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
import "@openzeppelin/contracts/utils/Counters.sol"; | |
/** | |
* @title Digital Collectible | |
* @author Daniel Khoo | |
* @notice A dynamic NFT wrapper for digital collectibles on Instagram / Twitter with editable token URI | |
*/ | |
contract DigitalCollectible is ERC721URIStorage { | |
using Counters for Counters.Counter; | |
Counters.Counter private _tokenIds; | |
constructor() ERC721("DigitalCollectible", "DCB") {} | |
function mintItem(string memory tokenURI) public returns (uint256) { | |
uint256 tokenId = _tokenIds.current(); | |
_mint(msg.sender, tokenId); | |
_setTokenURI(tokenId, tokenURI); | |
_tokenIds.increment(); | |
return tokenId; | |
} | |
function setTokenURI(uint256 tokenId, string memory tokenURI) public { | |
require(msg.sender == ownerOf(tokenId), "Not owner of token"); | |
_setTokenURI(tokenId, tokenURI); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment