@@ -238,12 +238,10 @@ forge build
238
238
My output:
239
239
240
240
``` bash
241
- [⠊] Compiling...
242
- [⠑] Installing solc version 0.8.19
243
- [⠊] Successfully installed solc 0.8.19
244
- [⠒] Compiling 20 files with 0.8.19
245
- [⠑] Solc 0.8.19 finished in 6.08s
246
- Compiler run successful
241
+ [⠒] Compiling...
242
+ [⠔] Compiling 22 files with 0.8.20
243
+ [⠃] Solc 0.8.20 finished in 4.35s
244
+ Compiler run successful!
247
245
```
248
246
249
247
And now we can test it:
@@ -255,13 +253,15 @@ forge test
255
253
My output:
256
254
257
255
``` bash
258
- [⠰ ] Compiling...
256
+ [⠆ ] Compiling...
259
257
No files changed, compilation skipped
260
258
261
259
Running 2 tests for test/Counter.t.sol:CounterTest
262
- [PASS] testIncrement () (gas: 28334)
263
- [PASS] testSetNumber(uint256) (runs: 256, μ: 27553, ~ : 28409)
264
- Test result: ok. 2 passed; 0 failed; finished in 19.11ms
260
+ [PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 27631, ~ : 28409)
261
+ [PASS] test_Increment () (gas: 28379)
262
+ Test result: ok. 2 passed; 0 failed; 0 skipped; finished in 27.32ms
263
+
264
+ Ran 1 test suites: 2 tests passed, 0 failed, 0 skipped (2 total tests)
265
265
```
266
266
267
267
As we mentioned earlier, we are going to use OpenZeppelin ERC20 implementation.
@@ -278,8 +278,9 @@ This looks for the repo called `openzeppelin-contracts` from the GitHub user
278
278
This is the output I got:
279
279
280
280
``` bash
281
- Installing openzeppelin-contracts in " /home/myuser/d_d_academy/my_token/lib/openzeppelin-contracts" (url: Some(" https://github.com/OpenZeppelin/openzeppelin-contracts" ), tag: None)
282
- Installed openzeppelin-contracts v4.8.0
281
+ Installing openzeppelin-contracts in /home/myuser/d_d_academy/my_token/lib/openzeppelin-contracts (url: Some(" https://github.com/OpenZeppelin/openzeppelin-contracts" ), tag: None)
282
+ ...
283
+ Installed openzeppelin-contracts v5.0.0
283
284
```
284
285
285
286
This lets us import OpenZeppelin contracts in our smart contracts. We need to
@@ -303,10 +304,17 @@ rm test/*
303
304
```
304
305
305
306
<SideDrawer
306
- buttonText = " Checkpoint Questions will be here"
307
- title = " " >
307
+ buttonText = " Checkpoint Questions"
308
+ title = " Foundations of our contract with Foundry"
309
+ >
310
+ { /* <Question question="lesson-6/2-foundry/Q1" />
311
+ <Question question="lesson-6/2-foundry/Q2" />
312
+ <Question question="lesson-6/2-foundry/Q3" />
313
+ <Question question="lesson-6/2-foundry/Q4" />
314
+ <Question question="lesson-6/2-foundry/Q5" /> */ }
308
315
</SideDrawer >
309
316
317
+
310
318
Everything's ready, so let's go ahead and start coding Solidity.
311
319
312
320
## Create the Framing and Walls
@@ -328,7 +336,7 @@ basics:
328
336
329
337
``` solidity
330
338
// SPDX-License-Identifier: MIT
331
- pragma solidity 0.8.19 ;
339
+ pragma solidity 0.8.20 ;
332
340
333
341
contract MyToken {
334
342
}
@@ -338,7 +346,7 @@ Once we have that, we can import and inherit OpenZeppelin ERC20:
338
346
339
347
``` solidity
340
348
// SPDX-License-Identifier: MIT
341
- pragma solidity 0.8.19 ;
349
+ pragma solidity 0.8.20 ;
342
350
343
351
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
344
352
@@ -354,7 +362,7 @@ contract's constructor:
354
362
355
363
``` solidity
356
364
// SPDX-License-Identifier: MIT
357
- pragma solidity 0.8.19 ;
365
+ pragma solidity 0.8.20 ;
358
366
359
367
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
360
368
@@ -375,7 +383,7 @@ contract on our constructor:
375
383
376
384
``` solidity
377
385
// SPDX-License-Identifier: MIT
378
- pragma solidity 0.8.19 ;
386
+ pragma solidity 0.8.20 ;
379
387
380
388
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
381
389
@@ -444,8 +452,14 @@ We have now created doors to our house, but we haven't put locks in them!
444
452
445
453
446
454
<SideDrawer
447
- buttonText = " Checkpoint Questions will be here"
448
- title = " " >
455
+ buttonText = " Checkpoint Questions"
456
+ title = " Laying out the basics of the contract"
457
+ >
458
+ { /* <Question question="lesson-6/3-create-contract/Q1" />
459
+ <Question question="lesson-6/3-create-contract/Q2" />
460
+ <Question question="lesson-6/3-create-contract/Q3" />
461
+ <Question question="lesson-6/3-create-contract/Q4" />
462
+ <Question question="lesson-6/3-create-contract/Q5" /> */ }
449
463
</SideDrawer >
450
464
451
465
@@ -522,7 +536,7 @@ Here we have our fully functioning house, I mean... token:
522
536
523
537
``` solidity
524
538
// SPDX-License-Identifier: MIT
525
- pragma solidity 0.8.19 ;
539
+ pragma solidity 0.8.20 ;
526
540
527
541
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
528
542
import "@openzeppelin/contracts/access/AccessControl.sol";
@@ -592,10 +606,10 @@ forge build
592
606
Here's what I got in the console:
593
607
594
608
``` bash
595
- [⠒ ] Compiling...
596
- [⠃ ] Compiling 11 files with 0.8.19
597
- [⠒ ] Solc 0.8.19 finished in 1.29s
598
- Compiler run successful
609
+ [⠢ ] Compiling...
610
+ [⠒ ] Compiling 10 files with 0.8.20
611
+ [⠑ ] Solc 0.8.20 finished in 252.16ms
612
+ Compiler run successful!
599
613
```
600
614
601
615
Everything compiled successfully and is ready to deploy.
@@ -608,11 +622,17 @@ your configuration (OS, version, Foundry and Solidity version, etc.)
608
622
609
623
610
624
<SideDrawer
611
- buttonText = " Checkpoint Questions will be here"
612
- title = " " >
625
+ buttonText = " Checkpoint Questions"
626
+ title = " Defining permissions for use of our contract"
627
+ >
628
+ { /* <Question question="lesson-6/4-define-roles/Q1" />
629
+ <Question question="lesson-6/4-define-roles/Q2" />
630
+ <Question question="lesson-6/4-define-roles/Q3" />
631
+ <Question question="lesson-6/4-define-roles/Q4" />
632
+ <Question question="lesson-6/4-define-roles/Q5" /> */ }
613
633
</SideDrawer >
614
634
615
- ## Register your house in the Real Estate Register
635
+ ### Register your house in the Real Estate Register
616
636
617
637
Or... Let's deploy our contract!
618
638
@@ -633,7 +653,7 @@ more if you search for Sepolia Faucet in any search engine.
633
653
We are going to create an ` .env ` file, where we will store our _ secrets_ . And
634
654
when we say _ secrets_ , we are specially referring to the private key to your
635
655
wallet. Never, ever share this with anyone, not even us. Anyone who gets hold of
636
- your keys, can drain your wallet. This is why we strongly advise using a separate wallet for your development activities,
656
+ your keys, can drain your wallet. This is why we strongly advise using a separate browser profile, and most definitely a separate wallet for your development activities,
637
657
that should not hold anything with real value in it. It wouldn't be the first time,
638
658
even for experienced developers, to accidentally upload the ` .env ` file to
639
659
GitHub, and once it's on the internet we can consider it to be, yes, public.
@@ -751,22 +771,21 @@ the tool will return an error when trying to verify.
751
771
This is the output I got:
752
772
753
773
``` less
754
- [⠒ ] Compiling...
774
+ [⠊ ] Compiling...
755
775
No files changed, compilation skipped
756
776
Deployer: 0 xf4bAFA90241e808461653C17dB0f8669Fa4342a1
757
- Deployed to: 0 xCE68eD7AEd9A1c6C185f2B8b576e7cBD7bf5dAAf
758
- Transaction hash: 0 xeb420acc65f54fc3a564db28856e4496acb59615f837d784c75a9c00a0bb96d4
777
+ Deployed to: 0 xec870005029ED5595F146f6AAAe699b442065b72
778
+ Transaction hash: 0 x436120f627b1b56ac92ca1df408f1ec591cd578c4168aad4d89bc73c4141aa78
759
779
Starting contract verification...
760
780
Waiting for etherscan to detect contract deployment...
761
- Start verifying contract `0 xCE68eD7AEd9A1c6C185f2B8b576e7cBD7bf5dAAf` deployed on sepolia
762
-
763
- Submitting verification for [src/ MyToken.sol :MyToken] " 0xCE68eD7AEd9A1c6C185f2B8b576e7cBD7bf5dAAf" .
781
+ Start verifying contract `0 xec870005029ED5595F146f6AAAe699b442065b72` deployed on sepolia
764
782
783
+ Submitting verification for [src/ MyToken.sol :MyToken] " 0xec870005029ED5595F146f6AAAe699b442065b72" .
765
784
Submitted contract for verification:
766
785
Response: `OK`
767
- GUID: `fn91mxzy58kyjw5ps1tjid2jtulktj8zhdx583pxbfekthb5jm `
786
+ GUID: `hzmpq14eeasu92sd1hgzgdhttdu7iscirjlbs9eb1vsezkn8vc `
768
787
URL:
769
- https:// sepolia.etherscan.io/address/0xce68ed7aed9a1c6c185f2b8b576e7cbd7bf5daaf
788
+ https:// sepolia.etherscan.io/address/0xec870005029ed5595f146f6aaae699b442065b72
770
789
Contract verification status:
771
790
Response: `NOTOK`
772
791
Details : `Pending in queue`
@@ -775,30 +794,38 @@ Response: `OK`
775
794
Details : `Pass - Verified`
776
795
Contract successfully verified
777
796
```
797
+ If by chance you get a message saying Etherscan hasn't detected or verified the deployment,
798
+ try running the command again.
778
799
779
- If we filter out all information, we should pay attention to the second line, where
780
- the tool tells us what the address of the deployed contract is :
781
- ` 0xCE68eD7AEd9A1c6C185f2B8b576e7cBD7bf5dAAf ` .
800
+ By filtering through the information, we can pay attention to the second line, where
801
+ the tool tells us the address of the deployed contract:
802
+ ` 0xec870005029ED5595F146f6AAAe699b442065b72 ` .
782
803
783
804
784
805
<SideDrawer
785
- buttonText = " Checkpoint Questions will be here"
786
- title = " " >
806
+ buttonText = " Checkpoint Questions"
807
+ title = " Deploying with Foundry"
808
+ >
809
+ { /* <Question question="lesson-6/5-deployment/Q1" />
810
+ <Question question="lesson-6/5-deployment/Q2" />
811
+ <Question question="lesson-6/5-deployment/Q3" />
812
+ <Question question="lesson-6/5-deployment/Q4" />
813
+ <Question question="lesson-6/5-deployment/Q5" /> */ }
787
814
</SideDrawer >
788
815
789
816
## Querying the Block Explorer
790
817
791
818
You can go into [ Sepolia Etherscan] ( https://sepolia.etherscan.io/ ) block
792
- explorer and search for this address that the command returned to check out your
819
+ explorer and search for the address that the command returned to check out your
793
820
very own newly deployed smart contract!
794
821
795
822
![ ERC20-etherscan] ( /assets/lessons/6/ERC20-etherscan.png )
796
823
797
- If you got to verify it, it also gives you a link to see your contract on the
798
- block explorer. In our case, it's the last line the _ Submitted contract for
799
- verification_ section:
800
- [ Sepolia Etherscan] ( https://sepolia.etherscan.io/address/0xce68ed7aed9a1c6c185f2b8b576e7cbd7bf5daaf )
801
- ** and ** you get to see the code for the contract and all its libraries right
824
+ If you got to verify it, you will also get a link to see your contract on the
825
+ block explorer. In our case, it's the last line of the _ Submitted contract for
826
+ verification_ section of the terminal output
827
+ [ Sepolia Etherscan] ( https://sepolia.etherscan.io/address/0xec870005029ed5595f146f6aaae699b442065b72 ) .
828
+ ** And ** you get to see the code for the contract and all its libraries right
802
829
there in the tab named _ Contract_ with the green checkmark.
803
830
804
831
If you scroll down, you'll see our code. It was the first file of the set for
@@ -815,15 +842,13 @@ searching for the `balanceOf` function:
815
842
![ ERC20-balanceOf] ( /assets/lessons/6/ERC20-balanceOf.png )
816
843
817
844
Copy and paste your wallet's address - the one you used to deploy the contract,
818
- and click Query. You should have as many wei as you passed to the constructor
845
+ and click * Query* . You should have as many wei as you passed to the constructor
819
846
when deploying. In my case it was 1000000000000000000000 wei and since we left
820
847
our decimals in 18, that would be exactly 1000 MTK.
821
848
822
849
![ ERC20-1000MTK] ( /assets/lessons/6/ERC20-1000MTK.png )
823
850
824
851
825
- ### 😊 FINAL QUIZ 😊
826
-
827
852
## Invite your frens!
828
853
829
854
That's it! We deployed our contract on the Sepolia testnet, and our token should
0 commit comments