字幕表 動画を再生する 英語字幕をプリント We all hear about ERC20 tokens but what are those tokens and most importantly: what are they not? To start with, let's quickly go over some basics: ERC20 tokens exist on the Ethereum platform and that in itself consists out of a blockchain that is capable of storing transactions and a virtual machine that is capable of running smart contracts. It's important to understand that tokens live on the Ethereum blockchain. They benefit from its technology. They aren't independent and rely on Ethereum's blockchain and platform. The native currency on the Ethereum network is Ether. But besides Ether, it can also support other tokens and these can work like currencies but they can also represent shares of a company, loyalty points, gold certificates and so on… But we're running ahead a bit. Let's first look at how tokens come into existence. A token can be created by a smart contract. This contract is not only responsible for creating tokens but also for managing transactions of the token and keeping track of each tokens holder's balance. To get some tokens you have to send some Ether to the smart contract, which will then give you a certain amount of tokens in return. So when you want to create your own token, you write a smart contract that can create tokens, transfer them and keep track of people's balances. That sounds pretty easy but it's also quite risky. For starters, once a smart contract is deployed it cannot be changed anymore, so if you made an error you can't fix it. That could be quite catastrophic. Imagine a bug inside your contract's code that causes people to loose their tokens or a bug that would allow others to steal tokens. And then there is the problem of interoperability. Each token contract can be completely different from the other. So if you want your token to be available on an exchange, the exchange has to write custom code so they can talk to your contract and allow people to trade. Same thing goes for wallet providers. Supporting hundreds of tokens would be very complex and time consuming. So instead, the community proposed a standard called ERC20. ERC stands for “Ethereum Request for Comments” and 20 is just the number they assigned to a proposal that would create some structure in the wild west of tokens. ERC20 is a guideline or standard for when you want to create your own token. It defines 6 mandatory functions that your smart contract should implement and 3 optional ones. To start with you can optionally give your token a name, a symbol and you can control how dividable your token is by specifying how many decimals it supports. The mandatory functions are a bit more complex: for starters you have to create a method that defines the total supply of your token. When this limit is reached, the smart contract will refuse to create new tokens. Next up is the `balanceOf` method which has to return how many tokens a given address has. Then there are two transfer methods: `transfer` which takes a certain amount of tokens from the total supply and gives them to a user and `transferFrom` which can be used to transfer tokens between any two users who have them. Finally there is the `approve` and `allowance` methods. `Approve` verifies that your contract can give a certain amount of tokens to a user, taking into account the total supply. The `allowance` method is almost the same except that it checks if one user has a high enough balance to send a certain amount of tokens to someone else. If you know something about object oriented programming then you can compare ERC20 to an interface. If you want your token to be an ERC20 token, you have to implement the ERC20 interface and that forces you to implement these 6 methods. Before there was the ERC20 standard, everyone who wanted to create a token had to reinvent the wheel. And that meant that each token contract was slightly different and that exchanges and wallets had to write custom code to support your token. With ERC20 however exchanges and wallet providers only have to implement this code once. That's why exchanges can add new tokens so quickly and why wallets like MyEtherWallet have support for all ERC20 tokens, without having to be updated. So how easy would be it be to create your own token? Well there is a website called TokenFactory that does it all for you. You just enter what the total supply of your token should be, how you want to call it, how many decimals it should support and what symbol it should have. After entering all this, the website creates a token contract for you and adds it to the Ethereum blockchain. It's super easy and almost effortless. So effortless in fact that the website Etherscan has a list of 36,000 known ERC20 tokens and it's estimated that in 2017 over 4 billion dollars was raised by selling tokens in an ICO. However these tokens we're not always clean. Some were really overhyped and many people got scammed into purchase tokens that where essentially worthless. But now we're getting a bit distracted. ERC20 is a great standard that has propelled the use of tokens. But ERC20 itself is not perfect. It's only a guideline and people are free to implement the required functions however they like. That has lead to some interesting problems. For instance: to buy some tokens you have to send some ether to the token contract. But some people tried sending other ERC20 tokens instead. If the contract was not designed with this in mind, it will result in your tokens being lost. In fact, it was estimated that by December 2017 well over 3 million dollars have been lost because of this flaw. So to solve this, the community is already working on extending the ERC20 standard with the ERC223 standard. This warns token creators about these risks and offers some workarounds. Let me know what you think about ERC20 tokens in the comments below or send a tweet to @Savjee. Thank you very much for watching and don't forget to subscribe so I see you in the next video!