Last active
August 23, 2021 16:10
-
-
Save polluterofminds/73b5cbf219025dd653c16bd7c19d4cac to your computer and use it in GitHub Desktop.
PFPinatas 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
// contracts/PFPinatas.sol | |
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
import "@openzeppelin/contracts/utils/Counters.sol"; | |
import "@openzeppelin/contracts/utils/Strings.sol"; | |
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
contract PFPinatas is ERC721 { | |
using Strings for uint256; | |
using Counters for Counters.Counter; | |
Counters.Counter private _tokenIds; | |
string private baseURI; | |
constructor(string memory baseUri) ERC721("PFPinatas", "PFPP") { | |
baseURI = baseUri; | |
} | |
function tokenURI(uint256 tokenId) override view public returns (string memory) { | |
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; | |
} | |
function mintTo(address receiver) | |
public | |
returns (uint256) | |
{ | |
_tokenIds.increment(); | |
uint256 newItemId = _tokenIds.current(); | |
_safeMint(receiver, newItemId); | |
return newItemId; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment