<?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: CodeHadIt</title>
    <description>The latest articles on DEV Community by CodeHadIt (@codehadit).</description>
    <link>https://dev.to/codehadit</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%2F1021130%2F3057b18e-d93a-4dfb-91a4-0409c73ea90a.jpg</url>
      <title>DEV Community: CodeHadIt</title>
      <link>https://dev.to/codehadit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codehadit"/>
    <language>en</language>
    <item>
      <title>What Are License Identifiers In Solidity and why we need them</title>
      <dc:creator>CodeHadIt</dc:creator>
      <pubDate>Tue, 14 Feb 2023 16:44:56 +0000</pubDate>
      <link>https://dev.to/codehadit/what-are-license-identifiers-in-solidity-and-why-we-need-them-1il3</link>
      <guid>https://dev.to/codehadit/what-are-license-identifiers-in-solidity-and-why-we-need-them-1il3</guid>
      <description>&lt;p&gt;If you’re anything like me, then the first time you wrote a solidity smart contract, you thought to yourself; why do smart contracts start with a license identifier? What does the SPDX license identifier mean and why do we reference the Massachusetts Institute of Technology(MIT)?&lt;/p&gt;

&lt;p&gt;In my smart contract journey thus far, I have found that many solidity developers fail to have answers to the above questions. They simply copy-paste it onto their codes as a necessity without understanding why it's needed in the first place.&lt;/p&gt;

&lt;p&gt;If you're guilty of such(I was too at some point), then come along with me on this piece as I thoroughly discuss what license identifiers are in software, why they’re important in smart contracts, and how you can possibly do without them in your solidity codes.&lt;/p&gt;

&lt;p&gt;Our daily lives revolve around software, they power the digital age we currently find ourselves. For most software, before we enjoy their benefits, we first have to agree to some terms and conditions regarding their usage.&lt;/p&gt;

&lt;p&gt;The conditions precedent for the usage of a software is often contained in a file. This file sets the terms for the use of the software. It contains some of the following;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The extent to which the end-user enjoys the software.&lt;/li&gt;
&lt;li&gt;Limitations to the use of the software.&lt;/li&gt;
&lt;li&gt;Certain liabilities on the End user.&lt;/li&gt;
&lt;li&gt;The intellectual property right of the software creator.&lt;/li&gt;
&lt;li&gt;Some limitations of the creator’s liability.&lt;/li&gt;
&lt;li&gt;Plus a bunch of other legal terms and clauses, primarily to protect the IP right of the creator.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This file is what is called a software license. A software license spells out the rules guiding the use of the product.&lt;/p&gt;

&lt;p&gt;Before users can enjoy a software, they first enter into an End-User License Agreement or EULA. The EULA is a contract between the software creator (licensor) and the end user (licensee) establishing the right of the latter to use the software. &lt;/p&gt;

&lt;p&gt;Every day, you enter into a EULA without even knowing it. When you run a software for the very first time(not always the case) or click on an “accept terms and conditions” popup on your favourite website, you’re entering into a EULA. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why are Sofware Licenses Important?
&lt;/h2&gt;

&lt;p&gt;Software licenses are important for a variety of reasons to both the creator and end users. Some of these reasons are;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For creators, it protects their intellectual property rights.&lt;/li&gt;
&lt;li&gt;It also serves to limit their liabilities arising from the use of the products.&lt;/li&gt;
&lt;li&gt;For users, licenses serve to establish and limit the extent to which they can use, modify or distribute the software.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Classification of Software and Software Licenses
&lt;/h2&gt;

&lt;p&gt;Generally, in legal parlance, a software can be classified either as unlicenced or licensed. This classification determines the extent to which the software can be used, modified, and redistributed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unlicensed Software;
&lt;/h2&gt;

&lt;p&gt;is that not covered by terms and conditions for its use. They can be subdivided into public domain software and private unlicensed software. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Public Domain Software:&lt;/strong&gt;  These are software in the public domain. They are free of terms and limitations on their usage. A user is free to use, modify and redistribute at will. An example of this is SQLite(A database engine).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Private Unlicensed Software:&lt;/strong&gt; They do not come with licenses, nonetheless are protected under copyright law. The fact that these software are unlicensed does not mean one can use them at will, users still have to be careful in how they use, modify or redistribute them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Licensed software;
&lt;/h2&gt;

&lt;p&gt;is that software with explicit terms and conditions for its use. The type of license used by this software can be broadly grouped into free and open-source software licenses and proprietary software licenses.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Free and Open Source Software Licenses:
These licenses permit users to use the operational code, modify the source codes, and also redistribute the same with little to no restrictions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Common Types of Open Source Software Licenses &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Permissive licenses:&lt;/strong&gt; They are the most common type of software license. Permissive licenses allow you to use, modify and redistribute the software with minimal restriction. Examples include; Apache and MIT (used in solidity).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Copyleft licenses:&lt;/strong&gt; These allow usage of the software, and modification into one’s own product, with one caveat. The caveat being that; one must reciprocate the license when distributing a product/software made from the use of the original software carrying this type of license. &lt;/p&gt;

&lt;p&gt;You’re only allowed to use the software as long as you include the very same license used by the earlier software in any redistributed product created from the modification of the earlier software. Thus copyleft licenses permit usage and modification but restrict redistribution.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Proprietary or Commercial:
Unlike open-source software licenses, commercial software licenses do not allow for the usage, modification, or redistribution of software. Even if they do, they tend to grant very restrictive permissions. Such licenses are generally attached to commercial software and are heavily protected under copyright law. This type of license is common among business entities. With these, you cannot use, or reverse engineer the source code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where Does Solidity Come in All of This?
&lt;/h2&gt;

&lt;p&gt;As we have established above, for open-source projects, where users can enjoy, modify and redistribute the software, it is best they come with a permissive open-source license.&lt;/p&gt;

&lt;p&gt;Most smart contracts and blockchain protocols are open-sourced. It is essential that they are open-sourced as trust is one of the key tenets of the blockchain and web 3. Making your contract open source aids in the establishment of trust.&lt;/p&gt;

&lt;p&gt;As a result, you have to supply/identify the type of open-source license the contract uses so as to set the terms and conditions for the usage of your contract. The recommended licensing standard on the Ethereum network is the SPDX licensing identifiers which are readable by the Ethereum Virtual Machine.&lt;/p&gt;

&lt;p&gt;SPDX refers to Software Data Package Exchange. It is an open-source project hosted by the Linux Foundation. The goal is to help standardize the formats for data sharing. One way SPDX does this is by providing a list of open-source licenses for projects to reference. The SPDX open-source license list available to projects includes Apache, Barr, BSD, and many more. The recommended license in solidity is however the MIT license.&lt;/p&gt;

&lt;p&gt;To summarize the above, SPDX provides a standard for sharing software data(open-source). One of these common standards is in license referencing. They do this by proving a list of licenses projects can reference. The MIT license used in solidity is one of the many licenses on the&lt;a href="https://spdx.org/licenses/" rel="noopener noreferrer"&gt; SPDX list&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Should the SPDX-License-Identifier be Located in my Code?
&lt;/h2&gt;

&lt;p&gt;The SPDX license identifier can be written anywhere in your code as the solidity compiler can recognize it from wherever. It is however considered best practice to write it at the very top of your code. &lt;/p&gt;

&lt;h2&gt;
  
  
  What Happens If I Fail to Include the SPDX identifier in my smart contract
&lt;/h2&gt;

&lt;p&gt;Failure to reference a license in your contract will cause the solidity compiler to throw a warning rather than an error. Identifying multiple licenses on the other hand will throw an error.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can I Choose to Not Identify a License?
&lt;/h2&gt;

&lt;p&gt;Interestingly enough, if you want to prohibit code reuse, modification, and redistribution you can specify it in your contract. Instead of supplying a license identifier, you can simply use the special value; UNLICENSED. &lt;/p&gt;

&lt;p&gt;This way, the compiler will know you’re restricting the usage of your contract.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Takeaways
&lt;/h2&gt;

&lt;p&gt;The most important points in this piece are summed up below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Licenses in software spell out the terms by which that software can be used, modified, and redistributed.&lt;/li&gt;
&lt;li&gt;A Software could have Free and Open Sourced licenses or proprietary licenses.&lt;/li&gt;
&lt;li&gt;Free and Open source licenses allow for the usage of a software with little or no restrictions.&lt;/li&gt;
&lt;li&gt;Proprietary licenses on the other hand either expressly prohibit the usage of that software or permit usage under very strict conditions.&lt;/li&gt;
&lt;li&gt;SPDX stands for Software Data Package Exchange. They are an open-source project which helps standardize open-source licenses.&lt;/li&gt;
&lt;li&gt;Some of the open-source licenses available in their list of licenses include; MIT, Apache, Barr, and BSD.&lt;/li&gt;
&lt;li&gt;These types of open-source licenses are called permissive licenses and permit software usage with minimal restrictions.&lt;/li&gt;
&lt;li&gt;The majority of smart contracts are open-sourced as it helps build trust in the contract or protocol.&lt;/li&gt;
&lt;li&gt;Trust is a key feature of the blockchain.&lt;/li&gt;
&lt;li&gt;Solidity uses the MIT license to specify the terms of usage of each contract.&lt;/li&gt;
&lt;li&gt;You may include your license identifier anywhere in your contract, nonetheless specifying it at the top of your code is considered best practice.&lt;/li&gt;
&lt;li&gt;Failure to include a license identifier causes your compiler to throw a warning. &lt;/li&gt;
&lt;li&gt;Having multiple licenses results in a compiler error.&lt;/li&gt;
&lt;li&gt;If your contract is not open source, you can skip having a license identifier for the special value; UNLICENSED&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>How to fix injected web3 in Remix IDE</title>
      <dc:creator>CodeHadIt</dc:creator>
      <pubDate>Mon, 06 Feb 2023 15:19:37 +0000</pubDate>
      <link>https://dev.to/codehadit/how-to-fix-injected-web3-in-remix-ide-1j72</link>
      <guid>https://dev.to/codehadit/how-to-fix-injected-web3-in-remix-ide-1j72</guid>
      <description>&lt;p&gt;Sometimes when trying to deploy your smart contract from remix, it may refuse to select the inject web 3 provider(MetaMask) and connect your wallet. It may occasionally throw the following error; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&amp;gt; No injected Web3 provider found. Make sure your provider (e.g. MetaMask) is active and running (when recently activated you may have to reload the page)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Below is the simple step to fix this error. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
First, make sure your MetaMask is unlocked. Unlock it by simply &lt;strong&gt;typing your password&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;
Next, right click on the MetaMask icon on your extensions bar and click on &lt;strong&gt;manage extension&lt;/strong&gt; from the popup menu.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;
Then toggle on &lt;strong&gt;developer mode&lt;/strong&gt; on the next screen.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;
Lastly, **click on update **to update your MetaMask extension.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;
Return to Remix and you should now be able to connect your wallet to remix.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>remix</category>
      <category>web3</category>
    </item>
    <item>
      <title>Ethereum Gas Fees Explained (For Baby Devs)</title>
      <dc:creator>CodeHadIt</dc:creator>
      <pubDate>Sun, 05 Feb 2023 15:25:28 +0000</pubDate>
      <link>https://dev.to/codehadit/ethereum-gas-fees-explained-for-baby-devs-355h</link>
      <guid>https://dev.to/codehadit/ethereum-gas-fees-explained-for-baby-devs-355h</guid>
      <description>&lt;p&gt;For anyone starting their journey exploring the web 3 space, the concept of gas fees can be a hassle to wrap ones head around. I write the article to guide freshmen in web 3 on what gas fees are, why they're of importance and how to calculate them post the Ethereum Merge. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is Gas and why is it important in Ethereum?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Gas is the unit of measuring the amount of computational work the Ethereum Virtual Machine (This is what executes operations on the Ethereum network) expends in carrying out operations. Each operation has a corresponding unit of gas that’ll be required to successfully execute it. Basic operations like sending Eth require or consume lesser units of gas, while operations like minting an NFT and swapping tokens require more units to be executed. It is pertinent to know that deploying smart contracts also requires you to pay for gas. The Ethereum Foundation likens this process to your car requiring gas/petrol for its operation. Without sufficient gas, your car cannot perform the computational work of moving you around.&lt;/p&gt;

&lt;h2&gt;
  
  
  Okay? But Why do I Have to pay? Why can’t transactions be free?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Payment of gas fees is required for the following reasons.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First&lt;/strong&gt;, they are needed because The Ethereum Virtual Machine(henceforth referred to as the EVM) is a Turing complete machine. Turing complete is a term for a computer that can execute any type of computation given to it. The EVM can thus process any computation given to it. From NFTs to complex smart contracts, it can execute it all.  &lt;/p&gt;

&lt;p&gt;This sounds like a great thing yeah? Not quite! You see, the thing with Turing complete machines is that they have a halting problem. That is, since they can process any given computation, they can be loaded with endless computations. Turing complete machines like the EVM can be overwhelmed by giving them infinite looped computations which by their design, they cannot stop running. The only way for such machines to come to a halt is by running out of memory and eventually crashing. &lt;/p&gt;

&lt;p&gt;An example of this is your everyday printer, it is a Turing complete machine, in that it can print as many copies as you want it to with enough paper and ink. As such, there’s no way for the printer to stop itself from printing endless copies unless it runs out of memory and crash. The same scenario can be painted for the EVM. One can deploy smart contracts with infinite loops that will eventually overwhelm the Ethereum network. Bad actors can spam and crash the Ethereum blockchain with this. &lt;/p&gt;

&lt;p&gt;To avoid this, there needs to be a way for people to pay for the computational work the EVM executes so as to secure the network and deter bad actors. It is such that, for every work to be executed by the blockchain, there is a required unit of gas. Meaning, if you feed the EVM with an infinite looped smart contract, you’ll pay handsome amounts of gas for every iteration of that loop. This makes any attempt to crash the network a very expensive one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Another essential reason&lt;/strong&gt; for gas fees is the need to incentives nodes to keep running their nodes in good faith. Before the Ethereum network moved to the Proof of Stake(henceforth referred to as POS) consensus mechanism, transactions on Ethereum were verified by miners who ran nodes. These nodes were expensive to operate as they required heavy hardware and consumed megawatts of electricity. To validate a transaction, nodes solved complex problems using some hashing algorithm to get the right hash that matches a transaction before adding it to the blockchain. &lt;/p&gt;

&lt;p&gt;A reward system existed that incentivized miners to run nodes and keep the system decentralized. Miners who solved the problems first got the gas fees paid by users to have their transactions processed. Post POS, miners no longer run “nodes” to validate transactions. Instead, they stake a certain amount of Ether(32 Ether presently) to become validators on the network. However, they are still incentivised with the gas fees paid by users of the network.&lt;/p&gt;

&lt;p&gt;So now you know why gas fees are integral to the success of the Ethereum blockchain  or any other blockchain for that matter.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Are Gas Fees Then?
&lt;/h2&gt;

&lt;p&gt;To understand how gas fees are calculated, there is a need to discuss the concept from two different timelines. The time before the Ethereum London upgrade of EIP1559 (Ethereum improvement plan 1559) and the time after the EIP implementation in August of 2021.&lt;/p&gt;

&lt;p&gt;Before the London upgrade, the formula for calculating gas fee was;  Gas Unit Limit * gas price(in gwei). Gas limit?  gas price? Gwei? What are all these you might ask.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Gas Limit:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
The gas limit is the pre-set gas unit for a given transaction. That is, the max amount of gas, the EVM will use in executing the operation. Certain transactions have pre-set gas limits required to execute them. For example, the EVM uses about 21,000 gas to process the transfer of Ether from one wallet to another. For more complex transactions, the gas limit is higher. View this as the amount of gas you’ll need to get to go from point A to point B. If you’re driving interstate to meet family and friends, your car requires way more gas than when you’re going to the mall nearby.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Gas Price:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
The gas price is the current amount of gwei needed for one’s transaction to be included on the current block. At This juncture, there is a need to explain some terms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gwei:&lt;/strong&gt; Gwei stands for gigawei, it is a smaller fragment of Ether. 1 Ether is equal to 1,000,000,000. Yes, one billion gwei. Meaning, 0.5 Ether is 500,000,000 gwei. 0.1 Ether is 100,000,000 Gwei. When you send one Ether to someone, the EVM records it as 1,000,000,000 gwei under the hood. There also is wei, which is the smallest possible unit of value in the Ethereum ecosystem. That is one quintillion Ether or 1 billion gwei. 1 Ether is equal to 1,000,000,000,000,000,000,000 Wei. You only need to care about Gwei, but it’s nice to know it's baby brother.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Block:&lt;/strong&gt; Think of blocks as memory cards that store different data. It has a specified time with which to fill up its total storage with data, when full, it is added to a library of memory cards where each card connects to one another by referencing the serial number of the one before it, to form a chain of memory cards. This is what a block represents in a blockchain only that it stores records of different verified transactions. Also, the time required for each block to be filled with such transactions on the Ethereum blockchain is twelve(12) seconds. Thus, blocks have 12 seconds with which they can be filled with transactions after which they get added to the chain of blocks with each block referencing the hash of the previous block. &lt;/p&gt;

&lt;p&gt;Ever since the London upgrade, each block has had a target of 15 million units of gas within that 12 seconds timespan. Meaning 15 million units of computation processed by the EVM is expected in any given block. Thus, if only transfers of Ether were included in a given block, it’ll take roughly 714 transactions to fill up that block. I’ll explain more about this target block size further down the road.&lt;/p&gt;

&lt;p&gt;Thus, gas price is the amount in gwei it’ll take for a transaction to be included in the current block. This updates every 12 seconds. It fluctuates and the more transactions to be processed, the higher the fee as there are limited block spaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Back to our calculation of gas fees pre-August 2021.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So let's say John wants to send Jane 0.1 Ether and the gas price at that point in time is 100 gwei (low activity);&lt;/p&gt;

&lt;p&gt;Gas Fee is thus;  &lt;strong&gt;21,000 gas units * 100 gwei = 2,100,000 gwei&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To get the Ether value, you just divide it by 1,000,000,000 = 0.0021 Ether. Thus, Jane will pay 0.0021 Ether as gas fees and 0.1002 Ether in total.  To get the dollar value, you just multiply the fee by the current price of Ether.&lt;/p&gt;

&lt;p&gt;To illustrate another example, say we want to send 0.2 Ether to our wallet during an anticipated NFT mint, the gas Fee will likely be higher as there will be a fight for block space (I experienced this with the BAYC otherside land mint). As such the gas price may become something like 1000gwei.&lt;/p&gt;

&lt;p&gt;Thus gas fee is &lt;strong&gt;21,0000 * 700 /1,000,000,000,000 = 0.021 Ether&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Following the implementation of EIP1559, although the formula for calculating gas fees remained Gas unit * Gas price, the procedure for determining gas prices changed. Gas prices became a function of base and priority fees. The new formula looks as follows; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gas Limit * gas price(base fee + priority fee)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Essentially, the 1559 update introduced two new concepts in gas price calculation;  &lt;strong&gt;Base fee and priority fee&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Base fee &lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
This is determined by the block size of the previous block. As highlighted earlier blocks have a target size of 15 million gas. That number can be increased or decreased depending on the network demands. During surge periods, block sizes can be increased up to a max of  30 million gas. When this happens, the base fee will increase up to a maximum of 12.5% per block. Meaning where the target block size of 15 million gas is exceeded by one block, the base fee to have your transaction included on the next block will increase up to a maximum of 12.5%. Similarly, the base fee will be decreased if the block size is less than the target block size. &lt;/p&gt;

&lt;p&gt;Say block A had a size of 15 million with a base fee of 100 gwei, the base fee of block B(the next block) will remain the same even if it uses up the maximum block size of 30 million gas, however, the base fee of block C will be increased up to a max of 12.5% to bring it to 112.5 Gwei. If that block C still uses up more than 15 million gas, the base fee will keep increasing until it gets to a point down the chain where a given block has 15 million or less block size.  All this is done by the Ethereum protocol through a process called &lt;em&gt;&lt;strong&gt;tâtonnement&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;It is important to note that validators do not get paid this base fee as it is rather burned after the block has been added to the blockchain(mined). This is done to prevent miners from validating empty blocks and to make Ethereum deflationary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Priority Fee:&lt;/u&gt;&lt;/strong&gt; &lt;br&gt;
This is the fee paid to incentive a validator to include your transaction on the next block. This is an extra tip given by a user to have their transaction included on the blockchain. This fee is set by the user. The higher the fee, the more likely your transaction will get added to the block, especially during periods of high demand. &lt;/p&gt;

&lt;p&gt;In most cases however users don't get to set the priority Fee as it's handled by their wallet provider. Wallet providers like MetaMask have systems in place to calculate and determine a recommended priority fee. You can still manually set your priority Fee, but be sure it's not below the one auto-set by your wallet provider. It is recommended you don't alter settings with regard to gas units and priority fees unless you absolutely know what you're doing. Priority fees are what validators get paid together with block rewards from Ethereum. &lt;/p&gt;

&lt;p&gt;Let's calculate gas fees at present using our earlier example of John sending Jane 0.1 Ether. Given that the previous block did not exceed the 15 million gas limit and the current base fee is 80 gwei, John decides to tip the validator 10 gwei. The gas fee will be;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;21,000(Gas unit) * (80gwei (Base fee) + 10gwei (Priority fee)) = 1,890,000 gwei&lt;/strong&gt;. And of course, you divide by one billion to get the Ether value.&lt;/p&gt;

&lt;p&gt;The concept of gas fees can be quite tricky to grasp for newbie smart contract developers and generally for persons new to web 3. I really hope I explained the concept of gas fees to your understanding because the importance of understanding the rationale behind gas fees and how they’re calculated cannot be overemphasized. It will not only help aid your understanding of the Ethereum Virtual Machine but also enable you write smarter contracts.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>learning</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
