Skip to content

Instantly share code, notes, and snippets.

@danielkhoo
Last active September 19, 2022 06:31
Show Gist options
  • Save danielkhoo/5f9f5e2a8169670f656a347d108bd1c1 to your computer and use it in GitHub Desktop.
Save danielkhoo/5f9f5e2a8169670f656a347d108bd1c1 to your computer and use it in GitHub Desktop.
//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