<h1>Tokens, Smart Contracts, Fungible vs Non-Fungible Tokens, Mining, Address, Blocks and all the different Block-chain jargon explained.</h1>
<h2>Preface</h2>
<p>I have been learning development with Web3 lately and have come to understand about a lot of topics which were a black box for me before starting in and I felt like writing a blog about writing everything down and explaining everything in a simple way so as to everyone could understand it.</p>
<h2>Introduction</h2>
<p>First of all, you should understand why is this even a thing. It all started with the creation of Bitcoin and decentralised finance sector. After the creation of bitcoin and the rise of it everyone was excited about how the decentralised thing solves all the problems that we have currently in our world and was hyped about it. A few years went by and <a href="https://en.wikipedia.org/wiki/Vitalik_Buterin">Vitalik Buterin</a> and <a href="https://en.wikipedia.org/wiki/Gavin_Wood">Gavin Wood</a> created Ethereum. While it also had a currency with it, but it was more than that. It introduced the concepts of Smart Contracts and with it started the journey of dApps. </p>
<h2>Basics</h2>
<p>Well Smart Contracts are nothing but a piece of code similar to a class in Java or C-Sharp and it runs on EVM's. dApps are nothing but a cool nick name of Decentralised Applications or simply saying applications which run on a decentralised network like Ethereum. </p>
<p>EVM's (nothing but Ethereum Virtual Machine) are the machines on which the ethereum software runs which basically supports all of the things that are necessary for running a ethereum node (server).</p>
<p>Smart Contracts get converted to bytecode once compiled and they run on EVM. eerily similar to how Java works.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640783724211/oyR_2nRbe.png" alt="Structure of EVM Node"></p>
<p><em>Source of this <a href="https://medium.com/@dtembe/ethereum-node-evm-application-geth-smart-contract-monitoring-5c9388d1405f">image</a></em></p>
<p>Now you can write Smart Contracts in a bunch of languages like <a href="https://vyper.readthedocs.io/en/stable/">Vyper</a>, <a href="https://docs.soliditylang.org/en/v0.8.11/">Solidity</a>, <a href="https://docs.near.org/docs/develop/contracts/rust/intro">Rust</a> etc. but the most famous one is Solidity and we are going to keep our focus on Solidity to keep things simple.</p>
<p>So now we know about Ethereum, Smart Contracts and EVM, also discussed about how you can write a smart contract. Next Step talking about Tokens. </p>
<h2>Why Tokens</h2>
<p>Tokens are best described as a state variable inside of a Smart Contract which is used in transactions (function calls) to interact with them and allow their transfer from one person to another to create a sense of ownership. </p>
<p>An OpenZeppelin description is sometimes better than what I said and it is here </p>
<blockquote>
<p>A token is a representation of something in the blockchain. This something can be money, time, services, shares in a company, a virtual pet, anything. By representing things as tokens, we can allow smart contracts to interact with them, exchange them, create or destroy them.</p>
</blockquote>
<p><a href="https://docs.openzeppelin.com/contracts/2.x/tokens">Source</a></p>
<p>All these tokens and complex Smart Contract behavior needs to be standardized and that's why a number of Standardized ways of creating tokens have been made. These standards are known as Token Standards and there are a number of them. </p>
<blockquote>
<p>One of the many Ethereum development standards focus on token interfaces. These standards help ensure smart contracts remain composable, so for instance when a new project issues a token, that it remains compatible with existing decentralized exchanges. <a href="https://ethereum.org/en/developers/docs/standards/tokens/#introduction">Source</a></p>
</blockquote>
<h2>Token Standards</h2>
<p>The most common and prevalent Token Standards with their primary use-cases are listed here -</p>
<ol>
<li>ERC-20 - A standard interface for fungible (interchangeable) tokens, like voting tokens, staking tokens or virtual currencies.</li>
<li>ERC-721 - A standard interface for non-fungible tokens, like a deed for artwork or a song.</li>
<li>ERC-777 - ERC-777 allows people to build extra functionality on top of tokens such as a mixer contract for improved transaction privacy or an emergency recover function to bail you out if you lose your private keys.</li>
<li>ERC-1155 - ERC-1155 allows for more efficient trades and bundling of transactions – thus saving costs. This token standard allows for creating both utility tokens (such as $BNB or $BAT) and Non-Fungible Tokens like CryptoPunks.</li>
</ol>
<p>This brings another complexity into question Fungible vs Non-Fungible tokens. The main difference between Fungible and Non-Fungible tokens is like Fungible tokens are tokens which all represent the same entity. Like each fungible token is representing exactly the same entity anywhere in the smart contract. While Non-Fungible Tokens can each represent a different entity and would have different cost/value. </p>
<p>Look at it this way, As tokens are something that represent an entity and should have value you can think of Fungible tokens as like a <code>dollar</code> that each and every <code>dollar</code> of the same type will have similar value. </p>
<p>While NFT's are generally tokenized representations of different things, they can be anything from an image to a video or an art piece. </p>
<p>The benefit of a NFT is that you can prove that certain NFT which represents a real world item is owned by a certain person because it is proved by blockchain. It gives a whole new meaning to calculating ownership of certain items and give a lot of freedom for artists to create unique pieces of art and sell them to a particular party and the whole chain would know that it is owned by them. It makes owning things a lot clearer and open.</p>
<p>This image would help you differentiate a little bit more between these two -</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640846729650/-pD5OfsVB.png" alt="Difference between Fungible and Non-Fungible Tokens"></p>
<p><a href="https://blockchainhub.net/blog/blog/nfts-fungible-tokens-vs-non-fungible-tokens/">Source</a></p>
<h2>Blockchain in a gist</h2>
<p>If you don't know all of this happens on blockchain and every detail is written in a linked data structure. It is structure in which even if someone tries to forge some entry it will be next to impossible to do so. While this is a very broad topic I recommend seeing this video to give you a gist about everything </p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/_160oMzblY8" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<p>If you seen that video all the things that I am going to say below will make sense so be sure to watch it. </p>
<p>All of the data written on chain is stored in a block which is like a bucket or box for storing the data in.</p>
<p>If you have seen the video you would understand there is some calculation that needs to happen whenever something is written on chain, and one cannot forge an entry into any of the blocks which have already been written and the more number of nodes there are the more secure a Blockchain becomes.</p>
<p>This process of verifying data that is already written is altogether known as mining. Because it requires compute as well as energy to do so. Every node that verifies some data already on blockchain gets some reward which is what the profit of mining in blockchain is. </p>
<p>For making transactions or reading data from a blockchain you need to have an Address, which basically is a account which you can use to work through the whole decentralised networks.</p>
<p>These address are automatically created whenever you use a wallet like metamask or with brave browsers inbuilt wallet. Note - there are bunch of different wallets that you can use and I have only listed the one's I am aware of.</p>
<p>That is all folks, I leave with this much information and I hope to write soon more about the things that I am learning.</p>
<p>Feel free to comment here and let me know if you find any thing which is wrong with whatever I have written.</p>