New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

The OpenZeppelin ERC 20 Testing

BaseMon, Oct 9, 2023, 12:00 AM

Mint tokens in an ERC-20 token contract. Understand the importance of using the correct decimal units and explore how to transfer tokens between accounts. Gain practical insights into the token minting process. Watch now to master ERC-20 token minting! 💰🚀 📚 Head to Base Camp for full courses on smart contract development: https://docs.base.org/base-camp/docs/welcome ✅ Subscribe to our channel here: https://www.youtube.com/@BuildonBase ► Build on Base: https://base.org ► Follow us on Twitter: https://twitter.com/buildonbase ► Join our Discord: https://base.org/discord

Transcript

now let's mint some tokens if you go to the to the to the separate implementation you will see that there is a function called mint okay this is internal but is also available for the contract that we are creating because we are inheriting okay so what we can do is when we create the contract we can actually assign to the sender let's say 1 multiply by 10 to the power of 18. so remember that we are using 18 decimals so for that reason we need to we need to multiply the number that we want to give to the user by 10 to the power of 18 okay now let's test let's call this token a and the symbol TKA all right now let's check the balance of this of the Creator okay and as you can see this is the balance this is one follow by 18 zeros okay 3 6 9 12 15 18. however when the wallet will display this it's gonna display it as one because the wallet is when I use the number of decimals to know how many units the token really represents okay all right so we can also mint for other users let's mint to the second account and let's give the same amount of tokens okay okay let's clean this now I'm going to deploy token B t k v will be the symbol and transaction okay now let's check the balance of the first account still one now the second account balance of is the same now let's transfer let's transfer to from this to this account so I'm just going to say the recipient is that account and I want to transfer so here if we want to transfer one is not gonna be really one you need to include the zeros okay um but I I'm just gonna include not that many zeros just three seven zeros okay so we will see how it changed but it's not the proper unit okay so I'm gonna say transact is correct and now let's get the balance okay as you see this one only change it if we wanted to really transfer the whole token we had to use one followed by 18 zeros okay all right um one important thing to keep in mind is when we mean what is really happening is and let's go to the implementation is that as you can see the total Supply is increasing okay and the balances are simply being updated for that particular account okay but remember here we are simply increasing the amount of the total Supply all right this is very important because in the next exercise we are gonna do the ERC 721 and we are gonna notice that one main difference relies in the minting mechanism

Automatic transcript — names and jargon may be misspelled.