Skip to content

Commit d3aa437

Browse files
committed
Merge branch 'main' of https://github.com/Markkos89/academy into staging
2 parents 5446758 + b585224 commit d3aa437

File tree

2 files changed

+56
-54
lines changed
  • src
    • pages/lessons/projects
    • utils/questions/lesson-2/4-nft-id

2 files changed

+56
-54
lines changed

src/pages/lessons/projects/2.mdx

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ assets.
9595
Now that we know they can be much more than just an image, what are we waiting
9696
for?
9797

98-
**By the end of this lesson we'll have learned a lot.** A breakdown of the steps
99-
to get there is:
98+
## Lesson breakdown
99+
100+
By the end of this lesson we'll have learned a lot. A breakdown of the steps to
101+
get there is:
100102

101103
- set up our development environment
102104
- install dependencies
@@ -109,9 +111,11 @@ to get there is:
109111
- _mint_, i.e. create our very own NFT
110112
- see our NFT in a public marketplace
111113

112-
**To achieve this, we'll need diverse developer tools.** We'll also need to open
113-
a couple of accounts as we progress from one development environment to the
114-
next. We'll be using:
114+
## Dev tools
115+
116+
To achieve this, we'll need diverse developer tools. We'll also need to open a
117+
couple of accounts as we progress from one development environment to the next.
118+
We'll be using:
115119

116120
- a console
117121
- an IDE
@@ -240,7 +244,7 @@ last prompt. If they didn’t install or we accidentally chose ‘n’, we can a
240244
install them manually with:
241245

242246
```bash
243-
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox @nomicfoundation/hardhat-chai-matchers
247+
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
244248
```
245249

246250
</Callout>
@@ -266,7 +270,7 @@ rm scripts/*.js
266270
rm test/*.js
267271
```
268272

269-
We now need to add our last dependency (OpenZeppelin contracts):
273+
We now need to add our last dependency - OpenZeppelin contracts:
270274

271275
```bash
272276
npm install @openzeppelin/contracts
@@ -323,8 +327,8 @@ contract ProjectNFT {
323327

324328
If you’ve been through our [first project](/lessons/projects/1), you’ll remember
325329
the first lines defines our copyright license, the second one defines the
326-
solidity version we are going to be using for this contract and the last two
327-
lines are how we declare a smart contract in solidity.
330+
Solidity version we are going to be using for this contract and the last two
331+
lines are how we declare a smart contract in Solidity.
328332

329333
With an empty project, we can now start adding what we need to create our
330334
awesome NFT collection. ERC721, the formal specification to follow for NFTs, has
@@ -405,8 +409,8 @@ contract ProjectNFT is ERC721 {
405409
}
406410
```
407411

408-
We made our totalSupply variable private and it will store the exact number of
409-
NFTs that have been minted. In the next step we will use this variable to
412+
We made our `totalSupply` variable `private` and it will store the exact number
413+
of NFTs that have been minted. In the next step we will use this variable to
410414
identify each new NFT that’s created.
411415

412416
<SideDrawer
@@ -479,9 +483,9 @@ Identifier), a web address if you prefer, that points to something on the
479483
internet, whatever we want it to be. e.g. a video, an image.
480484

481485
OpenZeppelin ERC721 contract provides us a way to create unique URIs from the
482-
IDs of the NFTs. It gives a way to define a base path for a web address and just
483-
attaches the token ID at the end of it. So, if you wanted, you could upload your
484-
NFT info (we'll look at how we store that later) to any web address, say
486+
IDs of the NFTs. It gives a way to define a 'base path' for a web address and
487+
just attaches the token ID at the end of it. So, if you wanted, you could upload
488+
your NFT info (we'll look at how we store that later) to any web address, say
485489
`www.my-site.com/my-nft-collection` and number each file with the corresponding
486490
ID (1, 2, 3, 4…).
487491

@@ -678,7 +682,7 @@ To achieve this, you need to add the json files all at the same time, as a
678682
**folder** into Pinata, and then you get a CID for the folder, which you can
679683
reference with the filenames at the end for each file.
680684

681-
Remember `_baseURI` function in our solidity contract? The one that was used to
685+
Remember `_baseURI` function in our Solidity contract? The one that was used to
682686
create the NFT tokenURI? There's where we are going to get the Pinata link with
683687
the CID to our folder.
684688

@@ -742,7 +746,7 @@ const hre = require("hardhat");
742746
const CONTRACT_NAME = "ProjectNFT";
743747

744748
// The 3 parameters for our smart contract's constructor (CHANGE THESE to your own NFT name and description)
745-
const NFT_NAME = "Academy";
749+
const NFT_NAME = "D_D Academy";
746750
const NFT_DESCRIPTION = "D_D Academy Basic NFT Collection";
747751

748752
// CHANGE THIS if you created your own images/JSONs:
@@ -762,10 +766,10 @@ async function main() {
762766
);
763767

764768
// We wait for it to be deployed to the blockchain
765-
await contract.deployed();
769+
await contract.waitForDeployment();
766770

767771
// We print the contract's address to the console
768-
console.log(`${CONTRACT_NAME} deployed to: ${contract.address}`);
772+
console.log(`${CONTRACT_NAME} deployed to: `, await contract.getAddress());
769773

770774
// --> ( We'll add more stuff here later ) <--
771775
}
@@ -786,13 +790,13 @@ and a Base URI for our files. With that info set at the top, the script deploys
786790
the contract, waits for it to be deployed and then prints the address of our
787791
deployed contract to the console.
788792

789-
Before we run our script, we need to tell Hardhat what solidity version our
793+
Before we run our script, we need to tell Hardhat what Solidity version our
790794
contracts are using. For that, we need to go into the `hardhat.config.js` file
791-
in our root folder. Find the line that says `solidity: '0.8.xx',` and replace
792-
the `0.8.xx` for the pragma used in our contract: `0.8.12`.
795+
in our project's root folder. Find the line that says `solidity: '0.8.xx',` and
796+
replace the `0.8.xx` for the pragma used in our contract: `0.8.12`.
793797

794-
We could have used a range of solidity versions e.g. `^0.8.0` in our contract,
795-
but we like to promote best practices by choosing a fixed solidity version and
798+
We could have used a range of Solidity versions e.g. `^0.8.0` in our contract,
799+
but we like to promote best practices by choosing a fixed Solidity version and
796800
knowing beforehand nothing is going to change in our bytecode if a new version
797801
in that range is released.
798802

@@ -868,30 +872,27 @@ going to run the deploy again, but this time to a testnet.
868872
What is a testnet? It is a basically a whole running blockchain, but it runs
869873
only so people can try stuff out. On it, you have ETH, NFTs, or other tokens but
870874
they have no monetary value. This way, you can develop and test your contracts
871-
without fear of losing anything valuable. For the moment, we are choosing to do
872-
this on \*Goerli\*\* testnet. It's one of the many of Ethereum testnets.
873-
874-
- We had wanted to use the Sepolia testnet, because Goerli is going to be
875-
deprecated by the end of 2023, but we're temporarily restricted, because there
876-
isn't yet a compatible NFT test hosting site for Sepolia. We will update the
877-
lesson accordingly when this availability arrives.
875+
without fear of losing anything valuable. Ethereum has many testnets, and you
876+
might notice that we used _Goerli_ testnet. But we suggest that you use
877+
_Sepolia_ testnet, now that it has compatible NFT hosting support, and longevity
878+
for app development that _Goerli_ won't outlast.
878879

879880
Before we go any further, let's take an extra step for precaution. In the next
880881
project we'll learn how to use collaborative tools to store our projects, but
881-
for now, let's open our root directory's `.gitignore` file an add this line
882-
anywhere:
882+
for now, let's open our root directory's `.gitignore` file and add this line:
883883

884884
```bash
885885
hardhat.config.js
886886
```
887887

888888
In order to deploy to a real testnet we'll need:
889889

890-
- An Ethereum wallet that can connect to Goerli [Metamask](https://metamask.io/)
891-
is often used
892-
- Some Goerli-ETH. You can ask for some in a faucet, it's free, although some
893-
are faster than others! Options: [#1](https://goerlifaucet.com/),
894-
[#2](https://faucets.chain.link/goerli), [#3](https://faucet.paradigm.xyz/)
890+
- An Ethereum wallet that can connect to Sepolia.
891+
[Metamask](https://metamask.io/) is often used
892+
- Some Sepolia-ETH. You can ask for some in a faucet, it's free, although some
893+
are faster than others! Options: [#1](https://sepoliafaucet.com/),
894+
[#2](https://testnet-faucet.com/sepolia/),
895+
[#3](https://faucet.quicknode.com/ethereum/sepolia)
895896
- An API Key from an Ethereum RPC Node Provider
896897
([Alchemy](https://www.alchemy.com/), [Infura](https://infura.io/),
897898
[Ankr](https://rpc.ankr.com/eth_goerli))
@@ -922,9 +923,10 @@ one of the Ethereum RPC Node Providers. Alchemy and Infura are the most used.
922923
And Ankr has a 'community endpoint' which doesn't require a dedicated sign up,
923924
to list a few options.
924925

925-
After signing up, you'll be asked to create an App. Be sure to select the Goerli
926-
network there. When the app is created, you'll see a 'View Key' button, or
927-
similar. Press it and copy the HTTP link, we'll use it in our next step.
926+
After signing up, you'll be asked to create an App. Be sure to select the
927+
Sepolia network there. When the app is created, you'll see a 'View Key' button,
928+
or similar. Press it and copy the HTTP link, we'll use it as the API-KEY in our
929+
next step.
928930

929931
With our wallet funded fake ETH, we can go ahead and change our Hardhat
930932
configuration file. Go into your project's main directory and open
@@ -933,8 +935,7 @@ configuration file. Go into your project's main directory and open
933935
We are going to replace our file with this:
934936

935937
```jsx
936-
require("@nomicfoundation/hardhat-chai-matchers");
937-
require("@nomiclabs/hardhat-ethers");
938+
require("@nomicfoundation/hardhat-toolbox");
938939

939940
const WALLET_PRIVATE_KEY = "YOUR-PRIVATE-KEY-DONT-SHARE";
940941

@@ -954,19 +955,19 @@ module.exports = {
954955
};
955956
```
956957

957-
And you need to fill those 2 global variables with your own for hardhat to
958-
communicate correctly to the network.
958+
And you'll need to set the two global variables using the `const` keyword with
959+
your own values for Hardhat to communicate correctly to the network.
959960

960961
We have already gone through how to get your API KEY.
961962

962963
For your wallet's private key, the most sensitive data of the project, you need
963-
to open Metamask, click on the three dots next to your Account Name, and then on
964-
Account Details, then click on Export Private Key. It will ask for your Metamask
965-
password (the one you use to open it, NOT your seed phrase). It also shows you a
966-
notice so you know that you are entering the danger zone. Confirm and you'll be
967-
able to copy your private key. Paste it in to our `hardhat.config.js`
964+
to open Metamask, click on the three dots next to your _Account Name_, and then
965+
on _Account Details_, then click on _Export Private Key_. It will ask for your
966+
Metamask password - the one you use to open it, NOT your seed phrase. It also
967+
issues a warning to 'Never disclose this key'. Confirm and you'll be able to
968+
copy your private key. Paste it in to our `hardhat.config.js`
968969

969-
Please, if you are already a developer and you plan to use Git to store your
970+
Please, if you are already a developer, and you plan to use Git to store your
970971
project, don't store your `hardhat.config.js` on it, because you will have your
971972
private key there.
972973

@@ -982,7 +983,7 @@ private key there.
982983
</SideDrawer>
983984
<br />
984985

985-
Ok. We are ready, let's deploy to the Goerli testnet!
986+
Ok. We are ready, let's deploy to the Sepolia testnet!
986987

987988
Now we need to run our deploy.js script and the deployment is going to cost us
988989
some ETH - test ETH, don't worry - from our wallet, since we are storing
@@ -994,7 +995,7 @@ deploy, delete all the lines we added to test the minting.
994995
Run:
995996

996997
```bash
997-
npx hardhat run scripts/deploy.js --network goerli
998+
npx hardhat run scripts/deploy.js --network sepolia
998999
```
9991000

10001001
This is the output i got in my console:
@@ -1010,7 +1011,7 @@ next project we will learn about tools to collaborate and store your projects
10101011
online.
10111012

10121013
So now we can go and explore the chain to find your contract (and mine too!).
1013-
Just go to [Goerli Etherscan](https://goerli.etherscan.io/) (or
1014+
Just go to [Sepolia Etherscan](https://sepolia.etherscan.io/) (or
10141015
[Opensea](https://testnets.opensea.io/)) and search for the address of our
10151016
deployed contract.
10161017

src/utils/questions/lesson-2/4-nft-id/Q5.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"answer": "Because it looks more professional"
66
},
77
{
8-
"answer": "Because you need to keep your personal assets separate from your development funds"
8+
"answer": "Because you need to keep your personal assets separate from your development funds",
9+
"correct": true
910
},
1011
{
1112
"answer": "Every milisecond counts for a dev, and separate wallets are faster to connect to the blockchain"

0 commit comments

Comments
 (0)