Skip to content

Commit

Permalink
added an event
Browse files Browse the repository at this point in the history
  • Loading branch information
maxslimb committed Jun 18, 2022
1 parent 8742d2e commit 9db8710
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 4 additions & 1 deletion contracts/MyEpicNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ string baseSvg = "<svg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='x
string[] secondWords = ["Panipuri", "palak", "paneer", "sandwich", "burger", "cupcake","lime","maggie","coldice","pizza","donuts","muffin","high","pasta","pancakes","Pie","banana","bagel","Cheetos","Kiwi"];
string[] thirdWords = ["jurrasic", "ghostbusters", "kgf", "gold", "silver", "bronze","kingkong","sonic","housefull","dhamal","dhol","prithviraj","smarat","shivaji","jodha","padmavat","akbar","Coolie","shandaar","adam","Avatar"];

event NewEpicNFTMinted(address sender, uint256 tokenId);

function pickRandomFirstWord(uint256 tokenId) public view returns (string memory) {
// I seed the random generator. More on this in the lesson.
Expand Down Expand Up @@ -61,7 +62,7 @@ function pickRandomFirstWord(uint256 tokenId) public view returns (string memory
string memory first = pickRandomFirstWord(newItemId);
string memory second = pickRandomSecondWord(newItemId);
string memory third = pickRandomThirdWord(newItemId);

string memory combinedWord = string(abi.encodePacked(first, second, third));

string memory finalSvg = string(abi.encodePacked(baseSvg, combinedWord, "</text></svg>"));
Expand Down Expand Up @@ -108,5 +109,7 @@ function pickRandomFirstWord(uint256 tokenId) public view returns (string memory
console.log("An NFT w/ ID %s has been minted to %s", newItemId, msg.sender);
// Increment the counter for when the next NFT is minted.
_tokenIds.increment();

emit NewEpicNFTMinted(msg.sender, newItemId);
}
}
6 changes: 0 additions & 6 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ const main = async () => {
await txn.wait()
console.log("Minted NFT #1")

// Mint another NFT for fun.
txn = await nftContract.makeAnEpicNFT()
// Wait for it to be mined.
await txn.wait()
console.log("Minted NFT #2")

};

const runMain = async () => {
Expand Down

0 comments on commit 9db8710

Please sign in to comment.