Skip to content

Commit c662b34

Browse files
committed
Clarify setup steps
1 parent 70bcd30 commit c662b34

File tree

1 file changed

+50
-20
lines changed

1 file changed

+50
-20
lines changed

lessons/projects/4.mdx

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,30 @@ it's an important tool to ensuring your contract will work as expected.
3737

3838
## Let's Get Started
3939

40-
### Setting up our project
40+
### Setting up our project dependencies
4141

4242
If you have an existing project from your previous work on the TierNFT lesson,
43-
you have all the Hardhat dependencies installed in order to run our testing
44-
suite.
43+
you have all the Hardhat dependencies installed.
4544

46-
Otherwise, let's create a new Hardhat project, copy in the contract and jump
47-
into some testing!
45+
Otherwise let's create a new Hardhat project and copy in the contract which
46+
we'll be testing.
4847

49-
1. Please refer to Lesson 2 and search for `npx hardhat` in the "Create your
50-
project" section to get your project going. After running through that
51-
section you'll have a working Hardhat project for the next steps.
48+
To create a new project, please refer to _Lesson 3 - Tier NFTs_ and search for
49+
the “First things first 👷‍♂️" section to get your project going. Follow the steps
50+
until "Let’s start coding”, then open up your code editor.
5251

53-
2. Next add a line in your `scripts` section of `package.json` so it looks like
54-
this below. You may already have other scripts' lines so don't get rid of
55-
those. If you already have a `"test"` script line, make sure it now has
56-
`hardhat test --network hardhat`. If you have multiple script lines make sure
57-
the last line does not have a comma at the end, otherwise you'll see an
58-
error.
52+
_If you are using VSCode, type `code .` in your terminal to open VSCode._
53+
54+
After running through that section you'll have a working Hardhat project for the
55+
next steps.
56+
57+
### Add test command for running tests
58+
59+
Add a line in your `scripts` section of `package.json` so it looks like this
60+
below. You may already have other scripts' lines so don't get rid of those. If
61+
you already have a `"test"` script line, make sure it now has
62+
`hardhat test --network hardhat`. If you have multiple script lines make sure
63+
the last line does not have a comma at the end, otherwise you'll see an error.
5964

6065
```javascript
6166
"scripts": {
@@ -64,9 +69,11 @@ into some testing!
6469
},
6570
```
6671

67-
3. Below is the contract from Lesson 3 we'll be testing. Please copy this code
68-
into a new file called `TierNFT.sol` in a `contracts` folder in the root of
69-
the project.
72+
### Bring in the contract we'll be testing
73+
74+
If you don't already have `TierNFT.sol` in your project from Lesson 3, below is
75+
that same contract. Please create a new file called `TierNFT.sol` in a
76+
`contracts` folder in the root of the project, and copy in this code:
7077

7178
```solidity
7279
// SPDX-License-Identifier: MIT
@@ -167,10 +174,31 @@ contract TierNFT is ERC721, Ownable {
167174
}
168175
```
169176

177+
### Verify Solidity Version
178+
179+
One small, but crucial change before we proceed. Ensure the version of Solidity
180+
being used to run the contract is the same one configured in
181+
`hardhat.config.js`.
182+
183+
Copy the Solidity version from the `pragma` statement at the top of your
184+
contract, to the `hardhat.config.js` file and replace that `solidity: "version"`
185+
with that of your contract.
186+
187+
For example, since our contract is using Solidity `0.8.12`:
188+
189+
```
190+
require("@nomicfoundation/hardhat-toolbox");
191+
require('dotenv').config();
192+
193+
module.exports = {
194+
solidity: "0.8.12",
195+
};
196+
```
197+
170198
## What do we want to test on our TierNFT contract?
171199

172200
Now that the tools are set up, let's talk about what we want to test in our
173-
smart contract. We'll then add create tests.
201+
smart contract. We'll then create the tests.
174202

175203
What is the contract trying to do?
176204

@@ -188,8 +216,9 @@ mint fails if there is not enough Eth spent.
188216

189217
### Creating our test file
190218

191-
Create a `test` folder in the root of your project, and add a new file called
192-
`tier-nft.test.js` which will hold our new test code.
219+
If you don't have one already, create a `test` folder in the root of your
220+
project, and add a new file called `tier-nft.test.js` which will hold our new
221+
test code.
193222

194223
### Start testing constructor(), mint() and withdraw()
195224

@@ -241,6 +270,7 @@ describe('TierNFT', function () {
241270
<ContentCallout emoji="💡" size="md" variant="info">
242271
Before we walk through, let's make sure everything is working correctly. Run
243272
the tests using `npm test` and you should see these two initial tests pass.
273+
<strong>This is an important milestone! You created your first tests and they now pass.<strong>
244274
</ContentCallout>
245275

246276
Now let's walk through the test code we've pasted in and explain what it does.

0 commit comments

Comments
 (0)