Skip to content

Commit 949fc20

Browse files
committed
Merge branch 'main' of https://github.com/Markkos89/academy into staging-merge-2
2 parents 68cfc9e + 60142c9 commit 949fc20

File tree

4 files changed

+91
-30
lines changed

4 files changed

+91
-30
lines changed

src/components/Banner.tsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { Center, Flex, Text, chakra } from "@chakra-ui/react";
2+
import { CloseIcon } from "@chakra-ui/icons";
3+
4+
const Banner = () => {
5+
const dismissBanner = () => {
6+
localStorage.setItem("bannerDismissed", "true");
7+
const banner = document.getElementById("banner");
8+
if (banner) {
9+
banner.style.display = "none";
10+
}
11+
};
12+
13+
return (
14+
<Center
15+
py="2"
16+
px="3"
17+
bgGradient="linear(to-r,cyan.700, purple.500)"
18+
color="white"
19+
textAlign="center"
20+
id="banner"
21+
>
22+
<Flex align="center" fontSize="sm">
23+
<Text fontWeight="medium" maxW={{ base: "32ch", md: "unset" }}>
24+
Acamdey V2 is coming soon 👀... Subscribe to our newsletter for
25+
updates!
26+
</Text>
27+
<chakra.a
28+
flexShrink={0}
29+
href="https://developerdao.substack.com/s/probably-nothing"
30+
target="_blank"
31+
ms="6"
32+
bg="blackAlpha.300"
33+
color="whiteAlpha.900"
34+
fontWeight="semibold"
35+
px="3"
36+
py="1"
37+
rounded="base"
38+
>
39+
Subscribe now!{" "}
40+
</chakra.a>
41+
<chakra.button
42+
onClick={dismissBanner}
43+
ms="6"
44+
color="whiteAlpha.900"
45+
fontWeight="semibold"
46+
px="3"
47+
py="1"
48+
rounded="base"
49+
>
50+
<CloseIcon />
51+
</chakra.button>
52+
</Flex>
53+
</Center>
54+
);
55+
};
56+
57+
export default Banner;

src/components/Layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Box } from "@chakra-ui/react";
22
import Topbar from "./Topbar";
33
import Footer from "./footer/Footer";
44
import { NextSeo } from "next-seo";
5+
import Banner from "./Banner";
56

67
interface Props {
78
children: React.ReactNode;
@@ -46,6 +47,7 @@ export default function Layout({ children, title, description }: Props) {
4647
},
4748
]}
4849
/>
50+
<Banner />
4951
<Topbar />
5052
<Box
5153
as="main"

src/pages/lessons/projects/3.mdx

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ following steps:
9797
- Write scripts for deployment
9898
- Exploring additional functionalities and possibilities with tiered NFTs ... in
9999
the smart contract!
100-
- Showcasing and trading your tiered NFTs on a public marketplace
100+
- Securely manage sensitive environment variables
101+
- Showcasing your tiered NFTs on a public marketplace
101102

102103
### Developer tooling
103104

@@ -179,7 +180,7 @@ last prompt. If they didn’t install or we accidentally chose ‘n’, we can a
179180
install them manually with:
180181
181182
```bash
182-
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox @nomicfoundation/hardhat-chai-matchers
183+
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
183184
```
184185
185186
</Callout>
@@ -245,6 +246,8 @@ contracts. We'll write our smart contract step by step in five stages:
245246
Let’s get started by inheriting OpenZeppelin's ERC721.sol like we did last time.
246247
We add a constructor to our contract, which will mirror the one from ERC721.sol.
247248
249+
{/* @wolovim optional line?: Unlike in our *Basic NFT* lesson, where we added a third parameter to the constructor for storing the token's baseURI, we will have a different approach this time, which we will come to later. */}
250+
248251
```solidity
249252
// SPDX-License-Identifier: MIT
250253
pragma solidity 0.8.12;
@@ -267,7 +270,7 @@ remember what `++` does to our total supply?
267270
// SPDX-License-Identifier: MIT
268271
pragma solidity 0.8.12;
269272
270-
import '@openzeppelin/contracts/token/ERC721/ERC721.sol'
273+
import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
271274
272275
contract TierNFT is ERC721 {
273276
@@ -939,11 +942,11 @@ async function main() {
939942
COLLECTION_NAME,
940943
COLLECTION_SYMBOL,
941944
)
942-
await contract.deployed()
945+
946+
await contract.waitForDeployment()
943947
// Print our newly deployed contract address
944-
console.log(`Contract deployed to ${contract.address}`)
948+
console.log("Contract deployed at ", await contract.getAddress())
945949
}
946-
947950
/** Run Main function - Do not change **/
948951
main().catch((error) => {
949952
console.error(error)
@@ -956,17 +959,17 @@ main().catch((error) => {
956959
- With `const COLLECTION_NAME = "TierNFT"` and
957960
`const COLLECTION_SYMBOL = "Tier"` - we define the _name_ and _symbol_ to pass
958961
to the constructor for the deployment.
959-
- `hre.ethers.getContractFactory(CONTRACT_NAME)` - this asks Hardhat Runtime
960-
Environment to get us a contract factory for our contract specified by
961-
`CONTRACT_NAME`. A contract factory is a template that allows us to deploy
962+
- `hre.ethers.getContractFactory(CONTRACT_NAME)` - this asks `hre` (Hardhat
963+
Runtime Environment) to get us a contract factory for our contract specified
964+
by `CONTRACT_NAME`. A contract factory is a template that allows us to deploy
962965
instances of that contract, which allows many advantages.
963966
- `contractFactory.deploy` - we are asking the contract factory to deploy an
964967
instance of our contract. This is the deploy transaction!
965968
- `COLLECTION_NAME, COLLECTION_SYMBOL` - these are the parameters for our
966969
contract's constructor function to set up its initial state.
967-
- `await contract.deployed()` - waits for the transaction to be approved by the
968-
network validators, and confirms that the deployment of the contract was
969-
successful, telling us that it's ready for use on the blockchain.
970+
- `await contract.waitForDeployment()` - waits for the transaction to be
971+
approved by the network validators, and confirms that the deployment of the
972+
contract was successful, telling us that it's ready for use on the blockchain.
970973
- Running the `main().catch( … )` script at the very end makes sure that all the
971974
previous code is executed, and also logs any errors, and prints them to the
972975
console.
@@ -1017,6 +1020,8 @@ seed phrases!**
10171020

10181021
### Getting Some Testnet Funds
10191022

1023+
{/* @wolovim, maybe we should give a couple of testnet options, just in case. what do you think? */}
1024+
10201025
A testnet is a sandbox environment where developers can test, create and modify
10211026
functionalities, monitor and simulate a mainnet blockchain's network
10221027
performance, fix bugs and other network failures without having to worry about
@@ -1035,17 +1040,13 @@ can get tokens for multiple testnets.
10351040

10361041
### Personal Security
10371042

1038-
Take your time to understand the _good practices_ in this section. Before we
1039-
deploy, we need to add a `.env` file to our root folder to make sure we are
1040-
**not pushing and therefore exposing our private keys in public repositories**.
1041-
10421043
For your wallet's private key, the most sensitive data of the project, you need
10431044
to open Metamask. Click on the three dots next to your _Account Name_, and then
1044-
on _Account Details_, click on _Export Private Key_. It will ask for your
1045-
Metamask password, the one you use to log in to your wallet each session, not
1046-
your seed phrase. It also shows you a notice so you know that you are entering
1047-
the _danger zone_. Confirm and you'll be able to copy your private key. Add your
1048-
private key into the `.env` file like so:
1045+
on _Account Details_, click on _Show Private Key_. It will ask for your Metamask
1046+
password, the one you use to log in to your wallet each session, not your seed
1047+
phrase. It also shows you a warning to 'Never disclose this key'. Confirm and
1048+
you'll be able to copy your private key. Add your private key into the `.env`
1049+
file like so:
10491050

10501051
```bash
10511052
PRIVATE_KEY=f8abc629b...
@@ -1113,29 +1114,30 @@ async function main() {
11131114
const contractFactory = await hre.ethers.getContractFactory(CONTRACT_NAME);
11141115
const contract = await contractFactory.attach(CONTRACT_ADDRESS);
11151116
// Print our newly deployed contract address
1116-
console.log(`Attached contract: ${contract.address}`);
1117+
console.log("Attached contract ", await contract.getAddress());
11171118

11181119
// Call the mint function for Tier 0
11191120
let txn = await contract.mint({
1120-
value: hre.ethers.utils.parseEther(VALUE_TIER_0),
1121+
value: hre.ethers.parseEther(VALUE_TIER_0),
11211122
});
11221123
await txn.wait(); // Wait for the NFT to be minted
11231124
console.log("Minted a Tier 0 NFT!");
11241125

11251126
// Call the mint function for Tier 1
11261127
txn = await contract.mint({
1127-
value: hre.ethers.utils.parseEther(VALUE_TIER_1),
1128+
value: hre.ethers.parseEther(VALUE_TIER_1),
11281129
});
11291130
await txn.wait(); // Wait for the NFT to be minted
11301131
console.log("Minted a Tier 1 NFT!");
11311132

11321133
// Call the mint function for Tier 2
11331134
txn = await contract.mint({
1134-
value: hre.ethers.utils.parseEther(VALUE_TIER_2),
1135+
value: hre.ethers.parseEther(VALUE_TIER_2),
11351136
});
11361137
await txn.wait(); // Wait for the NFT to be minted
11371138
console.log("Minted a Tier 2 NFT!");
11381139

1140+
// Print total number of minted NFTs
11391141
let totalSupply = await contract.totalSupply();
11401142
console.log("Collection's new totalSupply: ", totalSupply);
11411143
}
@@ -1151,10 +1153,10 @@ main().catch((error) => {
11511153
sure that we are not deploying the contract again. Instead we need Hardhat to
11521154
use the contract addresss we just deployed to the testnet.
11531155
- `let txn = await contract.mint(...` is calling the mint function.
1154-
- `value: hre.ethers.utils.parseEther(VALUE_TIER_0)` - defines the value that we
1155-
want to send to the mint function. This defines which _Tier_ we get.
1156-
- `ethers.utils.parseEther` - here we use _Ethers_ to translate the value into
1157-
wei i.e. multiply it with 10\*\*18
1156+
- `value: hre.ethers.parseEther(VALUE_TIER_0)` - defines the value that we want
1157+
to send to the mint function. This defines which _Tier_ we get.
1158+
- `ethers.parseEther` - here we use _Ethers_ to translate the value into wei
1159+
i.e. multiply it with 10\*\*18
11581160
- `let totalSupply = await contract.totalSupply()` - is calling the
11591161
`totalSupply()` function to check if the 3 NFTs minted correctly.
11601162
<br />

src/utils/questions/lesson-3/4-deploy-scripts/Q2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"question": "What does the `await contract.deployed()` line do in the code?",
2+
"question": "What does the `await contract.waitForDeployment()` line do in the code?",
33
"options": [
44
{
55
"answer": " It deploys the contract to the blockchain."

0 commit comments

Comments
 (0)