<?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: Hazem Allbabidi</title>
    <description>The latest articles on DEV Community by Hazem Allbabidi (@hazeyhaze).</description>
    <link>https://dev.to/hazeyhaze</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%2F1153213%2Ff9cf89a6-5206-4744-b118-ae17f33443f9.jpeg</url>
      <title>DEV Community: Hazem Allbabidi</title>
      <link>https://dev.to/hazeyhaze</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hazeyhaze"/>
    <language>en</language>
    <item>
      <title>Blue Screen Menus in Linux</title>
      <dc:creator>Hazem Allbabidi</dc:creator>
      <pubDate>Fri, 01 Mar 2024 18:13:48 +0000</pubDate>
      <link>https://dev.to/hazeyhaze/blue-screen-menus-in-linux-54pf</link>
      <guid>https://dev.to/hazeyhaze/blue-screen-menus-in-linux-54pf</guid>
      <description>&lt;p&gt;The Linux operating system has to be one of my favorite tools to study and work on. I got the opportunity recently to work on a tool that displays text boxes, menus, input boxes, and more in a GUI-based or even Terminal-based Linux. &lt;/p&gt;

&lt;p&gt;This tool is called &lt;strong&gt;Dialog&lt;/strong&gt;. It is basically a tool that covers the full screen of a terminal (or the full screen if it was a terminal-based OS) showing only the data to be displayed inside the dialog box.&lt;/p&gt;

&lt;p&gt;Today, I will be showing you how to install and use this tool on an &lt;strong&gt;Ubuntu 20.04 System&lt;/strong&gt; and how you can utilize it to improve the experience of a user who is not very familiar with using a terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing The Tool
&lt;/h2&gt;

&lt;p&gt;You can install the tool by using the apt package manager on Ubuntu:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install dialog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Structure of The Command
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dialog --title "Trying Out Dialog" --infobox "This is cool" 10 20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This are multiple parts in the above command, these parts are explained below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;dialog&lt;/code&gt;&lt;/em&gt; - (Required) This is the command needed to start the application&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;--title "Trying Out Dialog"&lt;/code&gt;&lt;/em&gt; - (Optional) The title of the dialog box shown on the screen, you can change the value between the quotations (")&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;--infobox "This is cool"&lt;/code&gt;&lt;/em&gt; - (One of many options) This is the type of box that is being shown in the dialog box. In this case, it is simply text put being displayed. &lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;10 20&lt;/code&gt;&lt;/em&gt;  - (Required) These two values describe the size of the dialog box, the first value is the amount of lines that describe the height, so in this case the box should have a height of 10 lines. The second value is how many characters wide the dialog box should be, in this case, it is 20 characters wide.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The image below shows the result of running the command explained above:&lt;br&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%2F7swy8n48vonvnuhn7k7r.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%2F7swy8n48vonvnuhn7k7r.png" alt="Dialog Infobox" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Many More Options
&lt;/h2&gt;

&lt;p&gt;As explained above, the command can take many more options for the type of dialog being displayed, the most common ones include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;inputbox&lt;/code&gt;&lt;/em&gt; - Displays an input box&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;textbox&lt;/code&gt;&lt;/em&gt; - Displays the content of a file&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;menu&lt;/code&gt;&lt;/em&gt; - Show a menu with multiple items in which the user can go through and click on one of the items&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;checklist&lt;/code&gt;&lt;/em&gt; - Display multiple items in the form of a checklist&lt;/li&gt;
&lt;li&gt;Many more!
For a list of examples of each of the available options, you can checkout this GitHub Repository by @&lt;a href="https://github.com/tolik-punkoff"&gt;tolik-punkoff&lt;/a&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/tolik-punkoff/dialog-examples"&gt;https://github.com/tolik-punkoff/dialog-examples&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Working With Menus
&lt;/h2&gt;

&lt;p&gt;For the sake of this tutorial, I will focus on building a menu using Dialog and how you can display items, as well as run functions or commands based on the choice made on the dialog by the user.&lt;/p&gt;

&lt;p&gt;This project will have a menu that asks the user whether they prefer eating waffles or pancakes, and run a function based on the choice made.&lt;/p&gt;

&lt;p&gt;We can start off by creating a file that will run all of this. Create a file called &lt;em&gt;&lt;strong&gt;waffles_vs_pancakes.sh&lt;/strong&gt;&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch waffles_vs_pancakes.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run the below command to give it read, write, and execute permissions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod 0777 waffles_vs_pancakes.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can start editing the file, you can use any code editor you prefer and start by typing the below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dialog --menu  "Which do you prefer more?"  0  0  0  \
    "Waffles"  "Waffles are better"  \
    "Pancakes"  "Pancakes are better" 2&amp;gt; results.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Command explained:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;--menu "Which do you prefer more? 0 0 0 \"&lt;/code&gt;&lt;/em&gt; - This prompts Dialog to display a menu that includes the items listed afterwards. The three zeros stand for the height, width, and menu height that will be assigned by Dialog automatically depending on the amount of content in the dialog box.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;"Waffles" "Waffles are better" \&lt;/code&gt;&lt;/em&gt; - This is how an option looks like in the menu. The first value would be the result of that option was clicked, the second value is a description of that option. So if the user click on this option, "Waffle" would be the result.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;"Pancakes"  "Pancakes are better" 2&amp;gt; results.txt&lt;/code&gt;&lt;/em&gt; - This first part of this line is the same as the above explained line, the difference here is the &lt;code&gt;2&amp;gt; results.txt&lt;/code&gt;, which takes the choice made by the user and prints it in a separate file called &lt;code&gt;results.txt&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the above is done and ran, it should look like this:&lt;br&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%2F8ja028lnuvcz10ib3gmd.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%2F8ja028lnuvcz10ib3gmd.png" alt="Dialog Menu" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we can start writing the logic for what happens after they make a choice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;case  `cat results.txt`  in
    Waffles) dialog --infobox "Waffles are better" 0 0;;
    Pancakes) dialog --infobox "Pancakes are better" 0 0;;
esac
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Command explained:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;case  `cat results.txt`  in&lt;/code&gt;&lt;/em&gt; - This line uses a switch to check the output of the user by accessing the &lt;code&gt;results.txt&lt;/code&gt; file that was created in the previous command.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;Waffles) dialog --infobox "Waffles are better" 0 0;;&lt;/code&gt;&lt;/em&gt; - This line checks if the value is equal to "Waffles" and if so then display another dialog with an infobox that has the message "Waffles are better".&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;code&gt;esac&lt;/code&gt;&lt;/em&gt; - This line represents the end of the switch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The result of this would display a dialog like the one below:&lt;br&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%2Fluvaqtr0vqkbxipcaqek.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%2Fluvaqtr0vqkbxipcaqek.png" alt="Dialog Infobox 2" width="541" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After completing the file, you can run it from the terminal by running the below command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./waffles_vs_pancakes.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Thank you for reading this tutorial, I hope it benefited from it and gained some new knowledge. You can checkout the below links for more details on Dialog and how you can go further with it.&lt;br&gt;
&lt;a href="https://github.com/tolik-punkoff/dialog-examples"&gt;https://github.com/tolik-punkoff/dialog-examples&lt;/a&gt; - Dialog Option Examples&lt;br&gt;
&lt;a href="https://www.linuxjournal.com/article/2807"&gt;https://www.linuxjournal.com/article/2807&lt;/a&gt; - An Introductory Tutorial&lt;br&gt;
&lt;a href="https://linuxcommand.org/lc3_adv_dialog.php"&gt;https://linuxcommand.org/lc3_adv_dialog.php&lt;/a&gt; - More detailed documentation&lt;/p&gt;

&lt;p&gt;Thanks again for reading and best of luck!&lt;/p&gt;

</description>
      <category>linux</category>
      <category>cli</category>
    </item>
    <item>
      <title>Proof-of-Work and Mining</title>
      <dc:creator>Hazem Allbabidi</dc:creator>
      <pubDate>Sun, 27 Aug 2023 13:55:02 +0000</pubDate>
      <link>https://dev.to/hazeyhaze/proof-of-work-and-mining-387j</link>
      <guid>https://dev.to/hazeyhaze/proof-of-work-and-mining-387j</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Zq0hYbUk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2AKWxwJsVMDaygpRRB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zq0hYbUk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2AKWxwJsVMDaygpRRB.png" alt="" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Proof-of-Work and Mining
&lt;/h3&gt;

&lt;p&gt;A blockchain, and I am mainly talking about Bitcoin here, seeks to benefit all the people using it, these include the people who make payments, the people who receive payments, and also the people who approve these transactions. But who does the approving and the actual moving of the money, or Bitcoins?&lt;/p&gt;

&lt;p&gt;Proof-of-Work is the method used to ensure that transactions are not being altered or changed to cause double-payment, or reusing of the same money, and make sure everything runs smoothly. Proof-of-Work is a technical term that basically translates to a method of finding consensus using complex computations. The actual usage of it, especially in the blockchain, can be complicated, but I will try my best to explain it properly.&lt;/p&gt;

&lt;p&gt;In order to understand Proof-of-Work, we need to understand hashes. A hash is a computational algorithm of a value that outputs the exact same result everytime we use the exact same input, it is used to ensure that two outputs are the same without necessarily showing the full input. For example, we could hash the value “hello world”, and we would get the output “b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9”. No matter how many times hash the “hello world” that same output will be produced, but if we change it up just a tiny bit, e.g. “helloo world”, the output would be completely different, like in here: “671f53df225ff0c84208b7059e465a21f704d1404a37a632715b4e2bfa113fa4”. The output was completely different even when the change was very tiny and even barely noticable for some people, but this is the power and benefit of a hash. Since it is an algorithm, it can have different forms or functions, the main method used by Bitcoin is called SHA256, which is a function that outputs 256 Bits as a result, no matter how big or small the input was. There are many other hashing functions as well, but SHA256 is the one used by Bitcoin. The benefit of a hash is that is not reversable, meaning if you only have the output, or the hash, it is impossible to reverse it and find out what the input was.&lt;/p&gt;

&lt;p&gt;Now that we understand what a hash is, we can move on to understanding blocks and what they are. In the blockchain, we have what we refer to as Blocks. These blocks include all the transactions of the certain period, the previous block hash, a nonce, and the timestamp. Now who do all of these mean?&lt;/p&gt;

&lt;p&gt;In Bitcoin, a new block is formed every 10 Minutes. That means that all the previous transactions performed in the past 10 Minutes will be saved in the new block. We also give that block a timestamp, which is the time it has been created. Then we need to give it the previous block hash. This is the method that we use in order to connect the blocks together. Let us say we have 3 Blocks, and we want to connect them to each other, the way we do it on the blockchain, is to take the hash of the previous block, and adding it to the data of the new block that comes right after that one. This produces a list of items linked to each other, making it identifiable which block came after a specific block. The way we derive a hash is by taking all of that data and adding it as input to a hashing function, such as the SHA256. But there is one more thing we need to understand in order to fully know how Proof-of-Work in Bitcoin works.&lt;/p&gt;

&lt;p&gt;The last part of a block is what we call a “nonce”, and the use of it is a little bit more complicated. In order for the blockchain to ensure that a block was properly hashed, it ensures that the output fits a certain criteria. The main condition is for the output hash to have a set number of zeros at the beginning of the hash. For example, the criteria right now can be that we need four zeros at the beginning of the hash, for example, if the data we have in the block is just “hello world”, then we would keep hashing the value, until we have four zeros at the beginning. But if you recall, we previously mentioned that a hash always outputs the same result, given the same input, so how do we get new hashes everytime? That is where the “nonce” comes in. We perform a loop that hashes the data (i.e. “hello world”) along with the nonce, which is a number that starts as 1, and keeps going up until we find the hash that starts with four zeros. An example might help better undertstand. Assuming we have the data “hello world” and the nonce which starts at 1. We hash those two values: hash(“hello world” and 1) The output of this would be 385b541ea93b0b52527bd6ec106ea2897e9cfaefde8b503a3ead7eef962be72e, which does not start with four zeros. We increase the nonce from 1 to 2 and retry: hash(“hello world” and 2) The output of this would be f0baab7090353028efe61f2659b8c8fba366d02ef358be5edc2f667ba5b2612f. This does not start with four zeros either, so we keep increasing the nonce and running the hashing on the data until we get an output that fits the criteria. To get the correct result of this, we would have the data “hello world” and the nonce of 18014, which outputs the hash that fits the criteria: 0000d3d3702b7dce97cfd9f35705650ff9cfbc81025943525680241678594033. This is how the nonce works.&lt;/p&gt;

&lt;p&gt;To briefly summarize the above. We take the money-transfer transactions, the previous block hash, and the nonce, and run them through a hash function to get the output we need with the specific requirements set by the blockchain. Once that block is fully completed, along with it’s hash being generated, we get to work on the new block.&lt;/p&gt;

&lt;p&gt;Now the above explains the Proof-of-Work, which is the method used to mine cryptocurrency. Mining of Bitcoin is similar to the Mining of Gold. When you want to find new gold, you typically mine in a cave, right? Well, in Bitcoin, you mine Bitcoin by using hardware, such as a GPU or CPU, to run the Proof-of-Work to “find” new Bitcoins and also approve the transactions. Mining uses hardware to do the computations required by the Proof-of-Work to approve transactions and ensure that the blockchain is stable and cannot be attacked or hacked. The miner uses his PC or a device known as ASIC to mine new Bitcoins and acquire it for themselves because they are the ones that did the effort of mining them. Before we could buy Bitcoin from exchanges or from other people, users had to use their PCs in order to mine and find new Bitcoins.&lt;/p&gt;

&lt;p&gt;Hopefully this article helped you understand what is Proof-of-Work and what is mining. For an amazing and simple explanation in the form of a video, check out the link below: &lt;a href="https://www.youtube.com/watch?v=_160oMzblY8&amp;amp;ab_channel=AndersBrownworth"&gt;https://www.youtube.com/watch?v=_160oMzblY8&amp;amp;ab_channel=AndersBrownworth&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are interested in this topic, I recommend reading these two introductory books: This first one is a Chinese book that was translated to English. Some reviews on GoodReads wrote that they had difficulty understanding some of the English in it, but I personally had no problems. It is very simple and is filled with pictures, making it a fun and easy read: &lt;a href="https://amzn.to/3HBCOSs"&gt;https://amzn.to/3HBCOSs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second book explains lots of aspects in the Bitcoin and Blockchain technology, as well as many other technologies that use blockchain: &lt;a href="https://amzn.to/3LgzGgW"&gt;https://amzn.to/3LgzGgW&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at&lt;/em&gt; &lt;a href="https://hazemhadi.com/articles/proof-of-work-and-mining/"&gt;&lt;em&gt;https://hazemhadi.com&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mining</category>
      <category>proofofwork</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Introduction To Bitcoin</title>
      <dc:creator>Hazem Allbabidi</dc:creator>
      <pubDate>Wed, 16 Aug 2023 10:54:59 +0000</pubDate>
      <link>https://dev.to/hazeyhaze/introduction-to-bitcoin-5gff</link>
      <guid>https://dev.to/hazeyhaze/introduction-to-bitcoin-5gff</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qaFVQj7u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2AoyTMW5IywYirKQBx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qaFVQj7u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2AoyTMW5IywYirKQBx.png" alt="" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction To Bitcoin
&lt;/h3&gt;

&lt;p&gt;If you haven’t already, check out the &lt;a href="https://hazemhadi.com/articles/introduction-to-the-blockchain"&gt;Introduction To The Blockchain&lt;/a&gt; article I wrote in order to better understand this on. Nonetheless, in this article, I will be briefly talking about the history of Bitcoin and talking about some of the concepts it uses in order to work effeciently.&lt;/p&gt;

&lt;p&gt;Before Bitcoin came to being, money transfer was not an easy thing to do. You would typically go to a bank or a service in order for them to help you transfer money. This took both a lot of time, and a lot of money. A bank or service can also be hacked, regardless of how secure it is, one small manipulation can change a lot, and money is not to be played with. Almost 100 years ago, a person nicknamed “Pretty Boy Floyd” robbed banks, and one thing he did was destroy debts of mortgages. While this might seem like a heroic act, for software engineers nowadays, this can seem like a problem that needs to be fixed.&lt;/p&gt;

&lt;p&gt;Due to this difficulty of transferring money around, someone by the name of Satoshi Nakamoto, created what is called Bitcoin. He first wrote a white paper about it, which is a document that describes the technology and the reason it has been built. In the white paper, he described a peer-to-peer electronic cash system. It uses multiple concepts in order to ensure that it cannot be hacked or changed. He describes how this technology works by explaining the transactions that occur on it (i.e. transferring money), the way it ensures that a transaction is valid (Proof-of-Work), and even how it gets used in a network of nodes. This white paper was published in October of 2008.&lt;/p&gt;

&lt;p&gt;A few months after the release of the white paper, in January of 2009, the first transaction on the blockchain happened, which was a transfer of 10 Bitcoins from Satoshi to a cryptographer called Hal Finney. A year later, someone named Laszlo Hanyecz made the first commercial transaction by buying two pizzas for 10,000 Bitcoin, that day (May 22nd) is marked as the Bitcoin Pizza Day.&lt;/p&gt;

&lt;p&gt;The way that Bitcoin was made (before you could simply buy it on an exchange), you had to “mine” the coins. This meant using hardware, such as your PC, to do some computations, to ensure that the transactions on the blockchain are valid, while also “mining” the actual Bitcoin. This made the situation of using Bitcoin a win for everybody. Those who needed to transfer money, could simply do it on the blockchain, while those who wanted to earn some money (Bitcoin), they used their hardware to mine the Bitcoin and make sure that the transactions on the blockchain are approved.&lt;/p&gt;

&lt;p&gt;While Bitcoin was a very innovative idea, some people thought the blockchain could be more useful than simply transferring money. New ideas such as Ethereum started rising, building on concepts such as Smart Contracts, NFTs, and more.&lt;/p&gt;

&lt;p&gt;This was some history about Bitcoin and why it was built.&lt;/p&gt;

&lt;p&gt;If you are interested in this topic, I recommend reading these two introductory books: This first one is a Chinese book that was translated to English. Some reviews on GoodReads wrote that they had difficulty understanding some of the English in it, but I personally had no problems. It is very simple and is filled with pictures, making it a fun and easy read: &lt;a href="https://amzn.to/3HBCOSs"&gt;https://amzn.to/3HBCOSs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second book explains lots of aspects in the Bitcoin and Blockchain technology, as well as many other technologies that use blockchain: &lt;a href="https://amzn.to/3LgzGgW"&gt;https://amzn.to/3LgzGgW&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at&lt;/em&gt; &lt;a href="https://hazemhadi.com/articles/introduction-to-bitcoin/"&gt;&lt;em&gt;https://hazemhadi.com&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>bitcoin</category>
      <category>beginners</category>
      <category>introduction</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Introduction To The Blockchain</title>
      <dc:creator>Hazem Allbabidi</dc:creator>
      <pubDate>Wed, 16 Aug 2023 10:53:34 +0000</pubDate>
      <link>https://dev.to/hazeyhaze/introduction-to-the-blockchain-3792</link>
      <guid>https://dev.to/hazeyhaze/introduction-to-the-blockchain-3792</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--guqRx-k0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2ADLW_CVKg_gfWKF58.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--guqRx-k0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2ADLW_CVKg_gfWKF58.png" alt="Article Image" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction To The Blockchain
&lt;/h3&gt;

&lt;p&gt;As humans evolve, we tend to create technologies that help us grow on large scales. In 1971, Unix was created which led to the amazing Operating Systems we use now like Linux and Mac OS. Then 1983 was the birth of the internet which now is a necessity in our lives. In 2008, blockchain was brought into the world of technology by an unknown person that refers to himself as Satoshi Nakamoto.&lt;/p&gt;

&lt;p&gt;The blockchain was invented to allow us to move currency around the world, without relying on third-parties like banks. It is basically a way to keep track of transactions in a system that cannot be changed, except in specific situations. It allowed for a way to allow a specific amount of money to be moved and without allowing that same money to be used multiple times. It was a system that was built to replace having to trust a person.&lt;/p&gt;

&lt;p&gt;In previous times, and even now, trusting someone to perform an action is a difficult choice to be made. One common problem when explaining the benefits of the blockchain is the Byzantine Generals Problem. The problem is “How do you make absolutely sure that multiple entities, which are separated by distance, are in absolute full agreement, before an action is taken?”. Basically, how can different people reach consensus to do a specific thing. In this problem, there is an enemy city that they wish to attack, there are, let’s say, 4 armies and each one is led by 1 General, and the attack will not be successful unless all four armies attack the city at the same time. The problem consists of multiple issues. First, what if the timing of the attack is not confirmed by all generals? One might start the attack at 3 AM while the other starts the attack at 3 PM. Another issue is if one of the generals was a traitor and they confirmed the time of the attack, but they instead retreated and did not attack?&lt;/p&gt;

&lt;p&gt;The blockchain proposed a solution to this problem. Instead of needing each other’s trust, the blockchain has the transactions of the generals hashed in a way that cannot be altered. Meaning that if a general attempted to change the data in the blockchain, it will be rejected because of the difficult mathematical algorithms that were ran on the initial transaction data to verify that it is correct. In essence, if a piece of information is stored on the blockchain, it cannot be changed, therefore it is to be trusted.&lt;/p&gt;

&lt;p&gt;The blockchain is basically a public ledger of all the transactions in the Bitcoin network, which is a cryptocurrency built along with the blockchain. Bitcoin is a digital currency that allows for use to transfer to other wallets/people online. The Bitcoin and blockchain are used together to achieve the end goal of using digital currency securely and without manipulation.&lt;/p&gt;

&lt;p&gt;The way it works is, someone sends another person some Bitcoin, from one wallet to another. The transaction is first sent to the Bitcoin network to be verified, this halts the use of any of that money from the sender’s wallet, meaning they cannot reuse that money to send more people. So if the sender has 1 Bitcoin, they can only send or transfer 1 Bitcoin. Once the transaction is sent to the network, it will be verified using a series of difficult mathematical problems that are solved using a certain mechanism. The mechanism used in the Bitcoin blockchain is the Proof-of-Work, which involves using computers to solve these mathematical problems, in order to check in with different computers (or nodes) to ensure that they reach consensus and verify the transaction that was made. Once the transaction is verified, the sender will no longer have that 1 Bitcoin and the receiver has successfully received it.&lt;/p&gt;

&lt;p&gt;I previously said that the data in the blockchain cannot be altered, except in , or mining, specific situations. Let us say that 3 of the 4 Generals were controlled by a king. They decided not to attack the enemy city while the 4th one did not know about the decision. The king ordered the 3 Generals and their armies to retreat. Because the majority of the “votes”, which are of the 3 generals, are leaning towards retreating, the outcome of this plan would be to retreat, even if the initial decision was to make an attack. This can be referred to as a 51% attack. This is when a single person or entity, controls at least 51% of the Proof-of-Work power which allows the alteration of the data and making it verified on the 51% of the nodes in the blockchain. And because the blockchain uses multiple nodes to verify a transcation, it votes on whether this transaction meets the correct criteria, then it gets the vote, if not, then it bascially fails. Just like if a president got 51% of the votes in an election, it is impossible for any other candidate to reach that percentage, therefore candidate with 51% votes wins the election.&lt;/p&gt;

&lt;p&gt;This was an introduction to the basics of the blockchain and a little bit about Bitcoin. I will talk more about Bitcoin in the next article.&lt;/p&gt;

&lt;p&gt;If you are interested in this topic, I recommend reading these two introductory books: This first one is a Chinese book that was translated to English. Some reviews on GoodReads wrote that they had difficulty understanding some of the English in it, but I personally had no problems. It is very simple and is filled with pictures, making it a fun and easy read: &lt;a href="https://amzn.to/3HBCOSs"&gt;https://amzn.to/3HBCOSs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second book explains lots of aspects in the Bitcoin and Blockchain technology, as well as many other technologies that use blockchain: &lt;a href="https://amzn.to/3LgzGgW"&gt;https://amzn.to/3LgzGgW&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at&lt;/em&gt; &lt;a href="https://hazemhadi.com/articles/introduction-to-the-blockchain/"&gt;&lt;em&gt;https://hazemhadi.com&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>introduction</category>
      <category>bitcoin</category>
      <category>blockchain</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
