<?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>DEV Community: Tanisk Annpurna</title>
    <description>The latest articles on DEV Community by Tanisk Annpurna (@taniskannpurna).</description>
    <link>https://dev.to/taniskannpurna</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%2F884642%2F1f4837b0-2b00-4570-9262-1cb573fa102f.png</url>
      <title>DEV Community: Tanisk Annpurna</title>
      <link>https://dev.to/taniskannpurna</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/taniskannpurna"/>
    <language>en</language>
    <item>
      <title>Scaling Databases (Sharding)</title>
      <dc:creator>Tanisk Annpurna</dc:creator>
      <pubDate>Mon, 24 Jun 2024 12:11:01 +0000</pubDate>
      <link>https://dev.to/taniskannpurna/scaling-databases-sharding-b76</link>
      <guid>https://dev.to/taniskannpurna/scaling-databases-sharding-b76</guid>
      <description>&lt;p&gt;💜 &lt;strong&gt;DAY4 -&amp;gt; Scaling Databases (Sharding)&lt;/strong&gt; 💜&lt;/p&gt;

&lt;p&gt;As in my previous blogs, We talked about replication of databases. In this We will talk about Sharding.&lt;/p&gt;

&lt;p&gt;👉 What is Sharding?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Sharding is simply dividing DB mutually exclusive, so data is divided.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In simple word, you divide data in smaller chunks called as shards because as data becomes huge the performance also decreases, but having smaller data does not impact performance that much.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;Real life example : *&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's say we have a huge list of names stored on db.&lt;/li&gt;
&lt;li&gt;Now we can divide db into 3 shards like shard1 will store names starting 'A' to 'J', shard2 -&amp;gt; 'K' to 'T' and shard3 -&amp;gt; 'U' to 'Z'.&lt;/li&gt;
&lt;li&gt;When request comes to store new names in db, we can simply check first character and point it to proper shard for storing data.&lt;/li&gt;
&lt;li&gt;When GET request comes, then also we will be able to decide which shard would hold data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fus5b3zdtfzl9bah9x2h3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fus5b3zdtfzl9bah9x2h3.png" alt="API to shards" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;-&amp;gt; Remember Image shown above as different shards is not different database but its a single database which has 3 nodes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL vs NO-SQL&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Both dbs has inbuilt sharding features.&lt;/li&gt;
&lt;li&gt;SQL follows ACID properties but NO-SQL doesn't. So if there is any update that have to be run on multiple shards, SQL will either perform operations on all shards or none shards at all. but NO-SQL can give intermediate results.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;BENEFITS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Improved Scalability: It allows Dbs to handle more capacity in much better way.&lt;/li&gt;
&lt;li&gt;Increased Performance: Any operation that works on only one shard, will achieve result much faster as data is less, so performance is more.&lt;/li&gt;
&lt;li&gt;Fault Tolerance: If one fails, the others can continue to serve the requests. So, not complete outbreak.&lt;/li&gt;
&lt;li&gt;Reduced Costs: Vertical Scaling is costly thus sharding allows horizontal scaling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why is sharding not used by default&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The reason for this is very simple, Its very costly as well as time consuming for 2 shards to communicate with each other even though they belong to same DB. So it becomes absolute important to select such data on which sharding is done, so that there is none to minimum communication requirement between shards.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>systemdesign</category>
      <category>softwareengineering</category>
      <category>softwaredevelopment</category>
      <category>sharding</category>
    </item>
    <item>
      <title>DAY3 -&gt; Scaling Databases (Replication)</title>
      <dc:creator>Tanisk Annpurna</dc:creator>
      <pubDate>Fri, 21 Jun 2024 18:39:43 +0000</pubDate>
      <link>https://dev.to/taniskannpurna/day3-scaling-databases-replication-30pd</link>
      <guid>https://dev.to/taniskannpurna/day3-scaling-databases-replication-30pd</guid>
      <description>&lt;ul&gt;
&lt;li&gt;As in my previous blogs, We talked about vertical scaling. In this We will talk about Horizontal Scaling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;HORIZONTAL SCALING&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We know that for any db read &amp;amp; write ratio is 90:10;&lt;/li&gt;
&lt;li&gt;The very basic scaling that we can do is have separate db just for reading and separate db for writing.&lt;/li&gt;
&lt;li&gt;Through API we can send request to replica DB(Read operation) and Master DB(Write operation).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It would look something like shown below. (Replica DB can be multiple)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn9rm3z4wtjd7xt09y6fj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn9rm3z4wtjd7xt09y6fj.png" alt="Master DB with Replicas" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data consistency becomes a big part as we don't want data to be different in replica db and in master db. So, its very important to replicate the data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are mainly 2 ways to replicate :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;SYNCHRONOUS&lt;/li&gt;
&lt;li&gt;This means that when there is any write/update operation then through code or DB, we also update replica DB at the same time thus resulting in &lt;/li&gt;
&lt;li&gt;More response time &lt;/li&gt;
&lt;li&gt;Slower writes&lt;/li&gt;
&lt;li&gt;Zero replication logs&lt;/li&gt;
&lt;li&gt;Very strong consistency.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyslw2cm0m94zhthlk5r4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyslw2cm0m94zhthlk5r4.png" alt="Synchronous replication" width="800" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;ASYNCHRONOUS&lt;/li&gt;
&lt;li&gt;This means that we keep logs of all the write operations on master db and at certain time we just run those logs on replica dbs. This results in
&lt;/li&gt;
&lt;li&gt;Small response time&lt;/li&gt;
&lt;li&gt;Faster writes as it doesn't write on multiple db at a time, some replication logs&lt;/li&gt;
&lt;li&gt;Eventual consistency.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F240ypk3mv4te0nq69yp2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F240ypk3mv4te0nq69yp2.png" alt="Asynchronous replication" width="800" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>system</category>
      <category>softwaredevelopment</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Day1-100 series - Learning System Design for Interviews.</title>
      <dc:creator>Tanisk Annpurna</dc:creator>
      <pubDate>Thu, 20 Jun 2024 14:57:41 +0000</pubDate>
      <link>https://dev.to/taniskannpurna/day1-100-series-learning-system-design-for-interviews-13f3</link>
      <guid>https://dev.to/taniskannpurna/day1-100-series-learning-system-design-for-interviews-13f3</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Day2 -&amp;gt; Learning Databases&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Remember 90% of battle is won, when you select correct database for your system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are 2 types of Databases Relational(SQL) and Non-Relational(NoSql). In todays post we will learn about Relational Databases, ACID properties &amp;amp; Scaling them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RELATIONAL DBs&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Relational DBs were originally created for financial purposes. In 90's there were financial companies had ledgers that were filled by people to mantain financial records and it was tiresome as well as error prone. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;So Relational DB's were inspired from those ledgers like rows and columns. They had to follow all the properties those ledgers had.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All the properties provided by Relational DB's can be generalised to ACID properties : &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;A -&amp;gt; Atomicity&lt;/li&gt;
&lt;li&gt;C -&amp;gt; Consistency&lt;/li&gt;
&lt;li&gt;I -&amp;gt; Isolation&lt;/li&gt;
&lt;li&gt;D -&amp;gt; Durability&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;ATOMICITY&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This simply means that if you have multiple queries under a transaction, either all of then will be executed or none of them will be executed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Eg. Let's say Person A is transferring 50₹ to Person B. Now we have 2 statements to execute, one would deduct 50₹ from Person A and add 50₹ to Person B. So, either both of them will have to be executed or none of them should be executed to mantain consistency between data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CONSISTENCY&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This simply means that Relation DB's provides lots of tools and features to make sure that data is consistent. Some of the features are like &lt;em&gt;Foreign Keys&lt;/em&gt;, &lt;em&gt;Constraints&lt;/em&gt;, &lt;em&gt;Cascades&lt;/em&gt;, &lt;em&gt;triggers&lt;/em&gt; and many more. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;ISOLATION&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This simply means that Relational DB's provide multiple levels of transparency between two transactions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Eg. Let's say Person A and Person B are running transactions at the same time on the same data, Now we can decide on our requirements when, where or how much transparency is there about changes.&lt;/p&gt;

&lt;p&gt;Isolations have 4 levels&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;&lt;u&gt;READ UNCOMMITTED&lt;/u&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;This isolation level allows dirty reads, i.e., where a transaction may see uncommitted changes made by some other transaction. This means values in the data can be changed and rows can appear or disappear in the data set before the transaction completes.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In general, don’t use READ UNCOMMITTED. The one and only time it ever makes sense is when you are reading data that will never be modified in any way. For example, if you need to scan a large volume of data to generate high-level analytics or summaries, and absolute moment-of-query accuracy is not critical.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;READ COMMITTED&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is the default isolation level in most Postgres databases, and older SQL databases in general.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It restricts the reader from seeing any intermediate, uncommitted, ‘dirty’ read during a transaction and guarantees that any data read was committed at the moment it was read.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;REPEATABLE READ&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;REPEATABLE READ is the ideal isolation level for read-only transactions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;REPEATABLE READ would be a good choice for a financial app that calculates the total balance of a user’s accounts. This isolation level ensures that if a row is read twice in the same transaction, it will return the same value each time, preventing the nonrepeatable read anomaly mentioned above. In this case, when calculating a user’s total balance, REPEATABLE READ guarantees that the balance does not change during the calculation process due to concurrent updates.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;SERIALIZABLE&lt;/u&gt;&lt;/strong&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SERIALIZABLE is the highest level of isolation (and the default isolation level in CockroachDB). &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Transactions are completely isolated from each other, effectively serializing access to the database to prevent dirty reads, non-repeatable reads, and phantom reads.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;SCALING DBs&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There are 2 types of scaling - VERTICAL &amp;amp; HORIZONTAL.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;VERTICAL SCALING&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vertical scaling is simpler and should always be the first option in terms of scaling.&lt;/li&gt;
&lt;li&gt;Vertical scaling is adding more power like increasing RAMs, CPU or PROCESSOR power, MEMORIES etc.&lt;/li&gt;
&lt;li&gt;Vertical scaling is limited by hardware, like whatever source used will have certain hardware limit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;HORIZONTAL SCALING&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We know that 90% of the time we perform read operations. So, for these read operations we can have seperate db which handles only read operations.&lt;/li&gt;
&lt;li&gt;We can do sharding, partitioning and many more things for scaling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will read SHARDING, REPLICATION and PARTITIONING in the next blog.&lt;/p&gt;

&lt;p&gt;If you love posts like this, and think its beneficial, do follow and if any confusion do post any questions in comments.&lt;/p&gt;

</description>
      <category>database</category>
      <category>sql</category>
      <category>nosql</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>Day1-100 series - Learning System Design for Interviews.</title>
      <dc:creator>Tanisk Annpurna</dc:creator>
      <pubDate>Thu, 20 Jun 2024 06:12:25 +0000</pubDate>
      <link>https://dev.to/taniskannpurna/day1-100-series-learning-system-design-for-interviews-19im</link>
      <guid>https://dev.to/taniskannpurna/day1-100-series-learning-system-design-for-interviews-19im</guid>
      <description>&lt;p&gt;Hello everyone, I am starting Day1-100 series on Learning System Design for Interviews.&lt;/p&gt;

&lt;p&gt;We will go from 0-100 in system design. If you want to learn system design follow and share, I will be posting everyday about system designs.&lt;/p&gt;

&lt;h1&gt;
  
  
  Day1 -&amp;gt; 💜 &lt;strong&gt;&lt;u&gt;LATENCY and THROUGHPUT&lt;/u&gt;&lt;/strong&gt; 💜
&lt;/h1&gt;

&lt;p&gt;Let's start,&lt;br&gt;
In today's date, every system is online and is accessible to everyone across the globe. So Latency and Throughput becomes one of the most important factors to measure performance of any system.&lt;/p&gt;

&lt;p&gt;💁‍♂️ &lt;strong&gt;What is Latency ?&lt;/strong&gt; &lt;br&gt;
👉 Latency is the measurement of time between request sent and response received by the system. In simple terms, when you open a website i.e. you send a request and then the delay taken for the response to arrive. &lt;br&gt;
👉 Latency measured in ms(milliseconds).&lt;br&gt;
👉 Low latency is always preferred over high latency. There are systems where low latency is compulsory like Online Video games and high latency always gives bad user experience.&lt;br&gt;
👉 Latency can be measured using ping test or there are many tools which can measure and record latency over a period of time.&lt;/p&gt;

&lt;p&gt;💁‍♂️ *&lt;em&gt;What is throughput ? *&lt;/em&gt;&lt;br&gt;
👉 Over the networks, we send data using data packets. Now these data packets are like small chunks of bigger data. System takes those data packets and combine them back to create the bigger data. Hence that's why we see images on websites taking much more time to load instead of text because text data is smaller in size and image data.&lt;br&gt;
👉 Now, Throughput refers to the amount of data that can be transferred over a network in a period of time. &lt;br&gt;
👉 So, When data is transferred through networks, due to multiple factors, data packets are lost and system will request for them again and again till it gets complete data or it hits connection timeout.(Connection is broken when it hits timeout).&lt;br&gt;
👉 Throughput is measured in Mbps(megabit per second) or bps(bit per second).&lt;br&gt;
👉 There are lots of tools to measure throughput of a system like when you do speedtest on your browser that also simulates network traffic generators.&lt;/p&gt;

&lt;p&gt;🔺 Remember throughput is affected by latency and bandwidth(the internet speed that you buy from your ISP). So we use tools as it gives throughput and latency separately.&lt;/p&gt;

&lt;p&gt;💁‍♀️ &lt;strong&gt;Impacting factors for latency&lt;/strong&gt;&lt;br&gt;
👉 Location : if your data has to travel long distance, latency will always be high.&lt;br&gt;
👉 Protocol efficiency : Depending on the network protocol, latency may differs such as TCP does 3 handshakes for making and breaking connections. So it creates a delay.&lt;br&gt;
👉 Infrastructure : if network infrastructures are overloaded, then data packets will be dropped, delayed adding it to latency.&lt;br&gt;
👉 Congestion : Network data packets is bound to take longer distance routes, when there is high volume of data transferred.&lt;/p&gt;

&lt;p&gt;💁‍♀️ &lt;strong&gt;Impacting factors for Throughput&lt;/strong&gt;&lt;br&gt;
👉 Bandwidth : If your network bandwidth is 1Gbps, you can send much more data packets in short amount of time resulting in less loss of data packets.&lt;br&gt;
👉 Network topology : Depending on number of devices connected, distance between devices plays a major role in throughput.&lt;br&gt;
👉 Packet loss : Misconfiguration, network overloaded and many more affects through put.&lt;br&gt;
👉 Processing Power : Certain network devices are specialized in handling complex data packets, or more optimized interms of data packets lost.&lt;/p&gt;

&lt;p&gt;These are few factors that affect latency and throughput of system.&lt;/p&gt;

&lt;p&gt;Hopefully, you may have enjoyed these. Do Follow and show some love.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>systems</category>
    </item>
    <item>
      <title>GoLang (Part 1)</title>
      <dc:creator>Tanisk Annpurna</dc:creator>
      <pubDate>Sat, 03 Sep 2022 21:02:34 +0000</pubDate>
      <link>https://dev.to/taniskannpurna/golang-part-1-c3h</link>
      <guid>https://dev.to/taniskannpurna/golang-part-1-c3h</guid>
      <description>&lt;p&gt;&lt;strong&gt;💜Little about goLang..&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;goLang was designed by google in 2007.&lt;/li&gt;
&lt;li&gt;They wanted to create a language that would fix problems with traditional languages like concurrency.&lt;/li&gt;
&lt;li&gt;Languages like Java, C++ can be used to implement concurrency but its quite hard as well as complicated.&lt;/li&gt;
&lt;li&gt;They also wanted the new language to have better memory safety, better garbage collection, better structural typing with being much faster and readable.&lt;/li&gt;
&lt;li&gt;goLang is very efficient and mainly used in distributed systems. &lt;/li&gt;
&lt;li&gt;This language quite resembles with python for simplicity and C++ for efficiency.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉Remember, The best part of goLang is it removes complication for implementing concurrency. We will look into that in the upcoming articles.&lt;/p&gt;

&lt;p&gt;👉 Follow this article for setting up your system to run goLang &lt;a href="https://levelup.gitconnected.com/how-to-run-your-first-go-application-in-three-simple-steps-1539e846f792"&gt;Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💜VARIABLES&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables are like small storage values with predefined data types.&lt;/li&gt;
&lt;li&gt;We define these to store values, that can be used ahead in the code.&lt;/li&gt;
&lt;li&gt;We define variables :
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;There are 3 ways to define a variable -&amp;gt;
1. var &amp;lt;variable_name&amp;gt; = &amp;lt;value&amp;gt;
2. &amp;lt;variable_name&amp;gt; := &amp;lt;value&amp;gt;
3. var &amp;lt;variable_name&amp;gt; &amp;lt;data_type&amp;gt; OR var &amp;lt;variable_name&amp;gt; &amp;lt;data_type&amp;gt; = &amp;lt;value&amp;gt;

**Explanation**
1 -&amp;gt; When we use first way, goLang compiler automatically assigns a data type depending on the value given to it. So, First one requires value when we declare the variable else we will get compiler error as shown.

❌ var &amp;lt;variable_name&amp;gt;
✅ var &amp;lt;variable_name&amp;gt; = &amp;lt;value&amp;gt;

2 -&amp;gt; When we use second way, that also assigns data type automatically to the variable name and it also requires a value.

❌ &amp;lt;variable_name&amp;gt;
✅ &amp;lt;variable_name&amp;gt; := &amp;lt;value&amp;gt;

3 -&amp;gt; We use third way when we don't already know the value of variable. We can use it both with the value or without the value.

✅ var &amp;lt;variable_name&amp;gt; &amp;lt;data_type&amp;gt;
✅ var &amp;lt;variable_name&amp;gt; &amp;lt;data_type&amp;gt; = &amp;lt;value&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;💜When, Where to use what??&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We select between first and second way, when we need to define a const variable in the code. As by default goLang will take variables to be var.&lt;/li&gt;
&lt;li&gt;When using first and second way to declare the variable, goLang automatically assigns data type which would not be the required behaviour always.&lt;/li&gt;
&lt;li&gt;My personnel preference would be the third one as it works with the value or without as well as we can define a var or const and with proper data type.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;💜Examples&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. var numberOfTickets = 69 // We can define here const/var but not specific data type.
2. numberOfTickets := 69 // We can't define here const/var.
3. var numberOfTickets int = 69 // We can define here const/var with proper data type.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;💜Data types&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**int8**      8-bit signed(+/-) integer
**int16**  16-bit signed(+/-) integer
**int32**     32-bit signed(+/-) integer
**int64**     64-bit signed(+/-) integer
**uint8**     8-bit unsigned(+) integer
**uint16**    16-bit unsigned(+) integer
**uint32**    32-bit unsigned(+) integer
**uint64**    64-bit unsigned(+) integer
**float32**  32-bit IEEE 754 floating-point number
**float64**  64-bit IEEE 754 floating-point number
**int**       Both int and uint contain same size, either 32 or 64 bit.
**uint**          Both int and uint contain same size, either 32 or 64 bit.
**complex64**   Complex numbers which contain float32 as a real and imaginary component.
**complex128**  Complex numbers which contain float64 as a real and imaginary component.
**string** word/sentences
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Remember, by default goLang takes either int,float64,complex64 or string i.e. highest order data type depending on the value assigned. If we need to have specific data type, we need to define it specifically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💜Run your program&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Paste this code in and run your program using &lt;strong&gt;"go run ."&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;We will look into packages, fmt and many more in the next articles.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import "fmt"

func main() {

    //string
    var1 := "hello world"

    // integer
    var2 := 10
    var var6 uint = 10

    // float
    var3 := 1.55
    var var5 float32 = 1.55

    // boolean
    var4 := true

    fmt.Printf("var1 = %T\n", var1) //string
    fmt.Printf("var2 = %T\n", var2) //int
    fmt.Printf("var3 = %T\n", var3) //float64
    fmt.Printf("var4 = %T\n", var4) //boolean
    fmt.Printf("var5 = %T\n", var5) //float32
    fmt.Printf("var6 = %T\n", var6) //uint

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💜 That's it folks. 💜 &lt;/p&gt;

&lt;p&gt;Do follow to get notified about future articles about few advanced concepts of goLang like concurrency, context and many more. Next Article would be about structure, functions and packages in goLang. 💁‍♂️ till then HAPPY READING!!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Hello, I am Tanisk Annpurna
  I post about
  🚀web3, Blockchain, Ethereum
  🐦Smart Contract, Solidity
  🎉JavaScript, ReactJS, NodeJS and many more...
  Follow and like for more such posts. !!✌️!!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>DATA STRUCTURES IN SOLIDITY</title>
      <dc:creator>Tanisk Annpurna</dc:creator>
      <pubDate>Fri, 29 Jul 2022 13:23:19 +0000</pubDate>
      <link>https://dev.to/taniskannpurna/data-structures-in-solidity-4j85</link>
      <guid>https://dev.to/taniskannpurna/data-structures-in-solidity-4j85</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;You can read about basics of solidity like variables and different keywords, here 👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://taniskannpurna.hashnode.dev/solidity-101-part-2"&gt;Basic of Solidity (PART 2)&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Let's go&lt;/strong&gt;,
&lt;/h1&gt;

&lt;p&gt;💜 Data Structures are simply a structure in which we store the data, so that it allows certain method to be implemented. This saves time as well as in some cases memory.&lt;/p&gt;

&lt;p&gt;💜 Every Data Structures has their trade offs and proper use. So depending on the scenario, one data structure may work better than other.&lt;/p&gt;

&lt;p&gt;💜 &lt;strong&gt;ARRAYS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An array is a collection of items of same data type stored at contiguous memory locations.&lt;/li&gt;
&lt;li&gt;This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array). The base value is index 0 and the difference between the two indexes is the offset.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;FIXED ARRAYS&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;DATA TYPE&amp;gt; &amp;lt;ACCESS MODIFIER&amp;gt; &amp;lt;NAME&amp;gt;

uint[10] public balance; // This would create size of 10 indexes, If we try to store more it would fail.

address[200] private address_arr; // This would create size of 200 indexes, If we try to store more it would fail.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;STORING VALUES IN ARRAYS&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;balance[0] = 200; // Stores value at index 0. 
balance[1] = 203; // Stores value at index 1.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Remember, Arrays index starts from 0. So a 10 size array will have index from 0 to 9.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DYNAMIC ARRAYS&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;DATA TYPE&amp;gt; &amp;lt;ACCESS MODIFIER&amp;gt; &amp;lt;NAME&amp;gt;

uint[] public balance; // This would create a dynamic size array, will increase the size as per need.

address[] private address_arr; 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Remember, Its good practice to use dynamic array only when required. &lt;br&gt;
👉EVM implements some constraints to force developers to keep their code as much optimized as much possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ACCESSING VALUES IN ARRAYS&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;DATA TYPE&amp;gt; &amp;lt;ACCESS MODIFIER&amp;gt; &amp;lt;NAME&amp;gt;

uint[10] public balance; // This would create a dynamic size array, will increase the size as per need.

🍏 public_balance[8]; //This would give the value stored at 8th position in the array.
⛔ public_balance[10]; // This would give error as index are from 0 to 9;

address[] private address_arr; 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💜 &lt;strong&gt;MAPPING&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A mapping is like a dictionary, which has key and value pair.&lt;/li&gt;
&lt;li&gt;You simply provides the system the key, it returns the value paired with.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;MAPPING&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mapping(&amp;lt;DATA TYPE&amp;gt; =&amp;gt; &amp;lt;DATA TYPE&amp;gt;) &amp;lt;ACCESS MODIFIER&amp;gt; &amp;lt;NAME&amp;gt;

mapping(string=&amp;gt;uint256) public balance; // This would require a key of string and values of uint256

mapping(address=&amp;gt;uint256) public balance2; // This would require an address as key and values of uint256

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Remember, Keys will have to be unique else it will overwrite the value earlier stored corresponding to the key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STORING VALUES IN MAPPING&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;balance["abc"] = 26;
balance2[0x.....] = 92;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;ACCESSING&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;balance["abc"]; //This would give result as 26.
balance2[0x....]; // This would give result as 92.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💜 &lt;strong&gt;STRUCT&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Struct is used when we need to combine the use of different data variables. Like one variable stores uint, string, int etc.&lt;/li&gt;
&lt;li&gt;Its like a custom variable which one can create and use as per need. These can also store functions within themselves.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;STRUCT&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Struct &amp;lt;NAME&amp;gt;{ &amp;lt;DATA TYPE&amp;gt; &amp;lt;NAME&amp;gt; }

Struct People {
  uint256 number;
  String name;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;DEFINING IT&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;STRUCT NAME&amp;gt; &amp;lt;ACCESS MODIFIER&amp;gt; &amp;lt;NAME&amp;gt; = &amp;lt;STRUCT NAME&amp;gt; ({..provide details of variable as shown...acts as a constructor})
People public people1 = People ({number:5, name:"Tanisk"});
People public people2 = People ({number:92, name:"Sharma"});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;USING IT&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;NAME&amp;gt;.&amp;lt;VARIABLE IN STRUCT&amp;gt;
people1.name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 There are more Data Structure, but these are enough for writing smart contracts as they are used extensively.&lt;br&gt;
👉 There are few more but we can learn in future articles.&lt;/p&gt;

&lt;p&gt;That's all.&lt;/p&gt;

&lt;p&gt;In the next article, we will look into few nuances of EVM and how memory is handled in EVM.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hello, I am Tanisk Annpurna&lt;/p&gt;

&lt;p&gt;I post about&lt;/p&gt;

&lt;p&gt;🚀web3, Blockchain, Ethereum&lt;/p&gt;

&lt;p&gt;🐦Smart Contract, Solidity&lt;/p&gt;

&lt;p&gt;🎉JavaScript, ReactJS, NodeJS&lt;/p&gt;

&lt;p&gt;Follow and like for more such posts. !!✌️!!&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>blockchain</category>
      <category>ethereum</category>
      <category>smartcontract</category>
      <category>web3</category>
    </item>
    <item>
      <title>SOLIDITY-101 (PART 2)</title>
      <dc:creator>Tanisk Annpurna</dc:creator>
      <pubDate>Fri, 22 Jul 2022 07:26:00 +0000</pubDate>
      <link>https://dev.to/taniskannpurna/solidity-101-part-2-3aeo</link>
      <guid>https://dev.to/taniskannpurna/solidity-101-part-2-3aeo</guid>
      <description>&lt;p&gt;You can read about basics of solidity in my last article here 👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/taniskannpurna/solidity-101-part-1-2md8"&gt;Solidity-101 (part1)&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Start
&lt;/h2&gt;

&lt;p&gt;💜 &lt;strong&gt;VARIABLES&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We have different type of values to store in program like it can be an Integer, String, Characters, boolean etc.&lt;/li&gt;
&lt;li&gt;There are variables for integer or unsigned Integer, we can add power of 2 after variables  data type and it will restrict it to certain value.&lt;/li&gt;
&lt;li&gt;Variables in solidity are  : &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Integers&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Numbers can be negative as well as positive but not decimals
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int -&amp;gt; This is to tell solidity that we will store integer in this variable.
int8 -&amp;gt; This will store values from -2^8-1 to  2^8-1 i.e. -255 to 255.
int16 -&amp;gt; This will store values from -2^16-1 to  2^16-1 i.e. -65536 to 65536.
.
.
.
int256 -&amp;gt; This is the maximum integer value solidity store i.e. -2^256-1 to 2^256-1.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Remember, writing just int or int256 is same. By default int is taken as int256.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Unsigned Integers&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;For Numbers that will be only positive but not negative or decimals
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uint -&amp;gt; This is to tell solidity that we will store unsigned integer in this variable.
uint8 -&amp;gt; This will store values from 0 to  2^8-1 i.e. 0 to 255.
uint16 -&amp;gt; This will store values from 0 to  2^16-1 i.e. 0 to 65536.
.
.
.
uint256 -&amp;gt; This is the maximum integer value solidity store i.e. 0 to 2^256-1.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Remember, writing just uint or uint256 is same. By default int is taken as uint256.&lt;/p&gt;

&lt;p&gt;👉 This is only limited to integer and unsigned Integer.&lt;/p&gt;

&lt;p&gt;💜 &lt;strong&gt;DEFINING A VARIABLE&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We define variable in solidity as this pattern.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;DATA_TYPE&amp;gt; &amp;lt;ACCESS IDENTIFIER&amp;gt; &amp;lt;VARIABLE NAME&amp;gt;

int8 private fav_num = -8;
uint16 public fav_num = 8;
bool internal is_fav_num = true;
string external word = "Hello";
address private contractAddress = 0x70997970C.......;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💜 &lt;strong&gt;SPECIAL ACCESS IDENTIFIER FOR FUNCTIONS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;These access identifier is just to tell EVM how the function will interact with the storage.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PURE -&amp;gt; This means that it will not even access the storage.

VIEW-&amp;gt; This means that it will only access the storage but wont change anything.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💜 &lt;strong&gt;EXAMPLE&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;address private i_owner;
uint256 public minimumUsd;

function getOwner() public view returns (address) {
        return i_owner;
}

function getAddressToAmountFunded(address funder) public view returns (uint256) {
        return s_addressToAmountFunded[funder];
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💜 Summary&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This is done because we want to eliminate unwanted storage usage.&lt;/li&gt;
&lt;li&gt;So, if we know that values will be small then we can use uint8, uint16...etc.&lt;/li&gt;
&lt;li&gt;This is done to keep our gas prices in control.&lt;/li&gt;
&lt;li&gt;Depending on different task, EVM requires amount of gas to be paid. So to keep it in control we use these.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Remember using PURE or VIEW -&amp;gt; SPECIAL ACCESS IDENTIFIER, its because these denotes that they tells EVM that they have very limited functionality and gas charge will be taken as per.&lt;/p&gt;

&lt;p&gt;That's all.&lt;/p&gt;

&lt;p&gt;In the next article, we will look into different Storage, Data Structures that we basically use in writing SMART CONTRACT. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hello, I am Tanisk Annpurna&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I post about

🚀web3, Blockchain, Ethereum

🐦Smart Contract, Solidity

🎉JavaScript, ReactJS, NodeJS

Follow and like for more such posts. !!✌️!!
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

</description>
    </item>
    <item>
      <title>SOLIDITY - 101 (PART 1)</title>
      <dc:creator>Tanisk Annpurna</dc:creator>
      <pubDate>Sun, 17 Jul 2022 22:13:27 +0000</pubDate>
      <link>https://dev.to/taniskannpurna/solidity-101-part-1-2md8</link>
      <guid>https://dev.to/taniskannpurna/solidity-101-part-1-2md8</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;You can read my last article about COMPILING SMART CONTRACT, here 👇&lt;br&gt;
&lt;a href="https://dev.to/taniskannpurna/compiling-the-smart-contracts-3a9p"&gt;Colmpiling Smart Contract&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Let's Start
&lt;/h2&gt;

&lt;p&gt;💜 &lt;strong&gt;VARIABLES&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables are data items that is defined to store different values for the runtime of the program.&lt;/li&gt;
&lt;li&gt;We have different type of values to store in program like it can be an Integer, String, Characters, boolean etc.&lt;/li&gt;
&lt;li&gt;Variables in solidity are  : &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Integers&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Numbers can be negative as well as positive but not decimals
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int -&amp;gt; This is to tell solidity that we will store integer in this variable.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Unsigned Integers&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Numbers can only positive but not negative or decimals
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uint -&amp;gt; This is to tell solidity that we will store only positive integer in this variable.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Boolean&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;True or False
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bool -&amp;gt; This is to tell solidity that we will store true or false in this variable.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;String&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A combination characters. It can be a word, sentence etc.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string-&amp;gt; This is to tell solidity that we will store combination of characters in this variable.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Address&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Its a special type of data that is used in smart contract. As EVM has an hexadecimal unique value for every accounts or smart contract. We call them address as EVM will interact with the account/contract using the address.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;address-&amp;gt; This is to tell solidity that we will store Address in this variable.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💜 &lt;strong&gt;ACCESS IDENTIFIER&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access Identifier means that we can decide who can access the variables/function or anything in the smart contract.&lt;/li&gt;
&lt;li&gt;For Security purposes, We need to restrict the access. We do this using access Identifier.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PUBLIC -&amp;gt; This means that it can be accessed from anywhere, anyone can access it. No Restrictions.

PRIVATE -&amp;gt; This means that it can only be accessed from the contract in which its present. No contract/account from outside the contract can access it. Although they can see it but can not be accessed.

INTERNAL -&amp;gt; This means that no outside contract/accounts can access it. It can be accessed from within and contract's children i.e. Contracts inherited from this contract can access it. This is the default identifier i.e. If no access identifier is provided, EVM assumes this access identifier.

EXTERNAL -&amp;gt; This means that only external contracts/accounts can access it. if we need to use it internally then we have to use "this" keyword.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💜 &lt;strong&gt;DEFINING A VARIABLE&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We define variable in solidity as this pattern.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;DATA_TYPE&amp;gt; &amp;lt;ACCESS IDENTIFIER&amp;gt; &amp;lt;VARIABLE NAME&amp;gt;

int private fav_num = -8;
uint public fav_num = 8;
bool internal is_fav_num = true;
string external word = "Hello";
address private contractAddress = 0x70997970C.......;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Remember, We can also omit the access identifier and EVM by default will take internal as access identifier.&lt;br&gt;
👉 Remember, Always try to use Variable Name as self-explanatory.&lt;br&gt;
👉 Remember, We use " " for defining strings and ; to end any syntax.&lt;/p&gt;

&lt;p&gt;💜 &lt;strong&gt;SPECIAL ACCESS IDENTIFIER FOR FUNCTIONS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;These access identifier is just to tell EVM how the function will interact with the storage.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PURE -&amp;gt; This means that it will not even access the storage.

VIEW-&amp;gt; This means that it will only access the storage but wont change anything.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;💜 &lt;strong&gt;DEFINING FUNCTIONS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We define function in solidity as this pattern.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function &amp;lt;FUNCTION_NAME&amp;gt; &amp;lt;ACCESS IDENTIFIER&amp;gt; &amp;lt;SPECIAL ACCESS IDENTIFIER(OPTIONAL)&amp;gt; returns(&amp;lt;DATA_TYPE&amp;gt;){}

function func_name public pure returns(uint){}
function func_name2 private view returns(string){}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;👉 Remember, We can also omit the special access identifier.&lt;br&gt;
👉 Remember, Always try to use Function Name as self-explanatory.&lt;/p&gt;

&lt;p&gt;💜 &lt;strong&gt;EXAMPLE&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;address private i_owner;
uint256 public minimumUsd;

function getOwner() public view returns (address) {
        return i_owner;
}

function getAddressToAmountFunded(address funder) public view returns (uint256) {
        return s_addressToAmountFunded[funder];
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all.&lt;/p&gt;

&lt;p&gt;In the next article, we will look why we need special access identifiers, how we can add on these variables and use it more space effeciently.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hello, I am Tanisk Annpurna&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I post about

🚀web3, Blockchain, Ethereum

🐦Smart Contract, Solidity

🎉JavaScript, ReactJS, NodeJS

Follow and like for more such posts. !!✌️!!
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

</description>
      <category>blockchain</category>
      <category>web3</category>
      <category>smartcontract</category>
      <category>beginners</category>
    </item>
    <item>
      <title>COMPILING THE SMART CONTRACTS</title>
      <dc:creator>Tanisk Annpurna</dc:creator>
      <pubDate>Tue, 12 Jul 2022 16:46:40 +0000</pubDate>
      <link>https://dev.to/taniskannpurna/compiling-the-smart-contracts-3a9p</link>
      <guid>https://dev.to/taniskannpurna/compiling-the-smart-contracts-3a9p</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;You can read more about ABI and BYTECODE here 👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/taniskannpurna/understanding-smart-contract-bytecode-abi-268l"&gt;'understanding-smart-contract-bytecode-and-abi'&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  LETS START.....
&lt;/h1&gt;

&lt;p&gt;💜 &lt;strong&gt;Recap&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; In the previous article we learnt that EVM requires ABI and BYTECODE to understand any smart contract.&lt;/li&gt;
&lt;li&gt; ABI gives the power to interact with Smart Contract using JavaScript&lt;/li&gt;
&lt;li&gt; BYTECODE gives commands for EVM on how to execute the Smart Contract.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;if you want to understand in more depth, Please read my last article.&lt;/p&gt;

&lt;p&gt;💜 &lt;strong&gt;Converting to ABI and BYTECODE&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; There are many framework through which we can convert Smart Contract into ABI and BYTECODE. Among them we will look into few of them.&lt;/li&gt;
&lt;li&gt; Before that we will need smart contract to convert. So, Copy the below code into VS code or any IDE as per your preference and follow along.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  SMART CONTRACT
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt; Create a file named "SimpleSmartContract.sol".&lt;/li&gt;
&lt;li&gt; .sol is an extension used for solidity files.&lt;/li&gt;
&lt;li&gt; This Smart Contract is very simple, It updates a number, gets the number and multiply it with a number.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

contract SimpleSmartContract {
    uint256 public number;

    function getNumber() public view returns (uint256) {
        return number;
    }

    function updateNumber(uint128 _newNumber) public {
        number = _newNumber;
    }

    function multiplyNumber(uint8 _multiple) public {
        number = number * _multiple;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Remember, There are many extensions for Solidity in VS code. You can use anyone for proper intellisense and linting. Just search &lt;strong&gt;solidity&lt;/strong&gt; in extension marketplace.&lt;/p&gt;

&lt;p&gt;💜 &lt;strong&gt;SOLCJS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Its a framework written in typescript and can provide ABI and BYTECODE with single command.&lt;/li&gt;
&lt;li&gt; we have to install it using &lt;strong&gt;npm or yarn&lt;/strong&gt; and for npm we need &lt;a href="https://nodejs.org"&gt;'Node.js'&lt;/a&gt;. So first install Node.js if not installed.&lt;/li&gt;
&lt;li&gt; Open any terminal and change the directory to the location where smart contract is stored.&lt;/li&gt;
&lt;li&gt; Using &lt;strong&gt;NPM&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install solc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt; or We can also use &lt;strong&gt;YARN&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add solc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt; To check if solc is installed , write
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;solcjs --help
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if no error, then solc is installed else we need to install it again. Check location of terminal pointing to.&lt;/p&gt;

&lt;p&gt;To compile , we use this command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;solcjs --bin --abi --include-path node_modules/ --base-path . SimpleSmartContract.sol
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 SimpleSmartContract.sol is the name of the smart contract. Replace it with the name of your own smart contract.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;--bin&lt;/strong&gt; and &lt;strong&gt;--abi&lt;/strong&gt; tells the solcjs to create .bin as well as .abi file. If you need anyone then simply remove the other one from the command.&lt;/p&gt;

&lt;p&gt;💜 BYTECODE&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;608060405234801561001057600080fd5b506102dd806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063297c8d7a1461005157806347a9ee3f1461006d5780638381f58a14610089578063f2c9ecd8146100a7575b600080fd5b61006b60048036038101906100669190610161565b6100c5565b005b61008760048036038101906100829190610134565b6100df565b005b6100916100fb565b60405161009e919061019d565b60405180910390f35b6100af610101565b6040516100bc919061019d565b60405180910390f35b8060ff166000546100d691906101b8565b60008190555050565b806fffffffffffffffffffffffffffffffff1660008190555050565b60005481565b60008054905090565b60008135905061011981610279565b92915050565b60008135905061012e81610290565b92915050565b60006020828403121561014a57610149610274565b5b60006101588482850161010a565b91505092915050565b60006020828403121561017757610176610274565b5b60006101858482850161011f565b91505092915050565b6101978161022e565b82525050565b60006020820190506101b2600083018461018e565b92915050565b60006101c38261022e565b91506101ce8361022e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561020757610206610245565b5b828202905092915050565b60006fffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600080fd5b61028281610212565b811461028d57600080fd5b50565b61029981610238565b81146102a457600080fd5b5056fea26469706673582212206ce7a9ae1c7536d9fe3d885a363d9f98f3dc8defb9d937459835ecac88104ca664736f6c63430008070033
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💜 ABI&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[{"inputs":[],"name":"getNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"_multiple","type":"uint8"}],"name":"multiplyNumber","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"number","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"_newNumber","type":"uint128"}],"name":"updateNumber","outputs":[],"stateMutability":"nonpayable","type":"function"}]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Remember if you want to read ABI, just change the extension from .abi to .json, The file will update and then change it back to .abi again.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; You can read more about solcjs here 👉 &lt;a href="https://github.com/ethereum/solc-js"&gt;'solcJs'&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💜 &lt;strong&gt;REMIX IDE&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Remix IDE allows developing, deploying and administering smart contracts for Ethereum like blockchains.&lt;/li&gt;
&lt;li&gt; You can visit it here 👉&lt;a href="https://remix.ethereum.org"&gt;REMIX IDE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; Create a new file and name it "SimpleSmartContract.sol" and paste the smart contract as shown.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CY9YdnLr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://project-assets.showwcase.com/17216/1657640437053-Screenshot%2525202022-07-12%252520211011.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CY9YdnLr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://project-assets.showwcase.com/17216/1657640437053-Screenshot%2525202022-07-12%252520211011.png" alt="Screenshot 2022-07-12 211011.png" width="800" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉 Make sure that compiler version is set to ^0.8.7. You can set it by clicking on Solidity Compiler button at most left panel. Select Compiler from dropdown as 0.8.7+commit.. In the Smart Contract we have defined compiler version, Its best to pick the same compiler version as in Smart Contract. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jekvhrkn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://project-assets.showwcase.com/17216/1657640949204-Screenshot%2525202022-07-12%252520211011.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jekvhrkn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://project-assets.showwcase.com/17216/1657640949204-Screenshot%2525202022-07-12%252520211011.png" alt="Screenshot 2022-07-12 211011.png" width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; After pasting the code, we can hit compile button and check if any errors. If any error Please check that compiler version is correct.&lt;/li&gt;
&lt;li&gt; Below that Solidity Compiler, We have Deploy &amp;amp; Run Transaction. Select it. Keep the option as it is.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CJevVGLU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://project-assets.showwcase.com/17216/1657641234914-Screenshot%2525202022-07-12%252520211011.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CJevVGLU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://project-assets.showwcase.com/17216/1657641234914-Screenshot%2525202022-07-12%252520211011.png" alt="Screenshot 2022-07-12 211011.png" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; We hit Deploy button.&lt;/li&gt;
&lt;li&gt; We can see our smart contract deploy as shown below.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ti0dQMgA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://project-assets.showwcase.com/17216/1657642030847-Screenshot%2525202022-07-12%252520211011.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ti0dQMgA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://project-assets.showwcase.com/17216/1657642030847-Screenshot%2525202022-07-12%252520211011.png" alt="Screenshot 2022-07-12 211011.png" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Now In the Compiler tab, we can see ABI &amp;amp; BYTECODE button. From there one can copy the ABI/BYTECODE and have a look at it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zZbwKz6F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://project-assets.showwcase.com/17216/1657642153313-Screenshot%2525202022-07-12%252520213845.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zZbwKz6F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://project-assets.showwcase.com/17216/1657642153313-Screenshot%2525202022-07-12%252520213845.png" alt="Screenshot 2022-07-12 213845.png" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These are the ways one can convert the Smart Contract to ABI and BYTECODE.&lt;/p&gt;

&lt;p&gt;👉 Remember the BYTECODE and ABI will be same for same Smart Contract. It will never be different irrespective of the method of conversion. It will only change if Smart Contract changes.&lt;/p&gt;

&lt;p&gt;In the next article, we will see basics of solidity and how to write smart contract and deploy it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, I am Tanisk Annpurna

I post about

🚀web3, Blockchain, Ethereum

🐦Smart Contract, Solidity

🎉JavaScript, ReactJS, NodeJS

Follow and like for more such posts. !!✌️!!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>ethereum</category>
      <category>smartcontract</category>
    </item>
    <item>
      <title>Understanding SMART CONTRACT - BYTECODE &amp; ABI</title>
      <dc:creator>Tanisk Annpurna</dc:creator>
      <pubDate>Sat, 09 Jul 2022 09:24:05 +0000</pubDate>
      <link>https://dev.to/taniskannpurna/understanding-smart-contract-bytecode-abi-268l</link>
      <guid>https://dev.to/taniskannpurna/understanding-smart-contract-bytecode-abi-268l</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;In the last article, we saw how smart contracts are better than paper contracts. Read it here 👉&lt;br&gt;
&lt;a href="https://taniskannpurna.hashnode.dev/introduction-to-smart-contracts"&gt;Intro to Smart Contracts&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Lets Start....&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have seen how smart contracts are better than the old paper contracts, and how EVM makes sure that smart contracts keeps their promises.&lt;/p&gt;

&lt;p&gt;Now, EVM doesn't understand any high level language. It understands low level language. So, we need to convert our smart contract into low level language i.e. BYTECODE. &lt;/p&gt;

&lt;p&gt;💜 &lt;strong&gt;BYTECODE&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bytecode is a low level language consisting combination of numbers and alphabets.&lt;/li&gt;
&lt;li&gt;Bytecodes are very hard to write as well as read. Basically its not human readable.&lt;/li&gt;
&lt;li&gt;Using different frameworks like solcjs,ethers, hardhat and many  more, we can convert our smart contracts into bytecodes.&lt;/li&gt;
&lt;li&gt;This is how a bytecode looks for a very small and simple smart contract.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;608060405234801561001057600080fd5b50610771806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632e64cec11461005c5780636057361d1461007a5780636f760f41146100965780639e7a13ad146100b2578063b2ac62ef146100e3575b600080fd5b610064610113565b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;We can see them as a combinations of numbers and alphabets.&lt;/li&gt;
&lt;li&gt;EVM is a stack machine, meaning it uses stack to run any script. It stores functions, would PUSH function, would POP them and many more.&lt;/li&gt;
&lt;li&gt;Bytecode may look gibberish but they are commands for EVM on how to interact with stack.&lt;/li&gt;
&lt;li&gt;If we convert these bytecodes into OPCODE i.e. operation code, we will see how or what commands these combinations are giving to EVM. &lt;/li&gt;
&lt;li&gt;There are many websites that can convert bytecode -&amp;gt; opcode. I am using etherscan.
👉&lt;a href="https://dev.toLink"&gt;https://etherscan.io/opcode-tool&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is what we get....&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    [0] DUP1
    [2] PUSH1 0x40
    [3] MSTORE
    [4] CALLVALUE
    [5] DUP1
    [6] ISZERO
    [9] PUSH2 0x0010
    [10] JUMPI
    [12] PUSH1 0x00
    [13] DUP1
    [14] REVERT
    [15] JUMPDEST
    [16] POP
    [19] PUSH2 0x0771
    [20] DUP1
    [23] PUSH2 0x0020
    [25] PUSH1 0x00
    [26] CODECOPY
    [28] PUSH1 0x00
    [29] RETURN

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;👉 Remember EVM treats every number as a hexadecimal number. "0x" means that the number is a hexadecimal number. Now in-case of EVM, it doesn't need any "0x" as it treats every number as hexadecimal. So "0x40" in EVM we can put it as just "40".&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now these are different commands that helps EVM. Here is what they mean&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;PUSH1 0x40 -&amp;gt; This means to put 1 byte value of "0x40" in the stack. Now the hexadecimal value of PUSH1 is "60". So the commands become "6040".&lt;/li&gt;
&lt;li&gt;MSTORE -&amp;gt; This will allocate memory of 0x60 and will move 0x40 in there. The hexadecimal code for MSTORE is "0x52".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So the final bytecode for these becomes...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;604052

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this way every bytecode has their meaning and tells EVM what to do. We don't require to know about what every bytecode means for writing a smart contract. Just knowing what it does is good. But if you want to learn more, Here is a link that will help a lot &lt;a href="https://www.ethervm.io/"&gt;Ethervm.io&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now, In the last article we saw ABI. Well, Smart contracts are only good when someone can use it. So here helps ABI.&lt;/p&gt;

&lt;p&gt;💜 &lt;strong&gt;ABI&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ABI stands for Application Binary Interface.&lt;/li&gt;
&lt;li&gt;ABI's are not as complicated as BYTECODE and are human readable.&lt;/li&gt;
&lt;li&gt;ABI looks like these :
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  {
    "inputs": [
      {
        "internalType": "string",
        "name": "_name",
        "type": "string"
      },
      {
        "internalType": "uint256",
        "name": "_favouriteNumber",
        "type": "uint256"
      }
    ],
    "name": "addPerson",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  }
]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;As we can look these are just JSON format files with extension of .abi&lt;/li&gt;
&lt;li&gt;If we look closely these abi contains like type:'function' or "uint256" or "string".&lt;/li&gt;
&lt;li&gt;These files contains all the details about the smart contracts like variables , their type , their name as well as name of functions, access modifiers, they are payable or non-payable and many more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ex-&amp;gt; when type is "uint256" or "string" that means its  a variable but when its "function" that means its a function.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Its used when JavaScript wants to interact with smart contract, that is where abi comes in. without abi there will not be any interactions and you can't call any functions or do anything with it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💜** Let's summarise....**&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smart contract requires bytecode and abi to run.&lt;/li&gt;
&lt;li&gt;Bytecode is non human readable and it tells EVM on how to execute the smart contract.&lt;/li&gt;
&lt;li&gt;Bytecode can be converted OpCode which is human readable.&lt;/li&gt;
&lt;li&gt;Every number in bytecode means a command in EVM. EVM assumes every number as hexadecimal.&lt;/li&gt;
&lt;li&gt;ABI is a JSON file with extension of .abi. It contains details about variables, access modifiers, function, their return types and many more.&lt;/li&gt;
&lt;li&gt;ABI makes it possible for JavaScript to call the functions in smart contract.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉Remember if you can write correct BYTECODE and ABI, you can simply deploy that on the chain.&lt;/p&gt;

&lt;p&gt;In the next article, we will see in how we can convert our smart contract to bytecode and ABI. We will also get basics of solidity and how to write smart contract and deploy.&lt;/p&gt;

&lt;blockquote&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, I am Tanisk Annpurna

I post about

🚀web3, Blockchain, Ethereum

🐦Smart Contract, Solidity

🎉JavaScript, ReactJS, NodeJS

Follow and like for more such posts. !!✌️!!
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

</description>
      <category>blockchain</category>
      <category>smartcontract</category>
      <category>ethereum</category>
      <category>web3</category>
    </item>
    <item>
      <title>Introduction to SMART CONTRACTS</title>
      <dc:creator>Tanisk Annpurna</dc:creator>
      <pubDate>Thu, 07 Jul 2022 21:05:44 +0000</pubDate>
      <link>https://dev.to/taniskannpurna/introduction-to-smart-contracts-n6c</link>
      <guid>https://dev.to/taniskannpurna/introduction-to-smart-contracts-n6c</guid>
      <description>&lt;p&gt;&lt;em&gt;You can read my last article on "WHY ETHEREUM" here 👇&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://dev.to/taniskannpurna/limitations-of-blockchain-solved-by-ethereum-3hei"&gt;https://dev.to/taniskannpurna/limitations-of-blockchain-solved-by-ethereum-3hei&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's start….&lt;/p&gt;

&lt;p&gt;💜 REAL WORLD CONTRACTS&lt;br&gt;
Paper Contracts are already present in the world. So why we need the SMART CONTRACTS, well there is a issue with our current contract&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Paper contracts are basically backed by Government. One relies that if the contracts agreement are not fulfilled then they can complain to government.&lt;/li&gt;
&lt;li&gt;But What happens if the government doesn't support. What one can do if suddenly government changes something and your contract gets null.&lt;/li&gt;
&lt;li&gt;No one can do anything now.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So what is the solution then ?....&lt;/p&gt;

&lt;p&gt;💜 SMART CONTRACTS&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smart Contract is an electronic contract written in solidity and then deployed to EVM(Ethereum Virtual Machine).&lt;/li&gt;
&lt;li&gt;Smart Contract is like a promise that can not be broken.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💜 HOW IT WORKS&lt;br&gt;
We have already seen how blockchain and Ethereum works.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Just like bank accounts we have accounts on Ethereum.&lt;/li&gt;
&lt;li&gt;Now We have account number in banks which is unique. Similarly, we have account address that is unique.&lt;/li&gt;
&lt;li&gt;We have balances in bank accounts. Similarly, we have balances in accounts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, Ethereum handles smart contract similarly...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When we deploy a smart contract to Ethereum, It is also treated as an account on the chain.&lt;/li&gt;
&lt;li&gt;Ethereum provides the smart contract its unique address, its own balance and ability for other accounts to use deployed smart contracts.&lt;/li&gt;
&lt;li&gt;These smart contracts lives on the chain and as soon as certain condition is met, it executes proper function for that.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we can see, How any external authority or anyone can change or make the contract null.&lt;/p&gt;

&lt;p&gt;👉 Remember, Smart Contracts once deployed on the chain can not be altered/Changed because Chain makes it too hard for the change. We can block it / give the access but we cannot alter it.&lt;/p&gt;

&lt;p&gt;💜 APPLICATIONS OF SMART CONTRACTS&lt;br&gt;
It can be used to create these ...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DeFi -&amp;gt; Decentralized Finance&lt;/li&gt;
&lt;li&gt;DAOs -&amp;gt; Decentralized Autonomous Organization&lt;/li&gt;
&lt;li&gt;NFTs -&amp;gt; Non-fungible tokens&lt;/li&gt;
&lt;li&gt;Dapps -&amp;gt; Decentralized Apps&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💜 HOW EVM HANDLES SMART CONTRACT&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smart contracts are written in solidity, a programming language heavily inspired by JavaScript.&lt;/li&gt;
&lt;li&gt;But EVM does not understand solidity or any high level languages. It understand BYTECODE i.e. a low level language.&lt;/li&gt;
&lt;li&gt;Now writing  BYTECODE is not human readable, So we convert our SOLIDITY -&amp;gt; BYTECODE and then send to EVM.&lt;/li&gt;
&lt;li&gt;But we also require ABI(Application Binary Interface). This helps our JavaScript code to interact with EVM BYTECODE.&lt;/li&gt;
&lt;li&gt;Now we can use many packages to convert our smart contract into ABI and BYTECODE. Few of them are "solcjs","ethers","hardhat" and many more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the way EVM handles smart contract. In the next article we will see in more details about ABI, BYTECODE and how we can convert our smart contract to these.&lt;br&gt;
We will also get basics of solidity and how to write smart contract and many more..&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hello, I am Tanisk Annpurna&lt;/p&gt;

&lt;p&gt;I post about&lt;/p&gt;

&lt;p&gt;🚀web3, Blockchain, Ethereum&lt;/p&gt;

&lt;p&gt;🐦Smart Contract, Solidity&lt;/p&gt;

&lt;p&gt;🎉JavaScript, ReactJS, NodeJS&lt;/p&gt;

&lt;p&gt;Follow and like for more such posts.&lt;br&gt;
!!✌️!!&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>smartcontracts</category>
      <category>blockchain</category>
      <category>ethereum</category>
      <category>web3</category>
    </item>
    <item>
      <title>Limitations of Blockchain solved by Ethereum...</title>
      <dc:creator>Tanisk Annpurna</dc:creator>
      <pubDate>Mon, 04 Jul 2022 21:31:58 +0000</pubDate>
      <link>https://dev.to/taniskannpurna/limitations-of-blockchain-solved-by-ethereum-3hei</link>
      <guid>https://dev.to/taniskannpurna/limitations-of-blockchain-solved-by-ethereum-3hei</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;You can read my last article on &lt;strong&gt;How transactions are made in blockchain..&lt;/strong&gt; here👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://taniskannpurna.hashnode.dev/how-transactions-goes-on-blockchain"&gt;https://taniskannpurna.hashnode.dev/how-transactions-goes-on-blockchain&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;New technology always tries to solve the limitations of previous technology. &lt;/p&gt;

&lt;p&gt;So to understand the need of Ethereum, we need to study the limitations of blockchain and how Ethereum solves it.&lt;/p&gt;

&lt;p&gt;💜 Just to recap, Lets first see the features of blockchain...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blockchain was created as an alternative of paper currency as an online currency i.e. bitcoin(BTC).&lt;/li&gt;
&lt;li&gt;The best feature that it provides is the DECENTRALIZED system i.e. not run or owned by single authority of any kind.&lt;/li&gt;
&lt;li&gt;It provides the most secure system that is almost impenetrable.&lt;/li&gt;
&lt;li&gt;It hashes all the data using sha256, that means if anyone changes any data then hash will change and once hash changes the NONCE(Read it in my last post) will change making the block wrong and other nodes will simply reject it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In summary, Blockchain is a very secure decentralized system that acts as a public ledger using online currency i.e. Bitcoin. &lt;/p&gt;

&lt;p&gt;💜 There is no as such proper limitation of blockchain. It is best on what it is meant to do, but it also does not provides a growth opportunity in its system. What I mean here is it was created as a public ledger in 2009 and today in 2022, its still working as a public ledger and nothing more.&lt;/p&gt;

&lt;p&gt;💜 So, Using the blockchain's idea of decentralized system, its security. Can we make a system that can do more rather than just being a public ledger.&lt;/p&gt;

&lt;p&gt;💜 &lt;strong&gt;The Rise of Ethereum&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ethereum also works as a public ledger just like Blockchain.&lt;/li&gt;
&lt;li&gt;Instead of bitcoin(BTC) as online currency, It uses ether(ETH).&lt;/li&gt;
&lt;li&gt;It is also a decentralized system which is very secured just like bitcoin.&lt;/li&gt;
&lt;li&gt;It also hashes the data but instead of sha256, It uses &lt;strong&gt;keccak256&lt;/strong&gt; algorithm for hashing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With these features, The biggest feature that it provides which differentiates it from blockchain is to write &lt;strong&gt;SMART CONTRACTS&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;💜 &lt;strong&gt;SMART CONTRACTS&lt;/strong&gt;&lt;br&gt;
In real world, we have contracts meaning a sheet of paper authorized by government which sets some rules and requirements between two parties to achieve any kind of result.&lt;/p&gt;

&lt;p&gt;Similarly Smart Contract is an electronic piece of code that sets some rules between any two parties. It can be another user, the system, time anyone.&lt;/p&gt;

&lt;p&gt;💜 &lt;strong&gt;Facts(no 🧢) about smart contracts&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smart contracts are written in solidity. Its a programming language inspired from JavaScript.&lt;/li&gt;
&lt;li&gt;These smart contracts are deployed on EVM i.e. Ethereum Virtual Machine.&lt;/li&gt;
&lt;li&gt;Once deployed, Its very very hard to change the smart contract. Its easier to write a new one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💜 Why we need the SMART CONTRACT ?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The real world contract works only in real world. The real world is a centralized system i.e. There is single unit of power or authority that controls it.&lt;/li&gt;
&lt;li&gt;Now, These single unit of power or authority may flip a switch and the real world contract will be nullified.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Smart Contract solves this, Once the smart contract is in the network i.e. deployed then no-one can alter it. We can block the access but none can alter it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Its a decentralized and transparent contract that will always work. It keeps the trust.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Smart contract is just like a pinky promise i.e. UNBREAKABLE PROMISE that will always follow the rule of its contract and no-one can change it.&lt;/p&gt;

&lt;p&gt;We will look into Ethereum and Smart Contract in more details in upcoming articles. So 👇👇👇&lt;/p&gt;

&lt;blockquote&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, I am Tanisk Annpurna

I post about
🚀web3, Blockchain, Ethereum
🐦Smart Contract, Solidity
🎉JavaScript, ReactJS, NodeJS

Follow and like for more such posts.
!!✌️!!
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

</description>
      <category>blockchain</category>
      <category>ethereum</category>
      <category>bitcoin</category>
      <category>smartcontrac</category>
    </item>
  </channel>
</rss>
