Now it's time to create a token, but this time we're going to create a token that's fully compatible with Ethereum's ERC-20 standard. The first thing we will do is analyze the anatomy of an ERC-20 token. And then, we will create our own token. Now, let's analyze the anatomy of an ERC-20 token. To do this, we need to go to the Ethereum Improvement Proposals website, where we can see all the standards, right?
Here we can find the ERC-20 token standard. We'll see. Well, the reason this pattern was created is that, initially, people were creating different tokens in different ways. And of course, this brings many problems, because how would wallets support these tokens? And, as in any sector these tokens?
And, as in any sector , standards are good because they help to move in a certain direction and also to have interoperability. Therefore, this standard was very important for the Ethereum ecosystem. Let's take a look at the specification, which mainly defines an interface that all tokens wishing to be fully compliant with the ERC-20 standard must implement. Okay, some of the things this specification defines are functions that, as you can see, are optional. For example, the name; This could help improve usability and allow users to see the name of a token, right?
Like " to see the name of a token, right? Like " my token". The symbol, for example, this symbol is also an optional feature, but it can greatly improve usability, okay? The "decimals" function is also optional, but it is very important. And in our example, as soon as we start implementing our own ERC-20 token, we'll see the importance of setting the decimal places correctly.
Right now, if you can see it, if you set the decimal places to eight, that means that to count a token, you need to have the number followed by eight zeros. In this case, you have three eight zeros. In this case, you have three , six, and eight. Therefore, this number one with eight decimal places will actually represent a single token. OK?
"Total supply" is not optional. This is mandatory. And this is important for knowing the total supply of a given token. OK? The " total supply of a given token.
OK? The " balance of" function helps to restore the balance of any account. We have this function. As you can see, it receives an owner and returns the balance. OK?
We also have the transfer function, similar to what we did in the minimalist token example, but we also have more advanced features like transfer from. A transfer from option is very useful because it allows you to make transfers from another contract. So, what happens is that contract. So, what happens is that you can actually approve a spender. Let's say there's a contract where you deposit your tokens, and then you approve that specific contract to transfer tokens on your behalf.
Therefore, you first need to approve it using this function. You will need to provide the address of the person who is responsible for spending on that contract, and then how many units that contract can spend on their behalf. And then the contract will simply use this function to transfer. Therefore, he will be able to transfer tokens that belong to you to any Ethereum address. OK?
Hmm, we have a method for permissions. This helps us verify how much a given address can spend in tokens belonging to a specific owner. OK? And then some events, transfer and approval. Okay.
The standard also contains some implementation examples and a bit of history.
Automatic transcript — names and jargon may be misspelled.