You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -12,7 +12,7 @@ import { LessonHeader } from "../../../components/mdx/LessonHeader";
12
12
13
13
<Layout
14
14
title="Your own Token with Foundry"
15
-
description="Create and deploy an ERC20 Token (UNI, MKR, DAI, etc.) using the Foundry
15
+
description="Create and deploy an ERC-20 Token (UNI, MKR, DAI, etc.) using the Foundry
16
16
toolkit."
17
17
>
18
18
<LessonHeader
@@ -21,8 +21,8 @@ import { LessonHeader } from "../../../components/mdx/LessonHeader";
21
21
22
22
## About this lesson
23
23
24
-
If you're eager to learn how to create your first ERC20 token, you're in the right place. There are
25
-
a multitude of uses for the ERC20, and we'll introduce you to some of them.
24
+
If you're eager to learn how to create your first ERC-20 token, you're in the right place. There are
25
+
a multitude of uses for the ERC-20, and we'll introduce you to some of them.
26
26
We'll be building a smart contract with a range of developer tools, including the use of Foundry.
27
27
If you are new to coding, we suggest that you first complete our _Getting Started with Smart Contract
28
28
Development_ project, to get to grips with the basics of Solidity you'll need in
@@ -43,7 +43,7 @@ source of much of our well-being. 🌱
43
43
44
44
## What are we creating?
45
45
46
-
By the end of this lesson you will have created your own ERC20 token, and
46
+
By the end of this lesson you will have created your own ERC-20 token, and
47
47
you will be able to change its properties in any way you need.
48
48
But before we go any further, let's check-in and see what building blocks you have already.
49
49
@@ -62,7 +62,7 @@ We hope that was a little eye-opener for what's to come!
62
62
63
63
64
64
65
-
### Tokens, crypto, coins, ERC20. Is it all the same?
65
+
### Tokens, crypto, coins, ERC-20. Is it all the same?
66
66
67
67
Let's begin with some context, so we all speak the same language. The Ethereum blockchain, and most EVM-compatible blockchains, have a native token that is used to pay for transaction costs, and also to reward validators in
68
68
Proof of Stake (previously miners in Proof of Work). In Ethereum that native
@@ -72,7 +72,7 @@ Every _other_ token or 'crypto' you see, use or interact with on Ethereum is
72
72
basically a smart contract that lets you send these tokens, receive them and
73
73
check your balance. Stablecoins like **DAI**, Tether (**USDT**), USD Coin (**USDC**), or tokens from
74
74
projects like Uniswap (**UNI**), MakerDAO (**MKR**), Basic Attention Token
75
-
(**BAT**) are all smart contracts that follow a standard. The ERC20 standard.
75
+
(**BAT**) are all smart contracts that follow a standard. The ERC-20 standard.
76
76
77
77
### Why would we want to create yet another Token?
78
78
@@ -89,12 +89,12 @@ Some basic functionality that our tokens need to provide are:
89
89
account
90
90
91
91
92
-
Has someone created a battle-tested library for the standard? Yes. OpenZeppelin, among others, has created an implementation we can inherit to create our own tokens easily. Here is a quick overview of what a contract needs in order to be called an ERC20 Token
92
+
Has someone created a battle-tested library for the standard? Yes. OpenZeppelin, among others, has created an implementation we can inherit to create our own tokens easily. Here is a quick overview of what a contract needs in order to be called an ERC-20 Token
93
93
contract:
94
94
95
-
<SideDrawerbuttonText="More info on the ERC20 Standard">
95
+
<SideDrawerbuttonText="More info on the ERC-20 Standard">
96
96
97
-
To achive the functionality needed for an ERC20 token, the standard requires us
97
+
To achive the functionality needed for an ERC-20 token, the standard requires us
98
98
to implement 9 methods and 2 events.
99
99
100
100
@@ -146,7 +146,7 @@ mkdir d_d_academy
146
146
cd d_d_academy
147
147
```
148
148
149
-
You can use whatever tools you feel confident with, or accustumed to. For this example
149
+
You can use whatever tools you feel confident with, or accustomed to. For this example
150
150
we will be creating a Foundry project, but feel free to use Hardhat, or Truffle
151
151
if that's your favourite flavor. The main focus of Foundry is that you don't
152
152
need to use Javascript at all, if you don't want to. All the tools are CLI
@@ -264,7 +264,7 @@ Running 2 tests for test/Counter.t.sol:CounterTest
264
264
Test result: ok. 2 passed; 0 failed; finished in 19.11ms
265
265
```
266
266
267
-
As we mentioned earlier, we are going to use OpenZeppelin ERC20 implementation.
267
+
As we mentioned earlier, we are going to use OpenZeppelin ERC-20 implementation.
268
268
To use it, we need to install OpenZeppelin as a dependency in our project. To
269
269
install dependencies in Foundry, we use:
270
270
@@ -302,18 +302,18 @@ rm src/*
302
302
rm test/*
303
303
```
304
304
305
-
<SideDrawer
305
+
{/*<SideDrawer
306
306
buttonText="Checkpoint Questions will be here"
307
307
title="">
308
-
</SideDrawer>
308
+
</SideDrawer>*/}
309
309
310
310
Everything's ready, so let's go ahead and start coding Solidity.
311
311
312
312
## Create the Framing and Walls
313
313
314
314
We need our house to have a structure and a floor plan with walls dividing the
315
315
rooms. Let's think of that setting as the 9 methods and 2 events that we saw
316
-
earlier for our code to be ERC20 compliant.
316
+
earlier for our code to be ERC-20 compliant.
317
317
318
318
It's a great exercise to try and implement them from scratch, and we ecourage
319
319
you to do that once you start diving deeper into Solidity. It is also a great
@@ -334,7 +334,7 @@ contract MyToken {
334
334
}
335
335
```
336
336
337
-
Once we have that, we can import and inherit OpenZeppelin ERC20:
337
+
Once we have that, we can import and inherit OpenZeppelin ERC-20:
338
338
339
339
```solidity
340
340
// SPDX-License-Identifier: MIT
@@ -347,7 +347,7 @@ contract MyToken is ERC20 {
347
347
```
348
348
349
349
Now that we have the full implementation inherited, we still have to specify a
350
-
few more things before compiling, because the ERC20 constructor **needs** to
350
+
few more things before compiling, because the ERC-20 constructor **needs** to
351
351
receive 2 parameters, i.e. the token's name and symbol, or it will raise an error. In
352
352
order to do that, we define our constructor and call our inherited
353
353
contract's constructor:
@@ -432,21 +432,21 @@ contract MyToken is ERC20 {
432
432
When we define our `mint` function, we decide who will be the receiver of said
433
433
new tokens. For the `burn` function on the other hand, we are only letting holders burn
434
434
their **own** tokens by using `msg.sender` as the address to call the internal
435
-
`_burn` function in the OpenZeppelin ERC20 implementation.
435
+
`_burn` function in the OpenZeppelin ERC-20 implementation.
436
436
437
437
In a special case where someone approves operating on an amount of *their* tokens,
438
438
we create a `burnFrom` function to be able to burn within that approved
439
439
allowance from the other address. If we try to burn, or transfer, more than the
440
-
approved allowance, the ERC20 implementation from OZ will revert the transaction
441
-
because that's required by the ERC20 standard.
440
+
approved allowance, the ERC-20 implementation from OZ will revert the transaction
441
+
because that's required by the ERC-20 standard.
442
442
443
443
We have now created doors to our house, but we haven't put locks in them!
444
444
445
445
446
-
<SideDrawer
446
+
{/*<SideDrawer
447
447
buttonText="Checkpoint Questions will be here"
448
448
title="">
449
-
</SideDrawer>
449
+
</SideDrawer>*/}
450
450
451
451
452
452
## Lock the Door!
@@ -565,7 +565,7 @@ A few examples could be:
565
565
566
566
- A token that accrues or drips more tokens, depending on how long have you been
567
567
hodling. Tip: you can override functions like `balanceOf` and
568
-
`_beforeTokenTransfer` / `_afterTokenTransfer` from the inherited ERC20
568
+
`_beforeTokenTransfer` / `_afterTokenTransfer` from the inherited ERC-20
569
569
- A token that can only be transferred or received if you hold another specific
570
570
token, i.e. an NFT from a specific collection
571
571
- A token that loses the balance if you don't transact or transfer it regularly
@@ -607,10 +607,10 @@ to ask our community for help by explaining your error, the console output and
607
607
your configuration (OS, version, Foundry and Solidity version, etc.)
608
608
609
609
610
-
<SideDrawer
610
+
{/*<SideDrawer
611
611
buttonText="Checkpoint Questions will be here"
612
612
title="">
613
-
</SideDrawer>
613
+
</SideDrawer>*/}
614
614
615
615
## Register your house in the Real Estate Register
616
616
@@ -781,10 +781,10 @@ the tool tells us what the address of the deployed contract is:
781
781
`0xCE68eD7AEd9A1c6C185f2B8b576e7cBD7bf5dAAf`.
782
782
783
783
784
-
<SideDrawer
784
+
{/*<SideDrawer
785
785
buttonText="Checkpoint Questions will be here"
786
786
title="">
787
-
</SideDrawer>
787
+
</SideDrawer>*/}
788
788
789
789
## Querying the Block Explorer
790
790
@@ -822,8 +822,6 @@ our decimals in 18, that would be exactly 1000 MTK.
0 commit comments