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 @@ Test result: ok. 2 passed; 0 failed; 0 skipped; finished in 27.32ms
264
264
Ran 1 test suites: 2 tests passed, 0 failed, 0 skipped (2 total tests)
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
@@ -321,7 +321,7 @@ Everything's ready, so let's go ahead and start coding Solidity.
321
321
322
322
We need our house to have a structure and a floor plan with walls dividing the
323
323
rooms. Let's think of that setting as the 9 methods and 2 events that we saw
324
-
earlier for our code to be ERC20 compliant.
324
+
earlier for our code to be ERC-20 compliant.
325
325
326
326
It's a great exercise to try and implement them from scratch, and we ecourage
327
327
you to do that once you start diving deeper into Solidity. It is also a great
@@ -342,7 +342,7 @@ contract MyToken {
342
342
}
343
343
```
344
344
345
-
Once we have that, we can import and inherit OpenZeppelin ERC20:
345
+
Once we have that, we can import and inherit OpenZeppelin ERC-20:
346
346
347
347
```solidity
348
348
// SPDX-License-Identifier: MIT
@@ -355,7 +355,7 @@ contract MyToken is ERC20 {
355
355
```
356
356
357
357
Now that we have the full implementation inherited, we still have to specify a
358
-
few more things before compiling, because the ERC20 constructor **needs** to
358
+
few more things before compiling, because the ERC-20 constructor **needs** to
359
359
receive 2 parameters, i.e. the token's name and symbol, or it will raise an error. In
360
360
order to do that, we define our constructor and call our inherited
361
361
contract's constructor:
@@ -440,13 +440,13 @@ contract MyToken is ERC20 {
440
440
When we define our `mint` function, we decide who will be the receiver of said
441
441
new tokens. For the `burn` function on the other hand, we are only letting holders burn
442
442
their **own** tokens by using `msg.sender` as the address to call the internal
443
-
`_burn` function in the OpenZeppelin ERC20 implementation.
443
+
`_burn` function in the OpenZeppelin ERC-20 implementation.
444
444
445
445
In a special case where someone approves operating on an amount of *their* tokens,
446
446
we create a `burnFrom` function to be able to burn within that approved
447
447
allowance from the other address. If we try to burn, or transfer, more than the
448
-
approved allowance, the ERC20 implementation from OZ will revert the transaction
449
-
because that's required by the ERC20 standard.
448
+
approved allowance, the ERC-20 implementation from OZ will revert the transaction
449
+
because that's required by the ERC-20 standard.
450
450
451
451
We have now created doors to our house, but we haven't put locks in them!
452
452
@@ -579,7 +579,7 @@ A few examples could be:
579
579
580
580
- A token that accrues or drips more tokens, depending on how long have you been
581
581
hodling. Tip: you can override functions like `balanceOf` and
582
-
`_beforeTokenTransfer` / `_afterTokenTransfer` from the inherited ERC20
582
+
`_beforeTokenTransfer` / `_afterTokenTransfer` from the inherited ERC-20
583
583
- A token that can only be transferred or received if you hold another specific
584
584
token, i.e. an NFT from a specific collection
585
585
- A token that loses the balance if you don't transact or transfer it regularly
0 commit comments