<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Mayank Vats</title>
    <description>The latest articles on Forem by Mayank Vats (@_mayankvats).</description>
    <link>https://forem.com/_mayankvats</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F558199%2F8f43289a-3de8-44b5-89f1-6d7568f9de16.jpg</url>
      <title>Forem: Mayank Vats</title>
      <link>https://forem.com/_mayankvats</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/_mayankvats"/>
    <language>en</language>
    <item>
      <title>Hardhat Implementation</title>
      <dc:creator>Mayank Vats</dc:creator>
      <pubDate>Mon, 28 Feb 2022 17:58:30 +0000</pubDate>
      <link>https://forem.com/_mayankvats/hardhat-implementation-4bj5</link>
      <guid>https://forem.com/_mayankvats/hardhat-implementation-4bj5</guid>
      <description>&lt;p&gt;Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software. &lt;br&gt;
Following document contains the minimal implementation steps to get started with hardhat:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Initialise an empty node project.  &lt;code&gt;npm init&lt;/code&gt; / &lt;code&gt;yarn init&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Install hardhat.  &lt;code&gt;npm i hardhat&lt;/code&gt; / &lt;code&gt;yarn add hardhat&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Install following dev dependencies: 
&lt;code&gt;npm install -D @nomiclabs/hardhat-ethers ethers @nomiclabs/hardhat-waffle ethereum-waffle chai&lt;/code&gt;
/
&lt;code&gt;yarn add -D @nomiclabs/hardhat-ethers ethers @nomiclabs/hardhat-waffle ethereum-waffle chai&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Run this command: &lt;code&gt;npx hardhat&lt;/code&gt;. After running this command you will get the following prompt: (choose to create an empty hardhat.config.js)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JxnA-qFV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s1dk8j55w196dwcuc7v1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JxnA-qFV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s1dk8j55w196dwcuc7v1.png" alt="Image description" width="880" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Replace the contents of hardhat.config.js with the following: &lt;a href="https://gist.github.com/mvrapidinnovation/a3e50c3550ec3304648b332fa2988ae1"&gt;hardhat.config.js&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Create the following folders in the root directory, 
&lt;code&gt;contracts/&lt;/code&gt;  &lt;code&gt;scripts/&lt;/code&gt;  &lt;code&gt;test/&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;contracts/&lt;/code&gt; - Here you will store all your contracts&lt;br&gt;
 &lt;code&gt;scripts/&lt;/code&gt; - Here you will store scripts for deploying contracts to the network&lt;br&gt;
 &lt;code&gt;test/&lt;/code&gt; - Here you will store all your test scripts&lt;/p&gt;

&lt;p&gt;The upcoming text will show you how to, compile, test and deploy a basic ERC20 contract using hardhat.&lt;br&gt;
NOTE: run this command &lt;code&gt;“npm i -g hardhat-shorthand”&lt;/code&gt;, to use &lt;code&gt;“hh”&lt;/code&gt; with every hardhat command you run instead of &lt;code&gt;”npx hardhat”&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Contract Compilation Using Hardhat:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can use &lt;a href="https://gist.github.com/mvrapidinnovation/dfec788fcc234b1baf59c31d6c0724f1"&gt;this&lt;/a&gt; contract.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Make a file “Token.sol” in the contracts/ folder and copy paste the code from the above link.&lt;/li&gt;
&lt;li&gt;Save the file and then go to the terminal and run &lt;code&gt;hh compile&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;After compiling two folders will be created namely &lt;code&gt;artifacts/&lt;/code&gt; and &lt;code&gt;cache/&lt;/code&gt;. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--va234ANS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/marztyf8lr5o9hhqg2i4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--va234ANS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/marztyf8lr5o9hhqg2i4.png" alt="Image description" width="606" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;artifacts/&lt;/code&gt; folder will contain the contract’s ABI and bytecode. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Contract Testing Using Hardhat:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can use &lt;a href="https://gist.github.com/mvrapidinnovation/42cf9f4b24a96818a0a695bd042d78f6"&gt;this&lt;/a&gt; basic testing script to get started.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Make a file “TokenTest.js” in the &lt;code&gt;test/&lt;/code&gt; folder and copy paste the code from above link.&lt;/li&gt;
&lt;li&gt;Save the file and then go to the terminal and run &lt;code&gt;“hh test test/TokenTest.js”&lt;/code&gt;.
Output should look something like below:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3_ZlrbHC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4lud0fs00ek3idn6xrx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3_ZlrbHC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4lud0fs00ek3idn6xrx.png" alt="Image description" width="698" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Contract Deployment Using Hardhat:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can use &lt;a href="https://gist.github.com/mvrapidinnovation/7b909a6f5295ac24aaa342f3cd76a311"&gt;this&lt;/a&gt; deployment script to get started. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: To deploy the script, replace  values with your own privateKey in the hardhat’s config file.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make a file “TokenDeploy.js” in the &lt;code&gt;scripts/&lt;/code&gt; folder and copy paste the code from above link.&lt;/li&gt;
&lt;li&gt;Save the file and then go to the terminal and run &lt;code&gt;“hh run scripts/TokenDeploy.js  --network bscTestnet”&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;You can search for the address &lt;a href="https://testnet.bscscan.com/"&gt;here&lt;/a&gt; and verify that the contract has been deployed. Save the contract’s address somewhere.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Contract Verification Using Hardhat:
&lt;/h2&gt;

&lt;p&gt;To verify contracts using hardhat we will need to install a hardhat plugin &lt;code&gt;“hardhat-etherscan”&lt;/code&gt;. Following steps will walk you through with that.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If you use yarn, run the following command: 
&lt;code&gt;“yarn add -D @nomiclabs/hardhat-etherscan”&lt;/code&gt;
and if you are using npm: 
&lt;code&gt;“npm i -D @nomiclabs/hardhat-etherscan”&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Then require the plugin in the hardhat’s config file.&lt;/li&gt;
&lt;li&gt;Now make an account &lt;a href="https://bscscan.com/"&gt;here&lt;/a&gt; and then go into the API keys section to create and get your API key.&lt;/li&gt;
&lt;li&gt;Copy the API key and paste it in the hardhat’s config as shown below.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jMkFSbMV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0iwwccw21b8qsimg2lz4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jMkFSbMV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0iwwccw21b8qsimg2lz4.png" alt="Image description" width="574" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now run this command in your terminal: hh verify --network bscTestnet "CONTRACT_ADDRESS_HERE".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This concludes the basics of getting started with the hardhat. I hope this has helped you.  &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Javascript: Under the hood</title>
      <dc:creator>Mayank Vats</dc:creator>
      <pubDate>Sun, 27 Jun 2021 11:02:47 +0000</pubDate>
      <link>https://forem.com/_mayankvats/javascript-under-the-hood-411n</link>
      <guid>https://forem.com/_mayankvats/javascript-under-the-hood-411n</guid>
      <description>&lt;p&gt;    One day, a curious guy named Thomas, who is a Software Developer, was wondering What does the execution context means? What actually happens when the JavaScript program first runs? If JavaScript is single threaded then how does it work asynchronously?&lt;/p&gt;

&lt;p&gt;    He then shifted himself into learning mode and started searching for the answers and wrote about all his learning, which I am going to share here.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 The First Run
&lt;/h2&gt;

&lt;p&gt;        Whenever we write the JavaScript code and execute it in our browser or in NodeJs, following things happen:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The compiler goes throw the whole source code, assigning memory to the variables, storing function definitions and creating Global Execution Context (Creation Phase).&lt;/li&gt;
&lt;li&gt;Then, it assigns the values to the variables, makes execution context on each function call, and also pushes the function onto the call stack (Execution Phase)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's take an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var message = "Hello World!";

const send = function (message) {
  const log = `"${message}" sent to the reciever`;
  console.log(log);
};

send(message);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;    For the code above, firstly the compiler reads through it and decides which variables need memory and what function definitions needs to be stored, this is the Creation Phase.&lt;/p&gt;

&lt;p&gt;    Secondly, the compiler goes through the code again and this time it assigns the values to the variables and looks for the function calls to create an Execution Context.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6qmk58h03fh56pt3lq5d.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6qmk58h03fh56pt3lq5d.jpeg" alt="Execution Context"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;    In the image above GEC is the Global Execution Context, which is always at the base of the call stack, you may have seen something like &lt;code&gt;&amp;lt;anonymous&amp;gt;&lt;/code&gt; in the browser's console.&lt;/p&gt;

&lt;p&gt;    Similarly, when the send function is called, the creation and execution phases are carried out and an execution context is created.&lt;/p&gt;

&lt;p&gt;    Execution Context can be thought of as an environment or a place where the current code execution is taking place.&lt;/p&gt;

&lt;p&gt;    So, whenever the JavaScript code runs, very first execution context that is the Global Execution Context is created, this Global Execution Context is the place which is responsible for storage and execution of the rest of the code, then on every function call a new execution context gets created, which may also refer to its parent execution context.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Synchronous Nature
&lt;/h2&gt;

&lt;p&gt; JavaScript is a single threaded programming language, that means, JavaScript engine has only one call stack and one memory heap. Due to the presence of only single call stack it can run single instruction at a time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2r397i4sqmjhph4jegbq.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2r397i4sqmjhph4jegbq.jpeg" alt="Call stack and Heap"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;    Earlier, JavaScript was used for only dynamic rendering of elements in the web pages and form validation. These tasks required only single thread to run on. But, as the technology progressed and web applications became more complex, more long running tasks such as an API call, querying the database, prompting user to upload a file, became headache with this synchronous flow.&lt;/p&gt;

&lt;p&gt;To mimic this synchronous and blocking nature, Open your browser's console and type &lt;code&gt;alert()&lt;/code&gt; and press enter.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Asynchronous Nature
&lt;/h2&gt;

&lt;p&gt;    JavaScript got its asynchronous nature with the help of its runtime, which consists of a JavaScript Engine, Web APIs, callback queue and an event loop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyo7dqdmryb7q3kjz12n6.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyo7dqdmryb7q3kjz12n6.jpeg" alt="JavaScript Runtime"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;JavaScript Engine&lt;/em&gt;, consists of Call Stack and Memory Heap, which are responsible for execution of the  JavaScript code.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Call Stack&lt;/em&gt;, keeps record of the current running function as well as the functions that needs to be executed once the current function completes its execution and is popped off the stack. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Callback Queue&lt;/em&gt;, is a queue which keeps record of the functions(or processes) that needs to be executed by the engine.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Event Loop&lt;/em&gt;, firstly checks if Call Stack is empty, monitors the Callback Queue and checks for any DOM events or processes in the queue that needs to be executed by pushing onto the stack. &lt;/p&gt;

&lt;p&gt;Combination of these is what gives JavaScript its asynchronous capabilities. Let's go through an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log("Fetching Data");

function sayHello() {
  console.log("JS says Hello!");
}

function fetchDatabase() {
  console.log("Data Retrieved");
}

setTimeout(() =&amp;gt; {
  fetchDatabase();
}, 3000);

sayHello();
console.log("Meanwhile doing some other task...");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run the above code in the browser or in the node, the output will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Fetching Data
JS says Hello!
Meanwhile doing some other task...
Data Retrieved
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following things happened when the above code is run:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript printed the first statement.&lt;/li&gt;
&lt;li&gt;After that, it called the Web API that is &lt;code&gt;setTimeout()&lt;/code&gt; and delegated the task of fetching from the database.&lt;/li&gt;
&lt;li&gt;Then the &lt;code&gt;sayHello()&lt;/code&gt; function gets pushed on to the Call Stack and the second statement gets printed and &lt;code&gt;sayHello()&lt;/code&gt; is popped off the stack.&lt;/li&gt;
&lt;li&gt;Meanwhile the Callback Queue keeps record for some other pending tasks or DOM events and Event Loop continuously checks for the tasks in the queue and pushes the task onto the Call Stack.&lt;/li&gt;
&lt;li&gt;The third statement gets printed, and after 3 seconds the data is retrieved and Event Loop pushes it onto the Call Stack and the last statement gets printed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;    Here you saw that how &lt;code&gt;setTimeout()&lt;/code&gt; simulated a long running task of fetching from database and the asynchronous nature of the runtime made the code Non-blocking.&lt;/p&gt;

&lt;p&gt;In this post you got an idea about:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Execution Context and the two phases&lt;/li&gt;
&lt;li&gt;Single threaded nature of JavaScript&lt;/li&gt;
&lt;li&gt;Call Stack and Memory Heap&lt;/li&gt;
&lt;li&gt;JavaScript Runtime, event loop, callback queue&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Keep Learning and Keep Growing 🎉&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>programming</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Micro-services: A micro introduction</title>
      <dc:creator>Mayank Vats</dc:creator>
      <pubDate>Sat, 19 Jun 2021 12:40:27 +0000</pubDate>
      <link>https://forem.com/_mayankvats/micro-services-a-micro-introduction-1jgb</link>
      <guid>https://forem.com/_mayankvats/micro-services-a-micro-introduction-1jgb</guid>
      <description>&lt;p&gt;An introduction to micro-services is incomplete without talking about monolith architecture, so before we start talking about micro-services let's first see what a monolith is, to get a good idea of what micro-services are and why they are needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Monolith Architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbe14odrxgue8bxlq4jx.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbe14odrxgue8bxlq4jx.jpeg" alt="Monolith Diagram"&gt;&lt;/a&gt;&lt;br&gt;
  In this type of architectural style, an application is developed as a single codebase and deployed as a single unit. Let's say you want to build a small role playing game(RPG) with following features:&lt;br&gt;
    A. Build an avatar&lt;br&gt;
    B. List available power-ups&lt;br&gt;
    C. Upgrade player's power&lt;br&gt;
    D. Daily bonuses&lt;/p&gt;

&lt;p&gt;  In a monolith architecture each of these features will be bundled in a single unit and then deployed, and this single unit will refer to one single database. Earlier, this kind of architecture was very common.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Micro-service Architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjekufc5cxbtte24sqqqd.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjekufc5cxbtte24sqqqd.jpeg" alt="Microservice Diagram"&gt;&lt;/a&gt;&lt;br&gt;
  In this type of architectural style, an application is broken down based on its features, and each feature has its own codebase, known as a service, and each service refers to its own database (this model is also known as Database-per-service model).&lt;/p&gt;

&lt;p&gt;  Taking the above example of the role playing game, Build an avatar, List available power-ups, Upgrade player's power, Daily bonuses, each of these features can be a service of its own, that is, each feature can be a self-contained unit and have its own database.&lt;/p&gt;

&lt;h3&gt;
  
  
  The why of micro-services
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Multiple teams can work independently on different features.&lt;/li&gt;
&lt;li&gt;No single point of failure.&lt;/li&gt;
&lt;li&gt;Even if one service fails the other one is not affected.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Microservices also provide a great way for independent feature development.&lt;/p&gt;

&lt;p&gt;   This concludes the micro introduction to the micro-services. I hope you have learnt something new today.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Keep Learning and Keep Growing. 🎉&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>microservices</category>
      <category>webdev</category>
    </item>
    <item>
      <title>ERC 20 and Solidity: A Starting Point (Part 1)</title>
      <dc:creator>Mayank Vats</dc:creator>
      <pubDate>Tue, 12 Jan 2021 16:30:04 +0000</pubDate>
      <link>https://forem.com/_mayankvats/erc-20-and-solidity-a-starting-point-part-1-4olh</link>
      <guid>https://forem.com/_mayankvats/erc-20-and-solidity-a-starting-point-part-1-4olh</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Things you will learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Intro to solidity and smart contracts&lt;/li&gt;
&lt;li&gt;What and Why of ERC20&lt;/li&gt;
&lt;li&gt;Remix - an online code editor&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;      If you have been following the world of blockchain you may have come across some terms such as cypto currencies, tokens, digital assets etc. Thanks to Ethereum, since 2015, there have been a rise in number of projects over Ethereum blockchain and since May 2020, DeFi(Decentralized Finance) based projects are skyrocketing.&lt;/p&gt;

&lt;p&gt;      But on every blockchain based project you may have come across(or you will come across) you will notice that each project have their own token, a fungible asset for example COMP, BAL, LINK or Steve Woznaik's project &lt;a href="https://www.efforce.io/"&gt;Efforce&lt;/a&gt; token &lt;a href="https://www.coingecko.com/en/coins/efforce"&gt;WOZX&lt;/a&gt; and many more.&lt;/p&gt;

&lt;p&gt;      Each of these tokens have one thing in common, that is, they are based on ERC20 token standards and are a fungible asset. In this series we will be diving into the know how of a Smart Contract, Solidity, ERC20 token, and also how you can build and deploy your own token, so let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Smart Contract ?
&lt;/h2&gt;

&lt;p&gt;        It is a source code which is written in Solidity, Vyper, Go and many more languages, compiled to byte code and deployed over Ethereum blockchain and executed by Ethereum Virtual Machine(EVM).&lt;/p&gt;

&lt;h3&gt;
  
  
  An example (Using Solidity):
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pragma solidity ^0.6.0;

contract myContract {
    uint public a = 1;

    function setA(uint _a) public returns (uint) {
        a = _a;
        return a;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Compile and deploy smart contract
&lt;/h3&gt;

&lt;p&gt;    To try the code above in &lt;a href="http://remix.ethereum.org/"&gt;Remix&lt;/a&gt;, the online solidity's code editor, follow the given steps below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go &lt;a href="http://remix.ethereum.org/"&gt;here&lt;/a&gt; and create a new file with .sol as extension, as shown &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZI7T6ACi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/a9fdupece7icmdditefj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZI7T6ACi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/a9fdupece7icmdditefj.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy and paste the code in the example above in the file you created, and compile the code as shown (see the left side) &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--STdppbhF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mxp5k3fqx55gwugpyc5y.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--STdppbhF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mxp5k3fqx55gwugpyc5y.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now we need to deploy the compiled code to interact with it, you can deploy the code as shown in the picture (see the left side) &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fGMsVECL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sr0aywyuc9pq12ur9mbz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fGMsVECL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sr0aywyuc9pq12ur9mbz.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Interacting with the contract
&lt;/h3&gt;

&lt;p&gt;    After deploying the contract if you scroll down the left side you will see something like this&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5xnO96Wd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/inm66hcc25avv2aibvrx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5xnO96Wd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/inm66hcc25avv2aibvrx.jpg" alt="Alt Text"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;As you can see in the image above, Remix has generated two buttons for the corresponding functions in the contract setA() and a().&lt;br&gt;
Note: Since variable 'a' is declared public the getter function for its value is automatically generated with same name as variable.&lt;/p&gt;

&lt;h2&gt;
  
  
  So, What is ERC20?
&lt;/h2&gt;

&lt;p&gt;    Now you have the idea of what smart contract is, how to write and deploy one and how you can interact with it, you are ready to understand the concept of ERC20 and its tokens.&lt;br&gt;
    Every token on the Ethereum blockchain is just a smart contract with some specific functions and variables and runs on Ethereum Virtual Machine(EVM) and follows a specific rules set by Ethereum Requests for Comments(ERC). These rules state that every smart contract written for the development of an ERC20 token must have the following functions defined by the ERC:-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;function name() public view returns (string)&lt;/li&gt;
&lt;li&gt;function symbol() public view returns (string)&lt;/li&gt;
&lt;li&gt;function decimals() public view returns (uint8)&lt;/li&gt;
&lt;li&gt;function totalSupply() public view returns (uint256)&lt;/li&gt;
&lt;li&gt;function balanceOf(address _owner) public view returns (uint256 balance)&lt;/li&gt;
&lt;li&gt;function transfer(address _to, uint256 _value) public returns (bool success)&lt;/li&gt;
&lt;li&gt;function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)&lt;/li&gt;
&lt;li&gt;function approve(address _spender, uint256 _value) public returns (bool success)&lt;/li&gt;
&lt;li&gt;function allowance(address _owner, address _spender) public view returns (uint256 remaining)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  But why does the smart contract must adhere to these rules? Why can't we make our own functions?
&lt;/h4&gt;

&lt;p&gt;    Well, we can make our own functions and there is nothing wrong in doing so. But, if every developer makes their own functions for the token's smart contract then to interact with those contracts you would first need to know about name and signature of each function, which may be an inefficient way, since the idea behind every token's smart contract is same, that is to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;keep track of and check total supply.&lt;/li&gt;
&lt;li&gt;keep track of and check each user's balance.&lt;/li&gt;
&lt;li&gt;transfer the tokens to other account.&lt;/li&gt;
&lt;li&gt;allow someone else to transfer them on your behalf.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thus, ERC20 standard makes our life easier and we don't have to know about the name and signature of particular token's smart contract functions for total supply, balance, transfer and allowing someone else to transfer those tokens.&lt;/p&gt;

&lt;h3&gt;
  
  
  Make your own token
&lt;/h3&gt;

&lt;p&gt;You can make your own token right now, by following the steps mentioned above for compiling and deploying the contract.&lt;br&gt;
The contract's code can be found &lt;a href="https://github.com/MayankVats/smart-contracts/blob/main/myToken.sol"&gt;here&lt;/a&gt; which you can copy paste into &lt;a href="http://remix.ethereum.org/"&gt;Remix&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for your valuable time. I will be writing the Part 2 of this blog in a short while, where I will explain each and every function of the ERC20 Token smart contract.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
