Last active
September 25, 2021 12:22
-
-
Save aeither/ad2f80dcd185ec1c06929aac4f2038ce to your computer and use it in GitHub Desktop.
Basic NFT contract
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; | |
import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Counters.sol'; | |
import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/extensions/ERC721URIStorage.sol'; | |
import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol'; | |
contract GameItem is ERC721URIStorage, Ownable { | |
using Counters for Counters.Counter; | |
Counters.Counter private _tokenIds; | |
constructor() ERC721("GameItem", "ITM") { | |
} | |
function awardItem(address player) //, string memory tokenURI | |
public | |
returns (uint256) | |
{ | |
_tokenIds.increment(); | |
uint256 newItemId = _tokenIds.current(); | |
_mint(player, newItemId); | |
// _setTokenURI(newItemId, tokenURI); | |
return newItemId; | |
} | |
function mint(address _to) public onlyOwner { | |
super._mint(_to, _tokenIds.current()); | |
_tokenIds.increment(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment