Skip to content

Instantly share code, notes, and snippets.

@EtherTyper
Created February 15, 2022 00:40
Show Gist options
  • Save EtherTyper/ce7fd5619fcbd5cd0d9d3de0b562ebb8 to your computer and use it in GitHub Desktop.
Save EtherTyper/ce7fd5619fcbd5cd0d9d3de0b562ebb8 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.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// contracts/GameItem.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract GameItem is ERC721URIStorage {
using Counters for Counters.Counter;
Counters.Counter private tokenIds;
constructor() ERC721("True Art", "MONKE") {
awardItem(0x9b78dcf2FF15C32F1E33673268e5aC0f5270DA95, "https://i.ytimg.com/vi/eMonGZEB0Ik/maxresdefault.jpg");
}
function awardItem(address player, string memory tokenURI)
private
returns (uint256)
{
uint256 newItemId = tokenIds.current();
_mint(player, newItemId);
_setTokenURI(newItemId, tokenURI);
tokenIds.increment();
return newItemId;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment