Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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