Skip to content

Instantly share code, notes, and snippets.

@jack126guy
Last active January 21, 2022 12:07
Show Gist options
  • Save jack126guy/b2152dab45a7b58285eda47ef76d1dc3 to your computer and use it in GitHub Desktop.
Save jack126guy/b2152dab45a7b58285eda47ef76d1dc3 to your computer and use it in GitHub Desktop.
Ethereum smart contract for NFTs representing media that is Definitely Unique™
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract DefinitelyUniqueMediaBlock is ERC721, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _lastTokenId;
constructor() public ERC721("Definitely Unique Media Block", "DUMB") {
}
function mint() public onlyOwner returns (uint256) {
_lastTokenId.increment();
uint256 newTokenId = _lastTokenId.current();
_safeMint(owner(), newTokenId);
return newTokenId;
}
function tokenURI(uint256 /* tokenId */) public view virtual override returns (string memory) {
// JSON metadata referencing an embedded 1x1 pixel PNG image
return "data:application/json;base64,eyJuYW1lIjoiRGVmaW5pdGVseSBVbmlxdWUgTWVkaWEgQmxvY2siLCJkZXNjcmlwdGlvbiI6IkEgdG90YWxseSB1bmlxdWUgaW1hZ2UgdG9rZW4iLCJpbWFnZSI6ImRhdGE6aW1hZ2UvcG5nO2Jhc2U2NCxpVkJPUncwS0dnb0FBQUFOU1VoRVVnQUFBQUVBQUFBQkNBSUFBQUNRZDFQZUFBQUFERWxFUVZRSTEyUDQvLzgvQUFYK0F2N2N6Rm5uQUFBQUFFbEZUa1N1UW1DQyJ9";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment