Last active
November 24, 2022 12:04
-
-
Save matthsena/28826a42f240dd72db1edf6a4f50b5f1 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 metadataURI; | |
} | |
Invite[] public invites; | |
constructor() ERC721("Taste Residencial", "TASTE") {} | |
function mint(uint256 _unity, address _address, string memory metadataURI) public payable { | |
uint256 supply = totalSupply; | |
require(supply <= maxSupply); | |
invites.push( | |
Invite(_unity, _address, metadataURI) | |
); | |
totalSupply = totalSupply + 1; | |
_mint(_address, _unity); | |
_setTokenURI(_unity, metadataURI); | |
} | |
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