To create an ERC20 token, developers inherit from OpenZeppelin's ERC20 contract and can extend functionality by inheriting from additional contracts like ERC20Detailed (for metadata), ERC20Burnable (for token burning), ERC20Mintable (for minting new tokens), ERC20Capped (for limiting total supply), and ERC20Pausable (for pausing transfers). The token's metadata (name, symbol, decimals) is defined in the constructor, and access control mechanisms like addMinter() and addPausable() manage who can perform privileged operations.
Creating an ERC20 Token with OpenZeppelin: A Step-by-Step Guide
Added:in your smart contract projects if you want to represent fungible asset the two current standard need to choose is a C 20 instead of writing your own implementation of the s 20 tokens 10 that is safer and faster to use the implementation of opens evening so in this video I'm going to show you how you can create an S 20 token with open sibling hey I'm Julian and on my channel in the blocks I teach how to become a blockchain developer and get your first pro option job so this is a truffle project I've already installed open Zeppelin with NPM and next I'm gonna create a file for my yes 20 token let's open our new file I specify the version of solidity then I imported the last 20 smart contract from open Zeppelin then I create a smart contract for my token and I'm going to inherit from the ES 20 contract of open Zeppelin and that's all I need to do now you can call all the function of the s 20 token standard on my smart contract because it inherit from the US 20 token of open Zeppelin next you probably want to attach some metadata to your token so for that we can use another contract of open sibling which is yes it when detailed and when you're gonna combine these with what we've imported previously is by also in reading from this contract so in so DT it's possible to inherit from several smart contract and for that you need to use a comma so here we specify our second contract by the way the order of declaration is important here you need to first enter it from yes xx and after yes 20 detail and once you've done that then you need to define a constructor so the constructor is what's going to be called when your token is deployed so our constructor doesn't take any argument however we can call the constructor of one of the parents math contract so in our case we're going to call the structure yes 20 detailed and we're gonna give it three value the first one is the name of our token so this is a string so for example my token then the symbol of the token so for example I M G N and finally the number of decimal of our token so in most cases we're going to like for either that is 18 by the way if you are not clear of what's the main power yes 20 token works and what is this decimal thing then you can check out this video of my series of on ethereum tokens so now with all this metadata attached it's possible to call Sreenu function on your token the name function the symbol function and the decimals function next if you want to make your token burnable that means that it's possible to destroy some coin then you can use another contract of open zip links that's yes 20 burnable so in this case you're gonna add this Yesi burnable and now you have access to a new function which is turn and you have to pass the number of token that you want to burn and it's going to burn the token for the sender of this transaction next you probably want you to come to be min table so that means that at any time you can create a new coin so for that there is another token called ESC mean table and so now you have a new function defined on your smart contracts that's the mint function and the first argument is the address that will receive the new mine coin and the second argument is how many token you want to create so of course not everybody can call this function because otherwise that'll be too easy anybody could create as many coin as they want so only the address that deploy your token will be able to call this function or if you want to delegate this responsibility to another address you also have access to a function called add Minter and so here you can pass the address of the mentor like this and after once the administrator of your contract so that means do the first person who deployed the contract added a meter then this Minter is about to call the mint function next maybe that you want to learn you to come to be minted but up to a maximum value so in other word you want to cap the amount of token that can be created there is another spot contract of a pin setting that can help you and that is called EFC 20 capped so in this case you're gonna also inherit from it and we also need to call the constructor of these smart contracts so you can actually call several constructor so after the first constructor here of s 20 detail then we specify that we want to call the constructor of just one capped and we're gonna pass the maximum amount of token that we want to mint so for example if I pass 1000 here I can only mint up to 1000 token if I try to mean more token and this then it's going to throw an error next you might want to implement a post feature in your token so with a post feature when your contract is post is not possible to transfer token or to change the alone for a specific spender so for that you need to import yes 20 possible and you inherit from it and then we have some extra function defined on this contract so you have the post function you can also and pause it's also possible to know if the contract is supposed or not with the post function and of course in order to call this to function pause and unpause me to have special privilege so if you are the address that you plot the contract you have this privilege otherwise you need to get granted this privilege so the admin of the contract or another poser can call the add poser function and here you specify the address of the poser there is also an alternative implementation of the asset when it is called safe yes 20 so actually the way it works is so first you input safe yes it win so here I'm gonna create another token my token 2 is safe yeah C 20 so it works the same way as the asset when token except that when you when you do a transfer of token it makes sure that the recipient if this is a smart contract it needs to know how to handle token because sometimes people send token to other smart contract that don't know how to handle token and then the tokens are locked in this contract so we set as 20 then you you will not have this issue another thing that can be interesting to do is to interact with another smart contract with another token from your token so for that what you could do is import the interface of just 20 so that's cool I asked 20 and then in in your just 20 so let's create a function foo here if you want to interact with another yes 20 token then you use the interface of the yes 20 token then you pass the address to your X whatever and then you can call all the function of this auto-tagging like transfer etc so if you wonder how comes I know all these tricks I've actually looked inside the git repo of open zip link at this address so if you want more info you can check it out so with asset when it opens you can represent a fungible asset but there are many assets that are actually none fungible and for that you need to use the TSE 721 tokens and in the next video of this series i'll show you how you can create an asset 721 token which opens mmm I'll see you there
Up Next

Wrapped Tokens Explained: WBTC and WETH in DeFi Interoperability
@CoinGecko
49.8K views•2022-05-12

Torrent File Format & Bencoding: A Technical Deep Dive
@AsliEngineering
12.5K views•2022-08-08

Solidity Timelock Contract Tutorial: Delaying Transactions Securely
@EatTheBlocks
6.7K views•2022-08-02

Understanding Ethereum: A Comprehensive Beginner's Overview
@99Bitcoins
3.1M views•2018-06-26
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Blockchain & Crypto









![Learn Solidity: The COMPLETE Beginner’s Guide [Full Course] | Solidity Tutorial](https://i.ytimg.com/vi/9BZ0zjqwCPs/maxresdefault.jpg)

































