Skip to content

Instantly share code, notes, and snippets.

@mako34
Last active June 26, 2021 19:03
Show Gist options
  • Save mako34/1661b4d69d30a2915296c31bbd72e281 to your computer and use it in GitHub Desktop.
Save mako34/1661b4d69d30a2915296c31bbd72e281 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.6+commit.11564f7e.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract T3KN4RK1ST is ERC721URIStorage{
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
mapping(string => uint8) hashes;
constructor() ERC721("T3KN4RK1ST", "TKT") {}
function awardItem(address recipient, string memory hash, string memory metadata) public returns (uint256){
require(hashes[hash] != 1);
hashes[hash] = 1;
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(recipient, newItemId);
_setTokenURI(newItemId, metadata);
return newItemId;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment