mirror of
https://github.com/rjNemo/epicNFT
synced 2026-06-06 01:46:38 +00:00
limit token redemption
This commit is contained in:
parent
344c3a63c5
commit
6f6c2e4812
4 changed files with 51 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ Demo NFT collection for learning purposes.
|
|||
3. https://testnets.opensea.io/collection/squarenft-lemz9demvy
|
||||
4. https://testnets.opensea.io/collection/squarenft-1xkwn34mdz
|
||||
5. https://testnets.opensea.io/collection/squarenft-qlxxnjj8mo (0x6c603E2bF856529A095dAbC9D9991f0c559e1855)
|
||||
6. https://testnets.opensea.io/collection/squarenft-noshuqlivp (0xAd9b1Faf6eDC836C16c7ff4e1E16012982030CE3)
|
||||
|
||||
## Square NFT
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -11,6 +11,7 @@ contract EpicNFT is ERC721URIStorage {
|
|||
Counters.Counter private _tokenIds;
|
||||
|
||||
event NewEpicNFTMinted(address sender, uint256 tokenID);
|
||||
uint256 private maxTokenAllowed = 50;
|
||||
|
||||
constructor() ERC721("SquareNFT", "SQUARE") {
|
||||
console.log("My first NFT contract! EPIC!!!");
|
||||
|
|
@ -76,7 +77,19 @@ contract EpicNFT is ERC721URIStorage {
|
|||
"Sailor"
|
||||
];
|
||||
|
||||
function nftMintedCount() public view returns (uint256) {
|
||||
return _tokenIds.current();
|
||||
}
|
||||
|
||||
function getMaxNFTAllowed() public view returns (uint256) {
|
||||
return maxTokenAllowed;
|
||||
}
|
||||
|
||||
function mint() public {
|
||||
require(
|
||||
_tokenIds.current() < maxTokenAllowed,
|
||||
"the maximum of EpicNFT has already been minted"
|
||||
);
|
||||
uint256 tokenID = _tokenIds.current();
|
||||
|
||||
string memory color = pickRandomWord(colors, "color", tokenID);
|
||||
|
|
|
|||
|
|
@ -6,11 +6,20 @@ async function main() {
|
|||
await contract.deployed();
|
||||
console.log("EpicNFT deployed to:", contract.address);
|
||||
|
||||
let count = await contract.nftMintedCount();
|
||||
console.log(count.toNumber());
|
||||
|
||||
let txn = await contract.mint();
|
||||
await txn.wait();
|
||||
|
||||
count = await contract.nftMintedCount();
|
||||
console.log(count.toNumber());
|
||||
|
||||
txn = await contract.mint();
|
||||
await txn.wait();
|
||||
|
||||
count = await contract.nftMintedCount();
|
||||
console.log(count.toNumber());
|
||||
}
|
||||
|
||||
// run the script
|
||||
|
|
|
|||
Loading…
Reference in a new issue