ERC20 Tokens - Explained | How Tokens are Created
Tags: blockchain, ethereum, erc20, solidity
Published: 2022-03-28 17:32:23

<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column {"verticalAlignment":"center","width":"33.33%"} -->
<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:33.33%"><!-- wp:image {"id":1991,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://smartbuilds.io/wp-content/uploads/2022/01/eth-logo-gif.gif" alt="" class="wp-image-1991"/></figure>
<!-- /wp:image --></div>


<!-- wp:column {"width":"66.66%"} -->
<div class="wp-block-column" style="flex-basis:66.66%"><!-- wp:paragraph -->
<p>ERC20 Tokens - the technology standard behind your favorite projects. From decentralized stablecoins such as DAI to crypto the meme coins of SHIBA. <strong>With all that's going on in within this space, ERC20 Tokens can be a whole much more than dog coin projects. Let's dive in.</strong></p>
<!-- /wp:paragraph --></div>
</div>


<!-- wp:paragraph -->
<p><strong>What is a Token?</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong><a href="https://ethereum.org/en/developers/docs/standards/tokens/erc-20/" target="_blank" rel="noreferrer noopener nofollow">A token can represent virtually anything on the Blockchain</a> that we can earn or trade with other people. </strong>
Whether being XP in an online game, No. of points to a user’s profile, lottery tickets, and of course...cryptocurrencies.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2488,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://smartbuilds.io/wp-content/uploads/2022/02/erc20-standard-exchanges-1024x576.png" alt="erc20 standard exchanges" class="wp-image-2488"/><figcaption>ERC20 Tokens - developers can utilize tokens in their applications.</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>However, instead of every developer building their own token implementation. (Which would be chaotic)<br><br>There needs to be some standardization, making it easier for others such as exchanges to list these tokens by building functions into the smart contract to transfer, withdraw and swap these tokens. This is where the ERC20 standard comes in.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The <a href="https://eips.ethereum.org/EIPS/eip-20" target="_blank" rel="noreferrer noopener nofollow">ERC20 standard</a> presents a token standard that helps keep track of <strong>Fungible tokens</strong>. Meaning, each token has the exact same properties (both in type and value) when compared to another token. </p>
<!-- /wp:paragraph -->

> Full Article: [Web3, DApps, ERC20 Tokens & NFT Explained](https://smartbuilds.io/web3-dapps-erc20-tokens-nft-ipfs-explained/)

<!-- wp:image {"align":"center","id":2496,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://smartbuilds.io/wp-content/uploads/2022/02/fungible-tokens-1024x647.png" alt="fungible tokens" class="wp-image-2496"/><figcaption>ERC20 Fungible Tokens</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>I.e, an ERC20 Token named <em>ABC:</em> One <em>ABC</em> Token is always equal to all the other <em>ABC </em>tokens. As a result, this makes ERC20 Tokens ideal for mediums of exchange - currency, staking, and voting rights.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":2495,"sizeSlug":"large","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://smartbuilds.io/wp-content/uploads/2022/02/fungible-real-world-1024x572.png" alt="fungible-real world coin" class="wp-image-2495"/><figcaption>Real-World example of Fungible Tokens, £1 Coin</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In order for a Smart Contract to be called an ERC20 Token Smart Contract, the Smart Contract would need to comply with the <a href="https://ethereum.org/en/developers/docs/standards/tokens/erc-20/" target="_blank" rel="noreferrer noopener nofollow">ERC20 token standard</a>.(Ethereum Request for Comments 20).</p>
<!-- /wp:paragraph -->

<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column {"verticalAlignment":"center"} -->
<div class="wp-block-column is-vertically-aligned-center"><!-- wp:image {"id":1947,"width":363,"height":326,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full is-resized"><img src="https://smartbuilds.io/wp-content/uploads/2022/01/solidity-remix-erc20-e1641519043944.png" alt="web3, dapps, erc20 and nft's explained - solidity remix functions" class="wp-image-1947" width="363" height="326"/><figcaption>Minting ERC20 Token Functions</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph --></div>

<!-- wp:column -->
<div class="wp-block-column"><!-- wp:paragraph -->
<p>Examples of the methods and events that would need to be implemented:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><strong>Transfer() </strong>– Transfer tokens from one account to another account /wallet address.</li><li><strong>balanceOf()</strong> – Get the current token balance of the account</li><li><strong>totalSupply()</strong> – Total supply available on the blockchain network (e.g. mainnet).</li><li><strong>approve() </strong>– Approve whether a token amount can be spent or transferred by a third-party account. E.g. use for AirDrops etc.</li></ul>
<!-- /wp:list --></div>
</div>


<!-- wp:image {"id":1950,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://smartbuilds.io/wp-content/uploads/2022/01/erc20-token-soldity-remix.png" alt="web3, dapps, erc20 and nft's explained - erc20 solidity token" class="wp-image-1950"/><figcaption>Smart Contract Code to Mint an ERC20 (no really, that's all!)</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><a href="https://docs.openzeppelin.com/contracts/3.x/erc20" target="_blank" rel="noreferrer noopener nofollow">Constructing an ERC20 Token Contract</a> has been made simpler with OpenZepplin; which is a library that provides reusable templates for writing a smart contract that complies with the ERC20 standard. <br>Using OpenZepplin, we can inherit the methods where we can change the name, symbol, and decimals. These tokens are sent to an address specified during the minting process. Being the, <a href="https://docs.soliditylang.org/en/develop/units-and-global-variables.html#block-and-transaction-properties" target="_blank" rel="noreferrer noopener nofollow"><em>msg.sender</em> </a>argument.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>By default: ERC20 uses 18 decimals. Where 1 Eth, is equal to 10^18. Or (<strong>1 Ether = 1,000,000,000,000,000,000 wei</strong>).</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>You can have a look at an example of an ERC20 Smart Contract in Remix. In fact, OpenZepplin provides a<a href="https://docs.openzeppelin.com/contracts/4.x/wizard" target="_blank" rel="noreferrer noopener nofollow"> Smart Contract Wizard</a> for creating your own token.</p>
<!-- /wp:paragraph -->

<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column {"verticalAlignment":"center","width":"33.33%"} -->
<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:33.33%"><!-- wp:image {"align":"center","id":1966,"width":256,"height":256,"sizeSlug":"full","linkDestination":"none"} -->
<div class="wp-block-image"><figure class="aligncenter size-full is-resized"><img src="https://smartbuilds.io/wp-content/uploads/2022/01/jpowell-meme.gif" alt="jpow-money-printer" class="wp-image-1966" width="256" height="256"/><figcaption>License to Mint Tokens</figcaption></figure></div>
<!-- /wp:image --></div>

<!-- wp:column {"width":"66.66%"} -->
<div class="wp-block-column" style="flex-basis:66.66%"><!-- wp:paragraph -->
<p>As interesting as it is, this can theoretically make anyone their own federal reserve of their own currency. This may explain the <a href="https://etherscan.io/tokens" target="_blank" rel="noreferrer noopener nofollow">500,000+ Tokens deployed on the Ethereum main net</a>. It’s important to note, some are only designed to part you from your cash. (Given that, anyone could literally recreate your smart contract, name, ID, and symbol). That's why, It’s important to verify the contract address, and whether it’s legitimate.</p>
<!-- /wp:paragraph --></div>
</div>
<!-- /wp:columns -->

<!-- wp:paragraph -->
<p>Additionally, further examples of using tokens as reward points include gaming, loyalty points in online services, or even a gift card. (In the form of cryptocurrencies).<br><br>This can even expand to social media platforms. <a href="https://joinspace.xyz/" target="_blank" rel="noreferrer noopener nofollow">JoinSpace.xyz</a> is a decentralized social media platform I developed, which allows users to earn tokens based on their content quality.</p>
<!-- /wp:paragraph -->


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/odf09j510opge7t46zp6.png)