-
-
Save matthsena/21362cde23d87c920feb2cc72a8d5512 to your computer and use it in GitHub Desktop.
This file contains 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 "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
contract CreateNFT is ERC721URIStorage { | |
uint256 public maxSupply = 85; | |
uint256 public totalSupply = 0; | |
struct Invite { | |
uint256 unity; | |
address owner; | |
string imageURI; | |
} | |
Invite[] public invites; | |
constructor() ERC721("Taste Residencial", "TASTE") {} | |
function mint(uint256 _unity, address _address, string memory tokenURI) public payable { | |
uint256 supply = totalSupply; | |
require(supply <= maxSupply); | |
invites.push( | |
Invite(_unity, _address, tokenURI) | |
); | |
totalSupply = totalSupply + 1; | |
_mint(_address, _unity); | |
_setTokenURI(_unity, tokenURI); | |
} | |
function getTokens() public view returns (Invite[] memory) { | |
return invites; | |
} | |
function getTokenByUnity(uint256 _unity) public view returns (Invite memory) { | |
Invite memory currentInvite; | |
for (uint256 i = 0; i < totalSupply; i ++) { | |
if (invites[i].unity == _unity) { | |
currentInvite = invites[i]; | |
break; | |
} | |
} | |
return currentInvite; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment