<?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: Siddharth Singh Baghel </title>
    <description>The latest articles on DEV Community by Siddharth Singh Baghel  (@siddharthsing).</description>
    <link>https://dev.to/siddharthsing</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%2F724576%2Fdac7c15f-a75e-429e-b34c-cf95b4d3293c.jpeg</url>
      <title>DEV Community: Siddharth Singh Baghel </title>
      <link>https://dev.to/siddharthsing</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/siddharthsing"/>
    <language>en</language>
    <item>
      <title>What are smart contracts? Learn and deploy your first contract.</title>
      <dc:creator>Siddharth Singh Baghel </dc:creator>
      <pubDate>Tue, 13 Jun 2023 15:27:45 +0000</pubDate>
      <link>https://dev.to/siddharthsing/what-are-smart-contracts-learn-and-deploy-your-first-contract-1l3e</link>
      <guid>https://dev.to/siddharthsing/what-are-smart-contracts-learn-and-deploy-your-first-contract-1l3e</guid>
      <description>&lt;p&gt;Congratulate and appreciate yourself because you choose to enter the web3 world, a technical underworld that has immense potential and opportunities for devs like us. Checkout more articles related to blockchain and web3 &lt;a href="https://dev.to/siddharthsing/roadmap-to-blockchain-development-on4"&gt;here &lt;/a&gt;on this article series and make a presence in web3 underworld 😎.&lt;/p&gt;

&lt;p&gt;Lets enter the web3 underworld: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XGY6JzJw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91e5txu4xneynien7vew.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XGY6JzJw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91e5txu4xneynien7vew.gif" alt="A gif to show we are entering inside web3 underworld" width="498" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What are Smart Contracts &lt;/li&gt;
&lt;li&gt;Who uses smart contracts?&lt;/li&gt;
&lt;li&gt;Prerequisites &lt;/li&gt;
&lt;li&gt;IDE for writing Smart Contract&lt;/li&gt;
&lt;li&gt;
Miscellaneous FAQs

&lt;ul&gt;
&lt;li&gt;How do I create a smart contract in blockchain?&lt;/li&gt;
&lt;li&gt;What is a smart contract vs blockchain?&lt;/li&gt;
&lt;li&gt;What is an NFT smart contract?&lt;/li&gt;
&lt;li&gt;Is Bitcoin a smart contract?&lt;/li&gt;
&lt;li&gt;What is the smart contract platform?&lt;/li&gt;
&lt;li&gt;What is smart contract language?&lt;/li&gt;
&lt;li&gt;How do I make a smart contract?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Writer's Support ❤️&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Smart Contracts with Example?
&lt;/h2&gt;

&lt;p&gt;Smart contracts are simple programs or codes (written in the solidity programming language) stored in a blockchain that will be triggered upon certain conditions. As simple as that. Let me give a real-life example to better explain this.&lt;/p&gt;

&lt;p&gt;Remember the Espresso Machine in offices, &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QFA_Z8E9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ip8thwb1vdfvcr4omzjb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QFA_Z8E9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ip8thwb1vdfvcr4omzjb.jpg" alt="Espresso Machine to explain the smart contracts with real life example" width="800" height="743"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You press Espresso and put the cup below the nozzle then it will serve you the freshly made hot coffee. Your friend Peter Parker wants Cappuccino, he presses that button and got one, woohoo.&lt;/p&gt;

&lt;p&gt;Yeah, smart contracts are that simple. They are a simple set of rules which are written in a coding language (Solidity) with the help of variables and functions similar to any other coding language.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XRCF6WvY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ifs9mpw5wcyxrevd695.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XRCF6WvY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ifs9mpw5wcyxrevd695.png" alt="Espresso smart contract written in solidity in remix IDE" width="800" height="548"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Who uses smart contracts?
&lt;/h4&gt;

&lt;p&gt;Anyone working on web3 projects needs to do some work with smart contracts. Now, some of us might not be so much familiar with web3 and blockchains, I advise reading this article to get a more clear understanding.&lt;/p&gt;

&lt;p&gt;Coming to smart contracts, if you have decided to build a dApp (Decentralized Application) upon any chain which supports EVM (Ethereum Virtual Machine), you will need to write a smart contract.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Smart contracts are basically the bridge between the decentralized application and the blockchain. Let's take the previous Espresso Machine example, here suppose Espresso Machine is a Blockchain and you as a user wants a freshly made cappuccino.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What you will do is interact with the menu present on the espresso machine and press the Cappuccino button there. This menu is our smart contract, the bridge between the user and Blockchains (Espresso Machine here). &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Upon pressing the cappuccino button the smart contract will interact with the Ethereum Blockchain (or any other depending on the user) and transfer 30 wei( = 30* 10e-18 ETH) to the owner of the smart contract and serve you the coffee.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The owner&lt;/strong&gt; of the smart contract is the address who deploys it. Also, because smart contracts are deployed only once on the main-net, the owner can't be changed, any set of rules are also unchangeable after the deployment of the smart contract.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites
&lt;/h2&gt;

&lt;p&gt;So, since you have decided to enter the web3 world and are eager to write your first smart contract, let us discuss some of the homework which you have to do, &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Basic Understanding of Blockchain Technology - Follow &lt;a href="https://dev.to/siddharthsing/blockchain-bitcoin-ethereum-why-should-one-care--1naa"&gt;this&lt;/a&gt; article series from the beginning.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Learning Solidity - If you are good at any one programming language (c, cpp, python, etc. ) it will hardly take two-three weeks to learn solidity basics, and trust me basics are enough to start.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Resources: &lt;a href="https://www.tutorialspoint.com/solidity/index.htm"&gt;Solidity Tutorial&lt;/a&gt; is a very helpful website for learning solidity. Other than that DEV also has some very good articles and Youtube is always our saviour.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Follow me on DEV 😁&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  IDE (Integrated Development Environment)
&lt;/h2&gt;

&lt;p&gt;After completing the necessary prerequisites, you are ready to start coding your first Smart Contract.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Now when decide to start coding something, the first thing that crosses our mind is which IDE should prefer. Here, in case of solidity, since this language is still so young, we don't have many options for IDEs available. The one which is globally preferable at this time is Remix. &lt;a href="https://remix.ethereum.org/#lang=en&amp;amp;optimize=false&amp;amp;runs=200&amp;amp;evmVersion=null"&gt;Remix&lt;/a&gt; has a variety of test networks and each account in every network gives the user 100 free test ETHs which are more than sufficient for the developers.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Remix also gives us the option to connect our MetaMask wallets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you have mastered smart contracts and want to start building dApps, you need both the front end of the web or mobile app along with the backend, then you will use the IDEs preferred for respective dApps. For example, if you want to create a web dApp, you might prefer VS Code Editor.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Miscellaneous FAQs about Smart Contracts
&lt;/h2&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Q1.&lt;/strong&gt; &lt;strong&gt;How do I create a smart contract in blockchain?&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Learn about Blockchain Technology then learn the Solidity programming language, start building your first dApp, then deploy it on the mainnet (Ethereum) or any test networks (Georli, Roopsten, etc.). After deploying you have created your first smart contract in blockchain, woohoo, congrats. One thing is here that since your smart contract is stored inside the blockchain, therefore, if you deployed your smart contract to the mainnet then it is impossible to render that contract because blockchains are immutable and irreversible. But, you can do trial and error as many times as you want with the test network chains like Georli, Ropsten, etc. or with the advanced development environments like Truffle and Ganache, Hardfat, or Foundry.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Q2.&lt;/strong&gt; &lt;strong&gt;What is a smart contract vs blockchain?&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Smart contracts are simple codes or rules written in solidity programming language and Blockchains (Ethereum, Binance chain, polygon, etc.) are the decentralized databases where these contracts are stored so that no one can ever render these contracts.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Q3. What is an NFT smart contract?&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Smart contracts which deal with minting, listing, buying, selling, collecting, and viewing NFTs are called NFT smart contracts. NFTs are non-fungible tokens, which means these are some digital art, music, photographs, etc. which are up for sale digitally and are unique in the world. The biggest digital art (NFTs) market is &lt;a href="https://opensea.io/"&gt;Opensea&lt;/a&gt;. I will also be posting an article where I will create an NFT marketplace dApp from scratch soon.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Q4. Is Bitcoin a smart contract?&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;No, Bitcoin is a blockchain and BTC is its cryptocurrency. Also, Bitcoin does not support storing smart contracts on it because the founder (Satoshi Nakamoto) is a ghost. No one in the world can contact him. To run smart contracts on any chain, the chain must support EVM (Ethereum Virtual Machine). Chains like Polygon, Binance chain, and Ethereum support EVM and hence we can store smart contracts on them.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Q5.&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What is the smart contract platform?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is smart contract language?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How do I make a smart contract?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Read the article from the begginning to get all the answers thoroughly.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;_____________________&lt;strong&gt;&lt;em&gt;&lt;em&gt;--End--&lt;/em&gt;&lt;/em&gt;&lt;/strong&gt;_____________________&lt;br&gt;
&lt;a&gt;&lt;/a&gt; &lt;/p&gt;
&lt;h2&gt;
  
  
  Writer's Support
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you find the article useful show some ❤️ by staring some of my repositories and following me on dev.to and github.

&lt;p&gt;
&lt;a href="https://www.linkedin.com/in/siddharth-singh-baghel-912866190/"&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bpeFljpm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://img.shields.io/badge/LinkedIn-0077B5%3Fstyle%3Dfor-the-badge%26logo%3Dlinkedin%26logoColor%3Dwhite" width="107" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://github.com/Siddharth-sing"&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X0Hgo7Mj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://img.shields.io/badge/GitHub-100000%3Fstyle%3Dfor-the-badge%26logo%3Dgithub%26logoColor%3Dwhite" width="92" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://dev.to/siddharthsing"&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xz2MGu8c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://img.shields.io/badge/dev.to-0A0A0A%3Fstyle%3Dfor-the-badge%26logo%3Ddev.to%26logoColor%3Dwhite" width="88" height="28"&gt;
&lt;/a&gt;

&lt;/p&gt;


&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Unlock the Secrets of Blockchain: What is a Consensus Algorithm?</title>
      <dc:creator>Siddharth Singh Baghel </dc:creator>
      <pubDate>Tue, 17 Jan 2023 11:33:12 +0000</pubDate>
      <link>https://dev.to/siddharthsing/unlock-the-secrets-of-blockchain-what-is-a-consensus-algorithm-2104</link>
      <guid>https://dev.to/siddharthsing/unlock-the-secrets-of-blockchain-what-is-a-consensus-algorithm-2104</guid>
      <description>&lt;p&gt;Blockchain technology has been gaining traction in recent years with its potential to revolutionize the way we store and transfer data. Its decentralization and security features have made it a popular choice for financial institutions, businesses, and individual users. But what is the key technology underlying this revolutionary technology? That is where consensus algorithms come in. In this blog post, we’ll explore what a consensus algorithm is and the different types of consensus algorithms available. We’ll also discuss the benefits and challenges associated with consensus algorithms, and present examples of the most popular consensus algorithms in use today.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to Blockchain
&lt;/h2&gt;

&lt;p&gt;Blockchain technology is a type of distributed ledger technology (DLT) where transactions are recorded across a network of computers in a secure and transparent manner. It is a secure and tamperproof system, as all transactions are cryptographically signed and stored in a decentralized public ledger. This public ledger is shared among all participants in the network and cannot be altered or tampered with, thus providing a secure and reliable way to store and transfer data.&lt;/p&gt;

&lt;p&gt;The users in such a network can be individuals, businesses, or organizations. In a blockchain-based system, all participants in the network must agree to the validity of a transaction before it can be added to the public ledger. This is where consensus algorithms come into play, as they help in establishing consensus among all participants in the network.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Consensus Algorithm?
&lt;/h2&gt;

&lt;p&gt;A consensus algorithm is an algorithm which is used to achieve consensus among all participants in a network. This is an important aspect of blockchain technology, as it ensures that all participants in the network agree on the validity of a transaction before it can be added to the public ledger. A consensus algorithm helps to ensure that all transactions are valid and secure, without the need for a centralized authority.&lt;/p&gt;

&lt;p&gt;Consensus algorithms are used to establish trust and agreement between all participants in the network. They are also used to prevent malicious actors from tampering with the data stored in the blockchain. This is done by requiring all participants in the network to agree to the validity of a transaction before it is added to the public ledger.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Consensus Algorithms
&lt;/h2&gt;

&lt;p&gt;There are several different types of consensus algorithms available, each with its own set of advantages and disadvantages. The most common types of consensus algorithms are &lt;strong&gt;Proof of Work (PoW), Proof of Stake (PoS), and Proof of Authority (PoA).&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Proof of Work (PoW)&lt;/strong&gt; is the most widely used consensus algorithm. It requires miners to solve complex mathematical puzzles in order to add new blocks to the blockchain. The miner who solves the puzzle first is rewarded with a block reward. This is a type of incentive mechanism to incentivize miners to continue mining and verifying transactions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Proof of Stake (PoS)&lt;/strong&gt; is a consensus algorithm which requires validators to stake a certain amount of their crypto assets in order to validate transactions. The validators are then rewarded with a block reward for successfully validating transactions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Proof of Authority (PoA)&lt;/strong&gt; is a consensus algorithm which requires validators to be authorized by a trusted third-party authority. This third-party is responsible for verifying the validity of transactions and ensuring that the network remains secure.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Benefits of Consensus Algorithms
&lt;/h2&gt;

&lt;p&gt;Consensus algorithms have several benefits associated with them. Firstly, they provide a secure and reliable way to store and transfer data. They also help to ensure that all participants in the network agree on the validity of a transaction before it can be added to the public ledger. Furthermore, consensus algorithms help to prevent malicious actors from tampering with the data stored in the blockchain.&lt;/p&gt;

&lt;p&gt;Additionally, consensus algorithms help to reduce the cost of verifying transactions, as they require fewer resources than traditional methods. This reduces the need for large amounts of energy to be consumed in order to verify transactions. Lastly, consensus algorithms help to ensure that all participants in the network are working towards the same goal, which helps to maintain the integrity of the network.&lt;/p&gt;

&lt;h2&gt;
  
  
  Challenges with Consensus Algorithms
&lt;/h2&gt;

&lt;p&gt;Although consensus algorithms provide several benefits, they also come with some challenges. Firstly, they require all participants in the network to agree on the validity of a transaction before it can be added to the public ledger. This can be difficult to achieve in a decentralized network, as different participants may have different opinions about the validity of a transaction.&lt;/p&gt;

&lt;p&gt;Moreover, consensus algorithms can be costly to implement, as they require resources such as computing power and energy. Furthermore, consensus algorithms can be vulnerable to attack, as malicious actors can try to interfere with the consensus process in order to gain control of the network.&lt;/p&gt;

&lt;p&gt;Lastly, consensus algorithms can be slow, as they require a lot of time and computing power to reach consensus. This can be an issue for applications that require real-time transactions, as the consensus process can slow down the entire network.&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples of Consensus Algorithms
&lt;/h2&gt;

&lt;p&gt;There are several different types of consensus algorithms available. The most popular consensus algorithms are Bitcoin’s Proof of Work (PoW) algorithm, Ethereum’s Proof of Stake (PoS) algorithm, and Ripple’s Ripple Protocol.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Bitcoin’s Proof of Work (PoW) algorithm requires miners to solve complex mathematical puzzles in order to add new blocks to the blockchain. The miner who solves the puzzle first is rewarded with a block reward. This is a type of incentive mechanism to incentivize miners to continue mining and verifying transactions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ethereum’s Proof of Stake (PoS) algorithm requires validators to stake a certain amount of their crypto assets in order to validate transactions. The validators are then rewarded with a block reward for successfully validating transactions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ripple’s Ripple Protocol is a consensus algorithm which requires validators to be authorized by a trusted third-party authority. This third-party is responsible for verifying the validity of transactions and ensuring that the network remains secure.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How Consensus Algorithms Work
&lt;/h2&gt;

&lt;p&gt;Consensus algorithms work by requiring all participants in the network to agree on the validity of a transaction before it can be added to the public ledger. This is done by having each participant in the network verify the transaction and reach a consensus on its validity.&lt;/p&gt;

&lt;p&gt;Once the consensus is reached, the transaction is added to the public ledger. This helps to ensure that all participants in the network agree on the validity of a transaction before it is added to the public ledger.&lt;/p&gt;

&lt;h2&gt;
  
  
  Popular Consensus Algorithms
&lt;/h2&gt;

&lt;p&gt;The most popular consensus algorithms in use today are Bitcoin’s Proof of Work (PoW) algorithm, Ethereum’s Proof of Stake (PoS) algorithm, and Ripple’s Ripple Protocol.&lt;/p&gt;

&lt;p&gt;Bitcoin’s Proof of Work (PoW) algorithm requires miners to solve complex mathematical puzzles in order to add new blocks to the blockchain. The miner who solves the puzzle first is rewarded with a block reward.&lt;/p&gt;

&lt;p&gt;Ethereum’s Proof of Stake (PoS) algorithm requires validators to stake a certain amount of their crypto assets in order to validate transactions. The validators are then rewarded with a block reward for successfully validating transactions.&lt;/p&gt;

&lt;p&gt;Ripple’s Ripple Protocol is a consensus algorithm which requires validators to be authorized by a trusted third-party authority. This third-party is responsible for verifying the validity of transactions and ensuring that the network remains secure.&lt;/p&gt;

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

&lt;p&gt;In conclusion, consensus algorithms are an important part of blockchain technology. They help to ensure that all participants in the network agree on the validity of a transaction before it can be added to the public ledger. There are several different types of consensus algorithms available, each with its own set of advantages and disadvantages. The most popular consensus algorithms in use today are Bitcoin’s Proof of Work (PoW) algorithm, Ethereum’s Proof of Stake (PoS) algorithm, and Ripple’s Ripple Protocol.&lt;/p&gt;

&lt;p&gt;Consensus algorithms provide a secure and reliable way to store and transfer data. They also help to reduce the cost of verifying transactions, as they require fewer resources than traditional methods. However, they can be costly to implement and vulnerable to attack.&lt;/p&gt;

&lt;p&gt;Therefore, it is important to choose the right consensus algorithm for your application. If you’re looking to leverage the power of blockchain technology, then understanding the different types of consensus algorithms available is essential. With the right consensus algorithm, you can ensure that your transactions are secure and reliable.&lt;/p&gt;

&lt;p&gt;Now that you know what a consensus algorithm is and the different types of consensus algorithms available, you can start leveraging the power of blockchain technology. If you’re looking for a secure and reliable way to store and transfer data, then the blockchain is the way to go. So, what are you waiting for? Unlock the secrets of blockchain today and start leveraging the power of consensus algorithms.&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>discuss</category>
      <category>tooling</category>
    </item>
    <item>
      <title>Blockchain Block Anatomy</title>
      <dc:creator>Siddharth Singh Baghel </dc:creator>
      <pubDate>Sat, 07 Jan 2023 16:26:29 +0000</pubDate>
      <link>https://dev.to/siddharthsing/block-anatomy-of-a-blockchain-4773</link>
      <guid>https://dev.to/siddharthsing/block-anatomy-of-a-blockchain-4773</guid>
      <description>&lt;p&gt;So far in this article series, we have discussed the &lt;a href="https://dev.to/siddharthsing/blockchain-bitcoin-ethereum-why-should-one-care--1naa"&gt;Blockchain&lt;/a&gt;, its &lt;a href="https://dev.to/siddharthsing/roadmap-to-blockchain-development-on4"&gt;roadmap&lt;/a&gt;, and some of its &lt;a href="https://dev.to/siddharthsing/5-building-blocks-of-blockchain-every-developer-should-know-3902"&gt;key concepts&lt;/a&gt;. Now, we will be diving a little deep into blockchain and breaking down a single unit or a block in the blockchain and learning about it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv1jmnose0voq738wteeh.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv1jmnose0voq738wteeh.gif" alt="Lets get started gif" width="498" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Blockchain Structure
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One can imagine a Blockchain as a linked list. Similar to a Linked List the blocks of a blockchain are connected through something, that something in the linked list is the address of the previous node but in the blockchain, it is the Merkle-Hash value of the previous block, which is stored in the successor block.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft2im6nd89d4rn8lhzpmp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft2im6nd89d4rn8lhzpmp.png" alt="Blockchain structure showing hash codes connecting the previous block" width="800" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An obvious question might arise in your mind, how many blocks &lt;br&gt;
can be present in a blockchain?&lt;br&gt;
The answer is any number of blocks are possible, as long as the &lt;br&gt;
maintainers are good with that. You can check this &lt;a href="https://bitinfocharts.com/ethereum/" rel="noopener noreferrer"&gt;link&lt;/a&gt; to see how many blocks of &lt;br&gt;
some famous blockchains are created to date.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Here is an image of Ethereum's block count.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu6wz0sn8g7f574wbia4w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu6wz0sn8g7f574wbia4w.png" alt="Ethereum block count" width="800" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Block Structure
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A block in a blockchain constitutes of two components, Header (which is further divided into six components) and Ledger - the main transaction database. Below is the image to roughly visualize a block in a blockchain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpgnmibd0qt59tyaw4etm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpgnmibd0qt59tyaw4etm.png" alt="Block structure of a blockchain showing Block header - Version, Merkel Hash root, previous hash code, bits, timestamp and nonce  and block ledger with few transactions" width="664" height="786"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The block structure in the image above does not show all the components of the block's head, but I will be listing all of them in the next section.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Block-Header
&lt;/h3&gt;

&lt;p&gt;The Block-Header is an 80 bytes long string consisting of six components - &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Version (4 bytes) &lt;/li&gt;
&lt;li&gt;A hash code of the previous block (32 bytes)&lt;/li&gt;
&lt;li&gt;The current block's Merkle-Hash code value (32bytes)&lt;/li&gt;
&lt;li&gt;Timestamp (4 bytes)&lt;/li&gt;
&lt;li&gt;Bits (4 bytes) &lt;/li&gt;
&lt;li&gt;Nonce value (4 bytes)&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Version&lt;/strong&gt; - It is as the name is the version number of the protocol used in the chain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Previous block hash&lt;/strong&gt; - The block header contains a 256-bit long Merkle Hash code value of the previous block to stay connected with the blockchain. The first block in any blockchain is called a &lt;strong&gt;Genesis block&lt;/strong&gt; - A block that doesn't have any previous block hash.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Merkle Hash value&lt;/strong&gt; - Merkle hash code value of each block is a combination of all the hashes changed during each transaction in a block. It is a 256 bit long Hash code which acts as an identity or name for a block.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Timestamp&lt;/strong&gt; - Each block contains a &lt;a href="https://en.wikipedia.org/wiki/Unix_time" rel="noopener noreferrer"&gt;Unix time&lt;/a&gt; timestamp. In addition to serving as a source of variation for the block hash, they also make it more difficult for an adversary to manipulate the block chain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bits&lt;/strong&gt; - Bits can be understood as a level of difficulty assigned to the miners for the process of proof-of-work. Adding a new block in a blockchain is a tremendously difficult task, miners have to solve a very tough mathematical puzzle (not literally a puzzle) in order to add a block. The difficulty of that puzzle is stored in the Bits field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nonce&lt;/strong&gt; - It is that puzzle that miners are trying to solve extensively to get rewarded. Nonce itself is a full article topic so I will not be emphasizing it too much here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Block Ledger
&lt;/h3&gt;

&lt;p&gt;The Block ledger contains the details of all the transactions stored in a block. A block can store up to 2000 transactions. The maximum size a block can achieve is 1MB, depending upon the number of transactions recorded in a particular block. As long as the chain length increases it becomes impossible to update or manipulate these transactions and this makes the blockchain immutable.&lt;/p&gt;

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

&lt;p&gt;That was all about the block structure of a blockchain, I covered all the components of the block's structure. Hope you like the article. More articles on this series coming every week, so stay tuned.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writer's Support
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you find the article useful show some love ❤️ by following me on linkedin or github or instagram or twitter or everywhere 🤩.

&lt;p&gt;
&lt;a href="https://twitter.com/SidharthSing20" rel="noopener noreferrer"&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FTwitter-1DA1F2%3Fstyle%3Dfor-the-badge%26logo%3Dtwitter%26logoColor%3Dwhite" width="83" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://www.linkedin.com/in/siddharth-singh-baghel-912866190/" rel="noopener noreferrer"&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FLinkedIn-0077B5%3Fstyle%3Dfor-the-badge%26logo%3Dlinkedin%26logoColor%3Dwhite" width="91" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://github.com/Siddharth-sing" rel="noopener noreferrer"&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FGitHub-100000%3Fstyle%3Dfor-the-badge%26logo%3Dgithub%26logoColor%3Dwhite" width="95" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://dev.to/siddharthsing"&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2Fdev.to-0A0A0A%3Fstyle%3Dfor-the-badge%26logo%3Ddev.to%26logoColor%3Dwhite" width="92" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://www.instagram.com/i_m_siddharth.singh/" rel="noopener noreferrer"&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FInstagram-E4405F%3Fstyle%3Dfor-the-badge%26logo%3Dinstagram%26logoColor%3Dwhite" width="123" height="28"&gt;
&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2xzvand44haz2dpfayf.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2xzvand44haz2dpfayf.gif" alt="Image description" width="157" height="168"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>discuss</category>
    </item>
    <item>
      <title>How Blockchain hides your Identity?</title>
      <dc:creator>Siddharth Singh Baghel </dc:creator>
      <pubDate>Tue, 27 Dec 2022 06:32:10 +0000</pubDate>
      <link>https://dev.to/siddharthsing/how-blockchain-hides-your-identity-54mg</link>
      <guid>https://dev.to/siddharthsing/how-blockchain-hides-your-identity-54mg</guid>
      <description>&lt;p&gt;Click on the play button above to start the video.&lt;/p&gt;

&lt;p&gt;If you wanna read, see the full article &lt;a href="https://dev.to/siddharthsing/5-building-blocks-of-blockchain-every-developer-should-know-3902"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>web3</category>
      <category>tutorial</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>5 building blocks of blockchain every developer should know</title>
      <dc:creator>Siddharth Singh Baghel </dc:creator>
      <pubDate>Fri, 23 Dec 2022 16:30:13 +0000</pubDate>
      <link>https://dev.to/siddharthsing/5-building-blocks-of-blockchain-every-developer-should-know-3902</link>
      <guid>https://dev.to/siddharthsing/5-building-blocks-of-blockchain-every-developer-should-know-3902</guid>
      <description>&lt;p&gt;If you are interested in Ethereum Blockchain Development, please check out the roadmap I discussed &lt;a href="https://dev.to/siddharthsing/roadmap-to-blockchain-development-on4"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this article, I will be discussing five fundamental concepts of blockchain that every developer should know whether they want to enter the web3 environment or not.  Also, this article series on dev.to will be a complete guide to Ethereum Blockchain Development, so stay tuned.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6qoh10jv8mvhrp1h0pqq.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6qoh10jv8mvhrp1h0pqq.gif" alt="Let's Started gif" width="500" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Some keywords to understand the article :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;&lt;strong&gt;Public Key&lt;/strong&gt;&lt;/u&gt; - It is a cryptographic key (a long sequence of hexadecimal numbers ) that can be obtained and used by anyone to encrypt messages or transactions intended for a particular recipient, such that the encrypted messages can be deciphered only by using a second key that is known only to the recipient (the private key ).&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;&lt;strong&gt;Private Key&lt;/strong&gt;&lt;/u&gt; - As pointed out above a private key is a decipherer or a decoder for a  message or transaction encrypted by the corresponding public key. The private key must not be shared with anyone as it is capable of making transactions from your address.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;Consensus Mechanism&lt;/u&gt;&lt;/strong&gt; - A consensus mechanism refers to any number of methodologies used to achieve agreement, trust, and security across a decentralized computer network. In the context of blockchains and cryptocurrencies, proof-of-work (PoW) and proof-of-stake (PoS) are two of the most prevalent consensus mechanisms through which blockchain sync every node present with same data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Anonymity
&lt;/h2&gt;

&lt;p&gt;So, it's true that Blockchains like Ethereum and Bitcoin are totally transparent, in other words, the history of every BTC, for instance, can be tracked from the block where it was mined to the wallet in which it is currently stored. Similarly, the history of transactions for all addresses can be tracked, as well, since addresses are identified by public keys, and these are visible to everyone.&lt;/p&gt;

&lt;p&gt;Still, blockchain maintains anonymity somehow :&lt;/p&gt;

&lt;h3&gt;
  
  
  Pseudonym or pseudonymity
&lt;/h3&gt;

&lt;p&gt;Pseudonym, which means a name used by somebody, instead of his/her real name. Blockchain does the same, instead of taking your original name like the traditional banking systems, Blockchain transacts through your address (public key). For example, your real name can be Mike but in the Blockchain environment, you will be identified as " 1ExAmpLe0FaBiTco1NAdDr3sSV5tsGaMF6hd " or something else, something much longer. &lt;/p&gt;

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

&lt;p&gt;The above image shows how the traditional banking system exposes the users' name, address, and even contact number, whereas blockchain transactions transacts using an alias that is a public key (address of the wallet).&lt;/p&gt;

&lt;p&gt;Blockchain is powerful, hence just hiding our name won't make us safe in this very vast environment because with great powers comes greater threat.&lt;br&gt;
&lt;strong&gt;Check out this 5 minutes Youtube video to understand Blockchains Anonymity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/4pKBvJEk6Nc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Decentralization
&lt;/h2&gt;

&lt;p&gt;Nowadays we often hear phrases like &lt;strong&gt;decentralization is the king&lt;/strong&gt;. So, what does it mean, and what is decentralization?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;Decentralization&lt;/u&gt;&lt;/strong&gt; is the transfer of control and decision-making from a centralized entity (individual, organization, government, or group thereof) to a distributed network. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To understand it clearly, assume you made a transaction with your friend, and your friend received it. Now Here, the transaction happens between you and your friend, but the knowledge of the transaction is available to four entities, you, the friend, the banks involved (yours and friend's), and the payment network processor (VISA, MasterCard, etc.).&lt;/p&gt;

&lt;p&gt;The payment flow goes something like this (see the image below). In this traditional banking system, say you sent a request to your bank 'A' to send $500 to your friend, now the bank needs to verify you and your friend both, but let's say your friend's account is in bank 'B', then bank 'A' is unable to verify the details of your friend because bank's don't share customer information (due to competition). Here comes Payment Network Processors (VISA, MasterCard, etc.), every bank sells all their customer's data to these companies and they verify the users on behalf of the banks.&lt;/p&gt;

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

&lt;p&gt;Thatswhy decentralization is king, in a decentralized system, like cryptocurrency (BTC, ETH, DogeCoin, etc. ), if a user sends cryptocurrency to their friend or anyone, only the sender and receiver will have knowledge about the transaction. The image below compare between Centralized Finance (CeFi) and Decentralised Finance (DeFi).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs09p65mroxdxhzb6bz0f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs09p65mroxdxhzb6bz0f.jpg" alt="Decentralization" width="612" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Fault Tolerance
&lt;/h2&gt;

&lt;p&gt;A decentralized blockchain network looks something like this (see the image below). Several nodes (or blocks) throughout the world are connected without any centralized authorities regulation. All the nodes are connected through a Consensus agreement, therefore each node is synchronized and has the same transaction ledger throughout the blockchain network. Since, all nodes have the same data present in them, if one or two nodes are compromised or have a threat, the system still does not become faulty. Those faulty nodes will be removed from the network and the blockchain goes on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp54ondc2jqtaba9jhvxe.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp54ondc2jqtaba9jhvxe.gif" alt="Fault tolerance" width="600" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Immutability
&lt;/h2&gt;

&lt;p&gt;Immutability is a much-coined term in the web3 community.  Blockchain is an immutable database, and you cannot manipulate data that's already present in the blockchain. How come? For that let's see how hash codes generate and what a block structure looks like. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Hash Code&lt;/u&gt;&lt;/strong&gt; - Hash codes are long hexadecimal sequences that are generated through various algorithms like SHA-1. Hash codes can vary greatly by just changing a letter of your name. For example, &lt;strong&gt;DEV&lt;/strong&gt; can be hashed as "&lt;strong&gt;FA489B5C2003&lt;/strong&gt;", but, &lt;strong&gt;DAV&lt;/strong&gt; will become "&lt;strong&gt;A8DC567B89E&lt;/strong&gt;". Hence hackers trying to manipulate transactions in the blockchain immediately causes the change of hashcodes and the system indicates the node is faulty. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;See the monkey gif below for the reference of how broadly a hashcode changes by changing a few things.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Block Structure&lt;/u&gt;&lt;/strong&gt; - Each block in a blockchain contains two long hashcodes. One is the hash of the block itself and the other is the previous block hash (see the image below). The previous block's hash is used to connect both the blocks together similar to a linked list. Now, suppose any hacker changes the transaction detail in any one block, its hashcode will be changed completely causing the break of the chain from the faulty node. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fju1wmduq9dulexzqcll0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fju1wmduq9dulexzqcll0.jpg" alt="ledger" width="547" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is why it is so damn difficult to update a blockchain node because if anyone tries to update one node all the consecutive nodes should be updated simultaneously and hence blockchain is nearly immutable.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Trustless
&lt;/h2&gt;

&lt;p&gt;Trustless is the quality of decentralization. Blockchain network is called trustless not because you can't trust it but because you don't have to trust any third party for your transactions. The transactions in the crypto environment are completely peer-to-peer-based (P2P) transactions where no centralized authorities (government, banks, etc.) are involved. Hence blockchain is called a trustless environment. Although no system can be completely trustless, at some point we have to trust any organization but in blockchain that anyone would be a code instead of a person.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writer's Support
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you find the article useful show some love ❤️ by following me on linkedin or github or instagram or twitter or everywhere 🤩.

&lt;p&gt;
&lt;a href="https://twitter.com/SidharthSing20" rel="noopener noreferrer"&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FTwitter-1DA1F2%3Fstyle%3Dfor-the-badge%26logo%3Dtwitter%26logoColor%3Dwhite" width="83" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://www.linkedin.com/in/siddharth-singh-baghel-912866190/" rel="noopener noreferrer"&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FLinkedIn-0077B5%3Fstyle%3Dfor-the-badge%26logo%3Dlinkedin%26logoColor%3Dwhite" width="111" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://github.com/Siddharth-sing" rel="noopener noreferrer"&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FGitHub-100000%3Fstyle%3Dfor-the-badge%26logo%3Dgithub%26logoColor%3Dwhite" width="95" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://dev.to/siddharthsing"&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2Fdev.to-0A0A0A%3Fstyle%3Dfor-the-badge%26logo%3Ddev.to%26logoColor%3Dwhite" width="92" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://www.instagram.com/i_m_siddharth.singh/" rel="noopener noreferrer"&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FInstagram-E4405F%3Fstyle%3Dfor-the-badge%26logo%3Dinstagram%26logoColor%3Dwhite" width="123" height="28"&gt;
&lt;/a&gt;
&lt;/p&gt;

&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>Roadmap to Blockchain Development</title>
      <dc:creator>Siddharth Singh Baghel </dc:creator>
      <pubDate>Thu, 15 Dec 2022 14:26:20 +0000</pubDate>
      <link>https://dev.to/siddharthsing/roadmap-to-blockchain-development-on4</link>
      <guid>https://dev.to/siddharthsing/roadmap-to-blockchain-development-on4</guid>
      <description>&lt;p&gt;To know how blockchain and web3 are the new internet click &lt;a href="https://dev.to/siddharthsing/blockchain-bitcoin-ethereum-why-should-one-care--1naa"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this roadmap to blockchain development, I will be suggesting some of the learning resources as we walk through. Also this article series on dev.to will also guide you through these topics one by one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two types of blockchain developers
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;There are two types of blockchain developers present. One who builds the blockchain from scratch (for example: Bitcoin creator Satoshi Nakamoto or Ethereum creator Vitalik Buterin) and others who build Decentralised Applications (dApps) upon the public blockchains already present.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In general, when we say blockchain developer, we mean the dApp (Decentralised Apps) developers who develop apps upon publicly available blockchain networks. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In this roadmap to blockchain development, I will be walking through all the topics to cover to become an Ethereum blockchain developer. Also, I will be suggesting some of the learning resources. This article series on blockchain will also guide you through these topics one by one.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;h2&gt;
  
  
  Start with Basics :
&lt;/h2&gt;

&lt;p&gt;Since blockchain technology is new in comparison to Android or Web Dev, the community of Blockchain Developers is limited. So it's crucial to have a good grasp on the foundation or the basics of blockchain.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blockchain foundation and use cases:
&lt;/h3&gt;

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

&lt;blockquote&gt;
&lt;p&gt;Week - 1 &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Why are People Excited About Blockchain? &lt;/li&gt;
&lt;li&gt;The Brief History of Blockchain &lt;/li&gt;
&lt;li&gt;The Move to &lt;strong&gt;Decentralization&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ledgers&lt;/strong&gt;, Distributed Ledgers, and &lt;strong&gt;Consensus&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;What is Blockchain?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Week - 2&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Basics of cryptography and hash Functions.&lt;/li&gt;
&lt;li&gt;Public Key Cryptography and Signing.&lt;/li&gt;
&lt;li&gt;Blocks and Blockchain, Structure of a block.&lt;/li&gt;
&lt;li&gt;Nodes and Network.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Week - 3&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Trust Framework and Consensus Mechanisms &lt;/li&gt;
&lt;li&gt;Public, Consortium, Private Blockchains&lt;/li&gt;
&lt;li&gt;Blockchain Interoperability&lt;/li&gt;
&lt;li&gt;When to Use a Blockchain (Limitations and Misconceptions),&lt;/li&gt;
&lt;li&gt;Implications of Blockchain on Traditional Business.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Week - 4&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Bitcoin and Ethereum &lt;/li&gt;
&lt;li&gt;Ethereum Blockchain&lt;/li&gt;
&lt;li&gt;Smart Contracts (Theory)&lt;/li&gt;
&lt;li&gt;Cryptocurrency Tokens&lt;/li&gt;
&lt;li&gt;Wallets and the Marketplaces&lt;/li&gt;
&lt;li&gt;Implications on Traditional Businesses.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;This foundation course is offered by the &lt;strong&gt;&lt;a href="https://in.coursera.org/learn/blockchain-foundations-and-use-cases" rel="noopener noreferrer"&gt;Consensys Academy&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this foundation course?
&lt;/h3&gt;

&lt;p&gt;There are several Blockchain foundation courses present on the internet. Not all of them are bad but some of them are misleading. I am referring to this course because this course presented by &lt;strong&gt;ConsenSys Academy&lt;/strong&gt;. ConsenSys is a &lt;strong&gt;market-leading blockchain technology company&lt;/strong&gt; and the parent company of &lt;strong&gt;Ethereum&lt;/strong&gt;. So why not learn something directly from its creators? Click &lt;a href="https://blockchain-hacks-siddharth-singh.netlify.app/" rel="noopener noreferrer"&gt;here&lt;/a&gt; for knowing about financial aid provided by Coursera.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project based learning
&lt;/h2&gt;

&lt;p&gt;Now that you have cleared your basics, you are good to go for the main battle. The best way to learn Ethereum blockchain development is by project-based learning. Learn blockchain by implementing it because things are very much uncertain in the web3 environment. Your knowledge today will not benefit you tomorrow. So try and learn by doing projects and keep yourself updated with the trend.&lt;/p&gt;

&lt;p&gt;Let us list some bare minimum needed tools and technologies to learn Ethereum Blockchain Development.&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;&lt;u&gt;&lt;strong&gt;Javascript&lt;/strong&gt;&lt;/u&gt;&lt;/em&gt;
Javascript is a very versatile programming language. It can be used almost everywhere hence making it an indispensable part of blockchain development. Mainly react.js, node.js, express.js, and web3.js libraries of Javascript are needed in blockchain development.
&lt;p&gt;
Note : We can also use Python in place of Javascript and the web3.py library of python instead of web3.js. But javascript is recommended.&lt;br&gt;
&lt;/p&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;&lt;u&gt;Solidity&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;
Smart contract is a computer program or a transaction protocol that is intended to automatically execute, control or document events and actions according to the terms of a contract or an agreement written in Solidity language. &lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;In short, solidity is the coding language that one has to learn to become an Ethereum blockchain developer.&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;&lt;u&gt;Truffle&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;
Truffle is a world-class development environment, testing framework and asset pipeline for blockchains using the Ethereum Virtual Machine (EVM), aiming to make life as a developer easier. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;&lt;u&gt;Ganache&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;
Ganache is used for setting up a personal Ethereum Blockchain for testing your Solidity contracts. It provides more features when compared to Remix. You will learn about the features when you work out with Ganache.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;&lt;u&gt;Metamask&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt; 
Metamask is a cryptocurrency wallet that is available as a browser extension. Since web3 applications are not compatible to run with our normal browser, metamask overcomes this threshold. You will be learning about metamask more as you go forward. &lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Learning all these technologies with project-based implementation will make your blockchain journey far ahead of many developers because there are only 1% (roughly) blockchain developers available among all 18 million developers. &lt;/p&gt;

&lt;p&gt;Now, I will suggest 3 courses for Ethereum Blockchain Development which I find great.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.udemy.com/course/blockchain-developer/" rel="noopener noreferrer"&gt;Ethereum Blockchain Developer Bootcamp With Solidity (2022)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;This is a paid course but the authors are great tutors and all course materials got updated on a regular basis. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.udemy.com/course/ethereum-development-course-blockchain-at-berkeley/" rel="noopener noreferrer"&gt;Ethereum Development Course - Blockchain at Berkeley&lt;/a&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqoycicow6y2221un10kd.png" alt="Course3"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a freely available course on Udemy offered by Blockchain at Berkley.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.coursera.org/specializations/blockchain" rel="noopener noreferrer"&gt;Blockchain Specialization&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;This is again a paid course but you can apply for financial aid on Coursera and your financial aid will be cleared within 15 days. &lt;a href="https://blockchain-hacks-siddharth-singh.netlify.app/" rel="noopener noreferrer"&gt;Click here to know how to apply for the financial aid&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Writer's Support
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you find the article useful show some love ❤️ by following me on linkedin or github or instagram or everywhere 🤩.

&lt;p&gt;
&lt;a href="https://twitter.com/SidharthSing20" rel="noopener noreferrer"&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FTwitter-1DA1F2%3Fstyle%3Dfor-the-badge%26logo%3Dtwitter%26logoColor%3Dwhite"&gt;
&lt;/a&gt;
&lt;a href="https://www.linkedin.com/in/siddharth-singh-baghel-912866190/" rel="noopener noreferrer"&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FLinkedIn-0077B5%3Fstyle%3Dfor-the-badge%26logo%3Dlinkedin%26logoColor%3Dwhite"&gt;
&lt;/a&gt;
&lt;a href="https://github.com/Siddharth-sing" rel="noopener noreferrer"&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FGitHub-100000%3Fstyle%3Dfor-the-badge%26logo%3Dgithub%26logoColor%3Dwhite"&gt;
&lt;/a&gt;
&lt;a href="https://dev.to/siddharthsing"&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2Fdev.to-0A0A0A%3Fstyle%3Dfor-the-badge%26logo%3Ddev.to%26logoColor%3Dwhite"&gt;
&lt;/a&gt;
&lt;a href="https://www.instagram.com/i_m_siddharth.singh/" rel="noopener noreferrer"&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FInstagram-E4405F%3Fstyle%3Dfor-the-badge%26logo%3Dinstagram%26logoColor%3Dwhite"&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blockchain</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Wait, what and why Blockchain ? 🤔</title>
      <dc:creator>Siddharth Singh Baghel </dc:creator>
      <pubDate>Tue, 22 Nov 2022 10:13:51 +0000</pubDate>
      <link>https://dev.to/siddharthsing/blockchain-bitcoin-ethereum-why-should-one-care--1naa</link>
      <guid>https://dev.to/siddharthsing/blockchain-bitcoin-ethereum-why-should-one-care--1naa</guid>
      <description>&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Why should one care about blockchain, crypto, bitcoin etc. ? &lt;/li&gt;
&lt;li&gt;What is Blockchain ?&lt;/li&gt;
&lt;li&gt;What is Bitcoin ?&lt;/li&gt;
&lt;li&gt;Is Bitcoin and Blockchain are same ?&lt;/li&gt;
&lt;li&gt;Ethereum : A programmable Blockchain&lt;/li&gt;
&lt;li&gt;Bitcoin vs Ethereum&lt;/li&gt;
&lt;li&gt;Writer's Support ❤️&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why should one care about blockchain, crypto, bitcoin etc. ?
&lt;/h2&gt;

&lt;p&gt;Okay, before you stop reading the article, quickly check below the two graphs pinned and imagine if you become an Ethereum Blockchain Developer now then how much you be earning in 2025 🤩🔥&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q2XkVXnM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4o380g69kg6xl6ys9e82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q2XkVXnM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4o380g69kg6xl6ys9e82.png" alt="Crypto investment graph" width="800" height="569"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above image shows how massively the world is investing in cryptocurrencies (Bitcoin, Ethereum, DogeCoin, etc.). The research done by &lt;code&gt;statista.com&lt;/code&gt; clearly depicts that in 2021, &lt;strong&gt;32.5 Billion US Dollars&lt;/strong&gt; were invested in cryptocurrencies 🤯.&lt;/p&gt;

&lt;p&gt;And I will not be exaggerating if I say it's just the beginning 🤔. Let me present you with another graph to prove this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PyKKvvBp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3aw1ekdf8rjoiepbjpbu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PyKKvvBp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3aw1ekdf8rjoiepbjpbu.png" alt="crypto vs internet graph" width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looking at the comparison above, remember the times (1983 - if you are old enough 😶) when the internet was a big buzzing word around. A lot of rumors and grapevine surrounding the whole world, and then see today in 2022, we can live without food the whole day but without the internet 🤔... no chance. The same goes with blockchain, it's gaining popularity much faster than the internet. Hence anyone investing their time in learning blockchain might create new Google or Microsoft in 2030 or earlier 🤔.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Blockchain ?
&lt;/h2&gt;

&lt;p&gt;The simplest definition of blockchain suggests that it is a decentralized public ledger that helps in recording all transactions throughout multiple computers. One of the biggest highlights of blockchain technology is that the network does not have any central point.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7XnlFH-3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/56ite3dphf3ceq4qcpxl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7XnlFH-3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/56ite3dphf3ceq4qcpxl.png" alt="Blockchain Image" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Simply put together it is a much more secure database that is not centralized to any one authority but is distributed in peer-to-peer nodes(Computer systems).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For example, all your personal details are centralized in the bank's database. Suppose your bank compromised its security then  you and thousands of clients become fragile for the spammers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;But in blockchain, your data is decentralized that is not present in the bank's database in one place rather it is distributed over a network which is completely immutable and hence almost impossible to attack.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;br&gt;
&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Bitcoin ? Is Bitcoin and Blockchain are same ?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--julXDUpr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/69bb3fqdn0vgrgnrr1nw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--julXDUpr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/69bb3fqdn0vgrgnrr1nw.png" alt="Bitcoin" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Bitcoin and blockchain are not the same.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I often listen to the analogy that blockchain and bitcoin are the same but it is not true. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The concept of a blockchain was first fully actualized in Satoshi Nakamoto's 🥷 Bitcoin Whitepaper, the underlying component technologies draw from years of research across cryptography, computing, and economics.&lt;/li&gt;
&lt;li&gt;Hence, Bitcoin is a product(cryptocurrency) of blockchain similar as Ether(for Ethereum), Dogecoin etc. . &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Ethereum : A programmable Blockchain
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e6XZxNQ6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ee42ul9gl3o85ia7sfy5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e6XZxNQ6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ee42ul9gl3o85ia7sfy5.png" alt="ETHER" width="295" height="631"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ethereum (Ether) is the second most expensive and valuable cryptocurrency besides Bitcoin. &lt;/p&gt;

&lt;p&gt;That's it just another cryptocurrency 🤷 ... No Ethereum is much more powerful.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;EVM - Ethereum Virtual Machine is often referred to as a world computer for decentralized applications (dApps). &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ethereum is a platform on which anyone can build decentralized applications, where every program and action is universally accessible and verifiable because everything happens on the global Ethereum blockchain (mainnet). &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The feature of Ethereum that makes it so extensible is that it is a &lt;strong&gt;programmable blockchain&lt;/strong&gt;. It is similar to a programmable distributed ledger, where everyone agrees to run the same applications with the same data.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The main Ethereum blockchain is permissionless, meaning anyone can join the network.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Hence when we are talking about blockchain development we basically mean &lt;a href="https://consensys.net/developers/quickstart-and-tutorials/#tutorials"&gt;Ethereum Blockchain Development&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Bitcoin vs Ethereum
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h7ivZt7M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rdq1pmbngmh2ab3e2lne.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h7ivZt7M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rdq1pmbngmh2ab3e2lne.jpg" alt="Image description" width="800" height="1115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The comparison above shows precisely the differences between Bitcoin and Ethereum.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt; &lt;/p&gt;
&lt;h2&gt;
  
  
  Writer's Support
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you find the article useful show some love ❤️ by following me on linkedin or github or instagram or everywhere 🤩.

&lt;p&gt;
&lt;a href="https://www.linkedin.com/in/siddharth-singh-baghel-912866190/"&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bpeFljpm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://img.shields.io/badge/LinkedIn-0077B5%3Fstyle%3Dfor-the-badge%26logo%3Dlinkedin%26logoColor%3Dwhite" width="107" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://github.com/Siddharth-sing"&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X0Hgo7Mj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://img.shields.io/badge/GitHub-100000%3Fstyle%3Dfor-the-badge%26logo%3Dgithub%26logoColor%3Dwhite" width="92" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://dev.to/siddharthsing"&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xz2MGu8c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://img.shields.io/badge/dev.to-0A0A0A%3Fstyle%3Dfor-the-badge%26logo%3Ddev.to%26logoColor%3Dwhite" width="88" height="28"&gt;
&lt;/a&gt;
&lt;a href="https://www.instagram.com/i_m_siddharth.singh/"&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AO81Hx6l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://img.shields.io/badge/Instagram-E4405F%3Fstyle%3Dfor-the-badge%26logo%3Dinstagram%26logoColor%3Dwhite" width="121" height="28"&gt;
&lt;/a&gt;

&lt;/p&gt;


&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blockchain</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Hello Python (Voice Assistant) - For Windows Users</title>
      <dc:creator>Siddharth Singh Baghel </dc:creator>
      <pubDate>Thu, 15 Sep 2022 10:24:29 +0000</pubDate>
      <link>https://dev.to/siddharthsing/hello-python-voice-assistant-4g45</link>
      <guid>https://dev.to/siddharthsing/hello-python-voice-assistant-4g45</guid>
      <description>&lt;h2&gt;
  
  
  App's Overview
&lt;/h2&gt;




&lt;ul&gt;
&lt;li&gt;In this tutorial, we will be going through a voice assistant build with python for beginners. Prerequisites for reading this article are basic knowledge of python and python package importing.

&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Project Setup &lt;/li&gt;
&lt;li&gt;Imports &amp;amp; package installation&lt;/li&gt;
&lt;li&gt;Features and more&lt;/li&gt;
&lt;li&gt;GitHub Repo &lt;/li&gt;
&lt;li&gt;Writer's Support ❤️&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I have used the VS code editor for this project. PyCharm is also equally recommended, it depends upon your personal choice which among the two to choose. But other than these two I won't strongly recommend any editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a file &lt;code&gt;my_assistant.py&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Imports &amp;amp; Packages Installation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;We will be using various python packages for creating our smart assistant. Some of them need to be installed while some are pre-installed packages.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;The imports visible in the above image are the brain cells of our assistant 😁. &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;pyttsx3&lt;/strong&gt; - The most important package is &lt;code&gt;pyttsx3&lt;/code&gt;.&lt;br&gt;
 it is a &lt;strong&gt;&lt;em&gt;text-to-speech conversion&lt;/em&gt;&lt;/strong&gt; library in Python. Unlike alternative libraries, it works offline and is compatible with both Python 2 and 3.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## to download the package, write it in the terminal

pip install pyttsx3

## to import write this in my_assistant.py

import pyttsx3 

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

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;speech_recognition&lt;/strong&gt; - It allows computers to understand human language. Speech recognition is a machine's ability to listen to spoken words and identify them.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## to download the package, write it in the terminal

pip install SpeechRecognition

## to import write this in my_assistant.py

import speech_recognition as sr 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;wikipedia&lt;/strong&gt; - Wikipedia is a Python library that makes it easy to access and parse data from Wikipedia. Search Wikipedia, get article summaries, get data like links and images from a page, and more.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## to download the package, write it in the terminal

pip install wikipedia

## to import write this in my_assistant.py

import wikipedia as wk 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;datetime&lt;/strong&gt; - For accessing date and time.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## to import write this in my_assistant.py

import datetime as dt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;webbrowser&lt;/strong&gt; - For accessing the browser.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## to import write this in my_assistant.py

import webbrowser as wb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;os&lt;/strong&gt; - For accessing operating system's operations.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## to import write this in my_assistant.py

import os
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Features and More
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;This can be extended immensely as per the developer's interest. I have provided basic steps with a few features in this tutorial. But you can fork the GitHub Repo  for various features.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Feature - 1 (Listening)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;We will make our assistant listen us firstly 😁 .&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;takeCommand()&lt;/code&gt; function is ears for our assistant.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def takeCommand():
    r = sr.Recognizer()  # sr-&amp;gt; speech_recognition
    with sr.Microphone() as source:
        r.adjust_for_ambient_noise(source)  # for cancelling the backgroud noise 
        r.pause_threshold = 1
        print("Listening...")
        maudio = r.listen(source)

    print("Listened")   
    try: 
        print("Recognizing...")
        query = r.recognize_google(maudio, language = 'en-in')  # this step will recogize the text you spoke and store it into var query

    except Exception as e:
        query = "Say that again please!"

    return query        
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Now, you can use the &lt;code&gt;query&lt;/code&gt; returned from &lt;code&gt;takeCommand()&lt;/code&gt; for various tasks.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Feature - 2 (speaking)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It's time for our assistant to respond, because conversation must be two sided. 😊&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;speakBaby()&lt;/code&gt; function will let our assistant speak.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def speakBaby(audio):
    engine = pyttsx3.init('sapi5')  # learn more about sapi5 in pyttsx3 documentation 
    voices = engine.getProperty('voices') # for getting all the voices (male and female)
    engine.setProperty('voice', voices[1].id) # set a voice with your choice
    engine.say(audio)
    engine.runAndWait()

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

&lt;/div&gt;

&lt;h3&gt;
  
  
  Feature - 3 (Wishing)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;wishMe()&lt;/code&gt; function allows our assistant to wish us according to the time of the day.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def wishMe():
    hour = int(dt.datetime.now().hour)
    if hour in range(0,12):
        speakBaby("Good morning Sid .. How may I help you !")
    elif hour in range(12,17):
        speakBaby("Good Afternoon Sid .. How may I help you !")
    else:
        speakBaby("Good Evening Sid .. How may I help you !")        
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;We used &lt;code&gt;speakBaby()&lt;/code&gt; for our assistant to speak out time.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Note : These are the basic features for a working assistant and for more features checkout the GitHub repo attached below. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Siddharth-sing" rel="noopener noreferrer"&gt;
        Siddharth-sing
      &lt;/a&gt; / &lt;a href="https://github.com/Siddharth-sing/Python_Talks" rel="noopener noreferrer"&gt;
        Python_Talks
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Voice-Assistant-Python&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://dev.to/siddharthsing/hello-python-voice-assistant-4g45" rel="nofollow"&gt;&lt;br&gt;
  &lt;img src="https://camo.githubusercontent.com/1acec6bc44a5c4bc5f0b0fd5894f79683f95be00b9fdffea50be6ebd259fa71a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6465762e746f2d3041304130413f7374796c653d666f722d7468652d6261646765266c6f676f3d6465762e746f266c6f676f436f6c6f723d7768697465" height="200px" width="500px"&gt;&lt;br&gt;
 &lt;/a&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;App's Overview&lt;/h1&gt;
&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In this tutorial, we will be going through a voice assistant build with python for beginners. Prerequisites for reading this article are basic knowledge of python and python package importing.&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Table Of Content&lt;/h1&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Python_Talks#setup" rel="noopener noreferrer"&gt;Project Setup &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Python_Talks#imports" rel="noopener noreferrer"&gt;Imports &amp;amp; package installation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Python_Talks#features" rel="noopener noreferrer"&gt;Features and more&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Python_Talks#github" rel="noopener noreferrer"&gt;GitHub Repo &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Python_Talks#support" rel="noopener noreferrer"&gt;Writer's Support ❤️&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Project Setup&lt;/h1&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;I have used the VS code editor for this project. PyCharm is also equally recommended, it depends upon your personal choice which among the two to choose. But other than these two I won't strongly recommend any editor.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a file &lt;code&gt;my_assistant.py&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Imports &amp;amp; Packages Installation&lt;/h1&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;We will be using various python packages for creating our smart assistant. Some of them need to be installed while some are pre-installed packages.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/261a7a67ac804617220773c5147d7e892a1876af7091caeffaf93c427e69126b/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f75706c6f6164732f61727469636c65732f73623537677377773239643731703633347972642e706e67"&gt;&lt;img src="https://camo.githubusercontent.com/261a7a67ac804617220773c5147d7e892a1876af7091caeffaf93c427e69126b/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f75706c6f6164732f61727469636c65732f73623537677377773239643731703633347972642e706e67" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The imports visible in the above image are the brain cells of our assistant 😁.&lt;/li&gt;
&lt;/ul&gt;


&lt;blockquote&gt;

&lt;p&gt;&lt;strong&gt;pyttsx3&lt;/strong&gt; - The most important package is &lt;code&gt;pyttsx3&lt;/code&gt;
it is a …&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Siddharth-sing/Python_Talks" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
 

&lt;p&gt;&lt;a&gt;&lt;/a&gt; &lt;/p&gt;
&lt;h2&gt;
  
  
  Writer's Support
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you find the article useful show some ❤️ by staring some of my repositories and following me on dev.to and github.

&lt;p&gt;
&lt;a href="https://www.linkedin.com/in/siddharth-singh-baghel-912866190/" rel="noopener noreferrer"&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FLinkedIn-0077B5%3Fstyle%3Dfor-the-badge%26logo%3Dlinkedin%26logoColor%3Dwhite"&gt;
&lt;/a&gt;
&lt;a href="https://github.com/Siddharth-sing" rel="noopener noreferrer"&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FGitHub-100000%3Fstyle%3Dfor-the-badge%26logo%3Dgithub%26logoColor%3Dwhite"&gt;
&lt;/a&gt;
&lt;a href="https://dev.to/siddharthsing"&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2Fdev.to-0A0A0A%3Fstyle%3Dfor-the-badge%26logo%3Ddev.to%26logoColor%3Dwhite"&gt;
&lt;/a&gt;

&lt;/p&gt;


&lt;/li&gt;

&lt;/ul&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Swipe to delete from Cloud Firestore Database</title>
      <dc:creator>Siddharth Singh Baghel </dc:creator>
      <pubDate>Sun, 05 Dec 2021 18:11:32 +0000</pubDate>
      <link>https://dev.to/siddharthsing/swipe-to-delete-from-cloud-firestore-database-3fpj</link>
      <guid>https://dev.to/siddharthsing/swipe-to-delete-from-cloud-firestore-database-3fpj</guid>
      <description>&lt;h1&gt;
  
  
  Click on he below link to view the full article 😊
&lt;/h1&gt;

&lt;p&gt;👉 &lt;a href="https://dev.to/siddharthsing/swipe-to-delete-archive-etc-from-cloud-firestore-with-recyclerview-2ok3"&gt;Article&lt;/a&gt; &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Swipe to delete, archive etc from Cloud Firestore with RecyclerView</title>
      <dc:creator>Siddharth Singh Baghel </dc:creator>
      <pubDate>Sun, 05 Dec 2021 18:09:49 +0000</pubDate>
      <link>https://dev.to/siddharthsing/swipe-to-delete-archive-etc-from-cloud-firestore-with-recyclerview-2ok3</link>
      <guid>https://dev.to/siddharthsing/swipe-to-delete-archive-etc-from-cloud-firestore-with-recyclerview-2ok3</guid>
      <description>&lt;h1&gt;
  
  
  App's Overview
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In this article I am gonna take you through the development of &lt;br&gt;
Swipe Delete Feature, specifically we are going to delete the &lt;br&gt;
data present in Cloud Firestore Database in just a swipe.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sounds amazing, yes it is amazing, let's start :&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/sG1O5zXQJQI"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;u&gt;Note&lt;/u&gt;:
&lt;/h3&gt;


&lt;p&gt;The article only contains the explanation of "swipe to delete" feature, firebase implementation and UI details are not discussed, but I will provide the GitHub from which you can easily go through the complete code of the app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Dependencies Setup &lt;/li&gt;
&lt;li&gt;Code Explanation&lt;/li&gt;
&lt;li&gt;Full code - GitHub Repo &lt;/li&gt;
&lt;li&gt;Writer's Support ❤️&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Dependencies Setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I have used an external library to create and decorate the swipe to delete feature, it is called &lt;a href="https://github.com/xabaras/RecyclerViewSwipeDecorator" rel="noopener noreferrer"&gt;RecyclerViewSwipeDecorator&lt;/a&gt;.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies{

   implementation 'it.xabaras.android:recyclerview-swipedecorator:1.2.3'

}

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

&lt;/div&gt;


&lt;p&gt;&lt;a&gt;&lt;/a&gt; &lt;/p&gt;
&lt;h2&gt;
  
  
  Code Explanation
&lt;/h2&gt;




&lt;ul&gt;
&lt;li&gt;Create an &lt;code&gt;ItemTouchHelper.SimpleCallback&lt;/code&gt;, instantiate an
&lt;code&gt;ItemTouchHelper&lt;/code&gt; with this callback.&lt;/li&gt;
&lt;li&gt;Copy the code snippet below 👇&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Reference - &lt;a href="https://github.com/Siddharth-sing/Swipe-delete-from-firebase-/blob/a253f5ea2286ff2ed7c97edacb3046fae18b4ba1/app/src/main/java/com/siddharthsinghbaghel/swipedeletefirebase/ListActivity.kt#L54" rel="noopener noreferrer"&gt;ListActivity.kt&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

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

   -&amp;gt; `SimpleCallback` gives us option to tell about the swipe 
       direction.

   -&amp;gt; `ItemTouchHelper.RIGHT or ItemTouchHelper.LEFT`

*/

   val callback: ItemTouchHelper.SimpleCallback = object :

            ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT or ItemTouchHelper.LEFT) {

            override fun onMove(

                recyclerView: RecyclerView,

                viewHolder: RecyclerView.ViewHolder,

                target: RecyclerView.ViewHolder

            ): Boolean {

                return false

            }

            override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {


               //Take action for swiped direction 

               //Delete on swipe left

               //Archive on swipe right

              //Customise according to your mood

         }

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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Now let us attach our &lt;code&gt;ItemTouchHelper&lt;/code&gt; with the &lt;code&gt;RecyclerView&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy the below 👇 code snippet just outside &lt;code&gt;callback&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;val itemTouchHelper = ItemTouchHelper(callback)

        itemTouchHelper.attachToRecyclerView(rv)

/* rv - replace with your  recycler view variable name */

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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;The above code is sufficient for the swipe to delete feature. It will look something like below 👇 &lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To decorate our swipe feature we will override &lt;code&gt;onChildDraw&lt;/code&gt; method. This method has various functions, some of them will be discussed in this article others you can explore &lt;a href="https://github.com/xabaras/RecyclerViewSwipeDecorator#customizing" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Override &lt;code&gt;onChildDraw&lt;/code&gt; method below &lt;code&gt;onSwiped&lt;/code&gt; method.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy the below code snippet👇&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) {



                RecyclerViewSwipeDecorator.Builder(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)

                    .addBackgroundColor(

                        ContextCompat.getColor(

                            this@ListActivity,

                            android.R.color.holo_red_light

                        )

                    )

                    .addActionIcon(R.drawable.ic_baseline_delete_sweep_24)  // add any icon of your choice

                    .addSwipeRightLabel("Deleting the Item") //Label according to your choice

                    .addSwipeLeftLabel("Deleting the Item")

                    .setSwipeRightLabelColor(R.color.white) // behind color on  swiping

                    .setSwipeLeftLabelColor(R.color.white)
                    .create()
                    .decorate()

                super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)

            }



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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;That's all now you can see the magic 😇&lt;/li&gt;
&lt;/ul&gt;



&lt;br&gt;
&lt;a&gt;&lt;/a&gt; 
&lt;h2&gt;
  
  
  GitHub Repository
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Fork the repository for better and easy understanding and for quick learning.
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Siddharth-sing" rel="noopener noreferrer"&gt;
        Siddharth-sing
      &lt;/a&gt; / &lt;a href="https://github.com/Siddharth-sing/Swipe-delete-from-firebase-" rel="noopener noreferrer"&gt;
        Swipe-delete-from-firebase-
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      This app will demonstrate the swipe to delete from firebase feature.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Article is on dev.to click below 👇&lt;/h2&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://dev.to/siddharthsing/swipe-to-delete-archive-etc-from-cloud-firestore-with-recyclerview-2ok3" rel="nofollow"&gt;&lt;br&gt;
  &lt;img src="https://camo.githubusercontent.com/1acec6bc44a5c4bc5f0b0fd5894f79683f95be00b9fdffea50be6ebd259fa71a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6465762e746f2d3041304130413f7374796c653d666f722d7468652d6261646765266c6f676f3d6465762e746f266c6f676f436f6c6f723d7768697465" height="200px" width="500px"&gt;&lt;br&gt;
 &lt;/a&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;App's Overview&lt;/h1&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;In this article I am gonna take you through the development of
Swipe Delete Feature, specifically we are going to delete the
data present in Cloud Firestore Database in just a swipe.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sounds amazing, yes it is amazing, let's start :&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=sG1O5zXQJQI&amp;amp;ab_channel=SiddharthSinghBaghel" rel="nofollow noopener noreferrer"&gt;&lt;br&gt;
 &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F72120258%2F144758938-c13eb496-55f4-482c-adc7-dca17293ebdc.jpg" alt="Watch the video" width="800" height="400"&gt;&lt;br&gt;
&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Note:&lt;/h3&gt;
&lt;/div&gt;

&lt;p&gt;The article only contains the explanation of "swipe to delete" feature, firebase implementation and UI details are not discussed, but I will provide the GitHub from which you can easily go through the complete code of the app.&lt;/p&gt;



&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Table Of Content&lt;/h2&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Swipe-delete-from-firebase-#setup" rel="noopener noreferrer"&gt;Dependencies Setup &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Swipe-delete-from-firebase-#code" rel="noopener noreferrer"&gt;Code Explanation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Swipe-delete-from-firebase-#GitHub" rel="noopener noreferrer"&gt;Full code - GitHub Repo &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Swipe-delete-from-firebase-#support" rel="noopener noreferrer"&gt;Writer's Support ❤️&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
##Dependencies Setup&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I have used an external library to create and decorate the swipe to delete feature, it is called &lt;a href="https://github.com/xabaras/RecyclerViewSwipeDecorator" rel="noopener noreferrer"&gt;RecyclerViewSwipeDecorator&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;dependencies{

   implementation 'it.xabaras.android:recyclerview-swipedecorator:1.2.3'

}

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

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Code Explanation&lt;/h2&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Create an &lt;code&gt;ItemTouchHelper.SimpleCallback&lt;/code&gt;, instantiate an
&lt;code&gt;ItemTouchHelper&lt;/code&gt; with this callback.&lt;/li&gt;
&lt;li&gt;Copy the code snippet below 👇&lt;/li&gt;
&lt;/ul&gt;


&lt;blockquote&gt;

&lt;p&gt;Reference -…&lt;/p&gt;


&lt;/blockquote&gt;
&lt;/div&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Siddharth-sing/Swipe-delete-from-firebase-" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;

&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Writer's Support
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you find the article useful show some ❤️ by staring at some of my repositories and following me on dev.to and github.

&lt;p&gt;
&lt;a href="https://www.linkedin.com/in/siddharth-singh-baghel-912866190/" rel="noopener noreferrer"&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FLinkedIn-0077B5%3Fstyle%3Dfor-the-badge%26logo%3Dlinkedin%26logoColor%3Dwhite"&gt;
&lt;/a&gt;
&lt;a href="https://github.com/Siddharth-sing" rel="noopener noreferrer"&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FGitHub-100000%3Fstyle%3Dfor-the-badge%26logo%3Dgithub%26logoColor%3Dwhite"&gt;
&lt;/a&gt;
&lt;a href="https://dev.to/siddharthsing"&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2Fdev.to-0A0A0A%3Fstyle%3Dfor-the-badge%26logo%3Ddev.to%26logoColor%3Dwhite"&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>kotlin</category>
      <category>android</category>
      <category>firebase</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Simple Country Code Picker For Android In Kotlin</title>
      <dc:creator>Siddharth Singh Baghel </dc:creator>
      <pubDate>Mon, 25 Oct 2021 09:52:19 +0000</pubDate>
      <link>https://dev.to/siddharthsing/simple-country-code-picker-for-android-in-kotlin-5aeo</link>
      <guid>https://dev.to/siddharthsing/simple-country-code-picker-for-android-in-kotlin-5aeo</guid>
      <description>&lt;h2&gt;
  
  
  App's Overview
&lt;/h2&gt;




&lt;ul&gt;
&lt;li&gt;In this article, I am going to demonstrate how to create a simple country code picker in an android application through Kotlin. &lt;/li&gt;
&lt;/ul&gt;




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

&lt;h2&gt;
  
  
  Table Of Content
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Project Setup &lt;/li&gt;
&lt;li&gt;Building the app's UI &lt;/li&gt;
&lt;li&gt;Creating the Backend of the app&lt;/li&gt;
&lt;li&gt;GitHub Repo &lt;/li&gt;
&lt;li&gt;Writer's Support ❤️&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add the below line of code in &lt;code&gt;build.gradle (project)&lt;/code&gt; under &lt;code&gt;allprojects&lt;/code&gt;.
```
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;maven { url "&lt;a href="https://jitpack.io" rel="noopener noreferrer"&gt;https://jitpack.io&lt;/a&gt;" }&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The code snippet will look like the one below :
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;allprojects {&lt;br&gt;
    repositories {&lt;br&gt;
        google()&lt;br&gt;
        jcenter()&lt;br&gt;
        maven { url "&lt;a href="https://jitpack.io" rel="noopener noreferrer"&gt;https://jitpack.io&lt;/a&gt;" }  /* changed file */&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* Dependency to be added : Add the dependency below in `build.gradle (Module)`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;implementation 'com.github.joielechong:countrycodepicker:2.4.2'&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
The code snippet will look like the one below :
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;dependencies {&lt;/p&gt;

&lt;p&gt;...&lt;br&gt;
    other dependencies&lt;br&gt;&lt;br&gt;
   ...&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Country Code Picker Dependency*/
implementation 'com.github.joielechong:countrycodepicker:2.4.2'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;}&lt;/p&gt;


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

&amp;lt;a name="UI"&amp;gt;&amp;lt;/a&amp;gt;
##App's UI

The app's UI is broken into two parts :

1. [Explanation of Country Code Picker (ccp)](#expCCP)
2. [Complete `.xml` code file (activity_main.xml)](#xml)

&amp;lt;a name="expCCP"&amp;gt;&amp;lt;/a&amp;gt;
&amp;gt; Explanation of ccp :

* The below code snippet shows the implementation of the country code picker through the `.xml` file. The below code snippet is not customized, it is the naive form of ccp but it will work completely fine in the android application. We shall see the customization in the next section of the blog.

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

&lt;/div&gt;


&lt;p&gt;
            android:id="@+id/ccp"&lt;br&gt;
            android:layout_width="wrap_content"&lt;br&gt;
            android:layout_height="wrap_content"&lt;br&gt;
            android:padding="16dp"&lt;br&gt;
            /&amp;gt;&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
* Customization of ccp in .xml file

   1. **`app:ccp_defaultNameCode="IN"`** - `ccp_defaultNameCode` attribute will set the the default country of the ccp spinner.

   2. **`app:ccp_defaultCode="91"`** - `ccp_defaultCode` will similarly set the default country code in the spinner.

   3. **`app:ccp_textColor="#1C2020"`** - change the color of ccp according to app's theme with `ccp_textColor` attritubute.

   4. **`app:ccp_countryPreference="IN,US,NZ"`** - `ccp_countryPreference` will set some of the preferred countries on the top, so that they will be easily accessed. See the example image below :

![Preference Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y8ol5ocnb1kcwky8tqtx.png)

The customized code snippet :

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

&lt;/div&gt;


&lt;p&gt;
            android:id="@+id/ccp"&lt;br&gt;
            android:layout_width="wrap_content"&lt;br&gt;
            android:layout_height="wrap_content"&lt;br&gt;
            app:ccp_defaultNameCode="IN"&lt;br&gt;
            app:ccp_defaultCode="91"&lt;br&gt;
            app:ccp_textColor="#1C2020"&lt;br&gt;
            android:padding="16dp"&lt;br&gt;
            app:ccp_countryPreference="IN,US,NZ"/&amp;gt;&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;There are many attributes present in order to customize the ccp, you can get to know about them all in it's documentation [here](https://github.com/joielechong/CountryCodePicker).

&amp;lt;a name="xml"&amp;gt;&amp;lt;/a&amp;gt;
&amp;gt; Complete .xml file (activity_main.xml) :

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

&lt;/div&gt;


&lt;p&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br&gt;
&amp;lt;RelativeLayout xmlns:android="&lt;a href="http://schemas.android.com/apk/res/android" rel="noopener noreferrer"&gt;http://schemas.android.com/apk/res/android&lt;/a&gt;"&lt;br&gt;
    xmlns:app="&lt;a href="http://schemas.android.com/apk/res-auto" rel="noopener noreferrer"&gt;http://schemas.android.com/apk/res-auto&lt;/a&gt;"&lt;br&gt;
    xmlns:tools="&lt;a href="http://schemas.android.com/tools" rel="noopener noreferrer"&gt;http://schemas.android.com/tools&lt;/a&gt;"&lt;br&gt;
    android:layout_width="match_parent"&lt;br&gt;
    android:layout_height="match_parent"&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tools:context=".MainActivity"
&amp;gt;

&amp;lt;LinearLayout
    android:id="@+id/llPhone"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_centerInParent="true"

    &amp;gt;

    &amp;lt;com.rilixtech.widget.countrycodepicker.CountryCodePicker
        android:id="@+id/ccp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:ccp_defaultNameCode="IN"
        app:ccp_defaultCode="91"
        app:ccp_textColor="#1C2020"
        android:padding="16dp"
        app:ccp_countryPreference="IN,US,NZ"/&amp;gt;

    &amp;lt;EditText
        android:id="@+id/edtPhone"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="16dp"
        android:padding="15dp"
        android:hint="@string/enter_phone_number"
        android:importantForAutofill="no"
        android:inputType="number" /&amp;gt;

&amp;lt;/LinearLayout&amp;gt;
&amp;lt;Button
    android:id="@+id/btnSendOTP"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/llPhone"
    android:padding="15dp"
    android:layout_margin="16dp"
    android:text="Send OTP"
    android:textStyle="bold"
    /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&amp;lt;a name="back"&amp;gt;&amp;lt;/a&amp;gt; 
##App's Backend

* Let's first link all the UI components with `MainActivity.kt`

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

&lt;/div&gt;


&lt;p&gt;val ccp:CountryCodePicker = findViewById(R.id.ccp)&lt;br&gt;
val edtPhoneNumber: EditText = findViewById(R.id.edtPhone)&lt;br&gt;
val btnOTP: Button = findViewById(R.id.btnSendOTP)&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
* Tell ccp which edit text should be registered for phone numbers, use the below line of code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;ccp.registerPhoneNumberTextView(edtPhoneNumber)&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
* Now, let us create a function to check the validity of the phone number entered wrt the country code selected.

   **`ccp.isValid`** will check whether the phone number 
      is correct or not.

The function looks like :

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

&lt;/div&gt;


&lt;p&gt;private fun checkValidity(ccp: CountryCodePicker): Boolean {&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    return if(ccp.isValid) {
        Toast.makeText(this, "number " + ccp.fullNumber + " is valid.", Toast.LENGTH_SHORT).show()
        true
    } else {
        false
    }

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

&lt;/div&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
The function returns `true` if phone number entered is correct otherwise it will return `false`.

* Finally, at last we will handle the button click and we are done to see the magic.

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

&lt;/div&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;btnOTP.setOnClickListener{

        if(checkValidity(ccp))
        {
            //Change with your own functionality
            Toast.makeText(this, "OTP Sent", Toast.LENGTH_SHORT).show()

        }else{
            Toast.makeText(this, "Please enter a valid phone number", Toast.LENGTH_SHORT).show()
        }

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

&lt;/div&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;If the `checkValidity()` function returns true it will show a toast `OTP Sent`, you can change it with your function. 

If the phone number is wrong it will pitch an Incorrect Message toast.

---

&amp;lt;a name="GitHub"&amp;gt;&amp;lt;/a&amp;gt; 
##GitHub Repository
* Fork the repository for better and easy understanding and for quick learning.

&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Siddharth-sing" rel="noopener noreferrer"&gt;
        Siddharth-sing
      &lt;/a&gt; / &lt;a href="https://github.com/Siddharth-sing/Country-Code-Picker" rel="noopener noreferrer"&gt;
        Country-Code-Picker
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      An easy approach on how to create your country code picker for the edit text. 
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Country-Code-Picker&lt;/h1&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Original Article on Dev.to Click below 👇&lt;/h2&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://dev.to/siddharthsing/simple-country-code-picker-for-android-in-kotlin-5aeo" rel="nofollow"&gt;&lt;br&gt;
  &lt;img src="https://camo.githubusercontent.com/1acec6bc44a5c4bc5f0b0fd5894f79683f95be00b9fdffea50be6ebd259fa71a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6465762e746f2d3041304130413f7374796c653d666f722d7468652d6261646765266c6f676f3d6465762e746f266c6f676f436f6c6f723d7768697465" height="200px" width="500px"&gt;&lt;br&gt;
  &lt;/a&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;App's Overview&lt;/h2&gt;
&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;In this article, I am going to demonstrate how to create a simple country code picker in an android application through Kotlin.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Also, how to validate phone numbers for every country possible.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; 
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/ec94d314910b26b66a63052c0fd352737db03aee974c3113fa023a028cf857d2/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f75706c6f6164732f61727469636c65732f6b657a62656f32763374713378336677353538632e676966"&gt;&lt;img src="https://camo.githubusercontent.com/ec94d314910b26b66a63052c0fd352737db03aee974c3113fa023a028cf857d2/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f75706c6f6164732f61727469636c65732f6b657a62656f32763374713378336677353538632e676966" height="400px" width="700px"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Table Of Content&lt;/h2&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Country-Code-Picker#setup" rel="noopener noreferrer"&gt;Project Setup &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Country-Code-Picker#UI" rel="noopener noreferrer"&gt;Building the app's UI &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Country-Code-Picker#back" rel="noopener noreferrer"&gt;Creating the Backend of the app&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Country-Code-Picker#support" rel="noopener noreferrer"&gt;Writer's Support ❤️&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Project Setup&lt;/h2&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Add the below line of code in &lt;code&gt;build.gradle (project)&lt;/code&gt; under &lt;code&gt;allprojects&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;maven { url "https://jitpack.io" }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The code snippet will look like the one below :&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;
allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Dependency to be added : Add the dependency below in &lt;code&gt;build.gradle (Module)&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;implementation 'com.github.joielechong:countrycodepicker:2.4.2'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The code snippet will look like the one below :&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;dependencies {

   ...
    other dependencies   
   ...

    /* Country Code Picker Dependency*/
    implementation 'com.github.joielechong:countrycodepicker:2.4.2'
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;App's UI&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;The app's UI is broken into two parts…&lt;/p&gt;
&lt;/div&gt;


&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Siddharth-sing/Country-Code-Picker" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;

&lt;p&gt;&amp;lt;a name="support"&amp;gt;&amp;lt;/a&amp;gt; &lt;/p&gt;
&lt;h2&gt;
  
  
  Writer's Support
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you find the article useful show some ❤️ by staring some of my repositories and following me on dev.to and github.
&amp;lt;div&amp;gt;
&amp;lt;p align="middle"&amp;gt;
&amp;lt;a href="&lt;a href="https://www.linkedin.com/in/siddharth-singh-baghel-912866190/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/siddharth-singh-baghel-912866190/&lt;/a&gt;"&amp;gt;
&amp;lt;img src="&lt;a href="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&amp;amp;logo=linkedin&amp;amp;logoColor=white" rel="noopener noreferrer"&gt;https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&amp;amp;amp;logo=linkedin&amp;amp;amp;logoColor=white&lt;/a&gt;"&amp;gt;
&amp;lt;/a&amp;gt;
&amp;lt;a href="&lt;a href="https://github.com/Siddharth-sing" rel="noopener noreferrer"&gt;https://github.com/Siddharth-sing&lt;/a&gt;"&amp;gt;
&amp;lt;img src="&lt;a href="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&amp;amp;logo=github&amp;amp;logoColor=white" rel="noopener noreferrer"&gt;https://img.shields.io/badge/GitHub-100000?style=for-the-badge&amp;amp;amp;logo=github&amp;amp;amp;logoColor=white&lt;/a&gt;"&amp;gt;
&amp;lt;/a&amp;gt;
&amp;lt;a href="&lt;a href="https://dev.to/siddharthsing"&gt;https://dev.to/siddharthsing&lt;/a&gt;"&amp;gt;
&amp;lt;img src="&lt;a href="https://img.shields.io/badge/dev.to-0A0A0A?style=for-the-badge&amp;amp;logo=dev.to&amp;amp;logoColor=white"&gt;https://img.shields.io/badge/dev.to-0A0A0A?style=for-the-badge&amp;amp;amp;logo=dev.to&amp;amp;amp;logoColor=white&lt;/a&gt;"&amp;gt;
&amp;lt;/a&amp;gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;

</description>
      <category>kotlin</category>
      <category>android</category>
      <category>tutorial</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Android's Locker Screen Using Shared Preferences &amp; Material UI</title>
      <dc:creator>Siddharth Singh Baghel </dc:creator>
      <pubDate>Thu, 21 Oct 2021 20:30:09 +0000</pubDate>
      <link>https://dev.to/siddharthsing/androids-in-app-lock-screen-using-shared-preferences-material-ui-103</link>
      <guid>https://dev.to/siddharthsing/androids-in-app-lock-screen-using-shared-preferences-material-ui-103</guid>
      <description>&lt;h2&gt;
  
  
  App's Overview
&lt;/h2&gt;


&lt;p&gt;&lt;br&gt;
In this article, I am going to create a multi-screen yet simple application that will be demonstrating the best way to create lock screens for the apps using shared preferences and some material UI components.&lt;br&gt;&lt;br&gt;
&lt;/p&gt;


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


&lt;h2&gt;
  
  
  Steps to proceed
&lt;/h2&gt;


&lt;p&gt;&lt;br&gt;
We will be proceeding in a very beginner-friendly way. All the steps are mentioned below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Project Setup &lt;/li&gt;
&lt;li&gt;Building the app's UI &lt;/li&gt;
&lt;li&gt;Creating the Backend of the app&lt;/li&gt;
&lt;li&gt;GitHub Repo &lt;/li&gt;
&lt;li&gt;Writer's Support ❤️&lt;/li&gt;
&lt;/ul&gt;






&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First of all, create a brand new project in your android studio. Assuming that it will be an easy part, so not explaining all. 
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiu4ykvvoqn5g1prrfvrp.jpg" alt="Image description"&gt;
&lt;/li&gt;
&lt;li&gt;Then set up your emulator properly to check the application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we are good to go for next step.&lt;br&gt;
&lt;/p&gt;


&lt;h2&gt;
  
  
  Building the app's UI
&lt;/h2&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;br&gt;
  App's UI will be built in 4 steps :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Main Activity UI (activity_main.xml)&lt;/li&gt;
&lt;li&gt;Set Password Screen UI (activity_set_password.xml)&lt;/li&gt;
&lt;li&gt;PIN Entering screen UI (activity_password_type.xml)&lt;/li&gt;
&lt;li&gt;Screen open upon correct PIN UI (activity_welcome.xml)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;App's UI is built with some of the &lt;code&gt;material UI&lt;/code&gt; component for giving it a better look.&lt;/p&gt;

&lt;p&gt;Simply copy each and every &lt;code&gt;.xml&lt;/code&gt; file below and create the same into your project.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;activity_main.xml&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/p&gt;

&lt;p&gt;
    xmlns:app="http://schemas.android.com/apk/res-auto"&lt;br&gt;
    xmlns:tools="http://schemas.android.com/tools"&lt;br&gt;
    android:layout_width="match_parent"&lt;br&gt;
    android:layout_height="match_parent"&lt;br&gt;
    android:background="@drawable/backgroud"&lt;br&gt;
    android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar"&lt;br&gt;
    &amp;gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    android:layout_centerInParent="true"
    tools:context=".MainActivity"&amp;gt;

    &amp;lt;ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@drawable/ic_baseline_android_24"
        android:layout_marginBottom="4dp"
        /&amp;gt;
    &amp;lt;TextView
        android:id="@+id/tv_app_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Lock Up !"
        android:gravity="center"
        android:textSize="25sp"
        android:textStyle="bold"
        android:textColor="@color/gradientEnd"
        android:layout_marginBottom="26dp"
        android:letterSpacing="0.3"/&amp;gt;

    &amp;lt;androidx.cardview.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:layout_marginEnd="20dp"
        android:background="@color/white"
        app:cardCornerRadius="8dp"
        app:cardElevation="5dp"
        &amp;gt;
        &amp;lt;LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:padding="16dp"&amp;gt;

            &amp;lt;TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Welcome"
                android:gravity="center"
                android:textSize="30sp"
                android:textColor="#0091EA"
                android:textStyle="bold"/&amp;gt;
            &amp;lt;TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Please set the lock screen pin"
                android:gravity="center"
                android:textSize="16sp"
                android:textColor="#7A8089"
                android:textStyle="bold"/&amp;gt;
            &amp;lt;LinearLayout
                android:id="@+id/llLaunchScreen"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                tools:visibility="visible"
                android:padding="8dp"
                android:layout_centerInParent="true"
                &amp;gt;

                &amp;lt;androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:cardCornerRadius="50dp"

                    &amp;gt;
                    &amp;lt;LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        &amp;gt;
                    &amp;lt;Button
                        android:id="@+id/buttonSetPin"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:backgroundTint="@color/gradientStart"
                        android:text="Set/Change PIN"
                        android:padding="16dp"
                        android:textColor="#FFFFFF"
                        android:textStyle="bold"
                        /&amp;gt;
                    &amp;lt;Button
                        android:id="@+id/buttonTypePin"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:backgroundTint="@color/gradientStart"
                        android:text="Type Pin To get in"
                        android:padding="16dp"
                        android:textColor="#FFFFFF"
                        android:textStyle="bold"
                        /&amp;gt;
                    &amp;lt;/LinearLayout&amp;gt;
                &amp;lt;/androidx.cardview.widget.CardView&amp;gt;
            &amp;lt;/LinearLayout&amp;gt;

        &amp;lt;/LinearLayout&amp;gt;

    &amp;lt;/androidx.cardview.widget.CardView&amp;gt;

&amp;lt;/LinearLayout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a name="setA"&amp;gt;&amp;lt;/a&amp;gt;

&amp;gt;activity_set_password.xml

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

&lt;/div&gt;


&lt;p&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br&gt;
&amp;lt;RelativeLayout xmlns:android="&lt;a href="http://schemas.android.com/apk/res/android" rel="noopener noreferrer"&gt;http://schemas.android.com/apk/res/android&lt;/a&gt;"&lt;br&gt;
    android:layout_width="match_parent"&lt;br&gt;
    android:layout_height="match_parent"&lt;br&gt;
    xmlns:app="&lt;a href="http://schemas.android.com/apk/res-auto" rel="noopener noreferrer"&gt;http://schemas.android.com/apk/res-auto&lt;/a&gt;"&lt;br&gt;
    android:background="@drawable/backgroud"&lt;br&gt;
    android:orientation="vertical"&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;

&amp;lt;ImageView
    android:id="@+id/imgAnd"
    android:layout_width="170dp"
    android:layout_height="170dp"
    android:layout_marginTop="5dp"
    android:src="@drawable/ic_baseline_android_24"
    android:layout_centerHorizontal="true"
    /&amp;gt;
&amp;lt;com.google.android.material.textfield.TextInputLayout
    android:id="@+id/mtxtName"
    android:padding="18dp"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/imgAnd"
    &amp;gt;

    &amp;lt;androidx.appcompat.widget.AppCompatEditText
        android:id="@+id/edtName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter your Name"
        android:padding="18dp"
        android:textColorHint="@color/white"
        android:inputType="text"
        android:textSize="16sp"

        /&amp;gt;
&amp;lt;/com.google.android.material.textfield.TextInputLayout&amp;gt;

&amp;lt;com.google.android.material.textfield.TextInputLayout
    android:id="@+id/mtxtPass"
    android:padding="18dp"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/mtxtName"

    &amp;gt;

    &amp;lt;androidx.appcompat.widget.AppCompatEditText
        android:id="@+id/edtPass"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter your password"
        android:padding="18dp"
        android:textColorHint="@color/white"
        android:inputType="numberPassword"
        android:textSize="16sp"

        /&amp;gt;
&amp;lt;/com.google.android.material.textfield.TextInputLayout&amp;gt;

&amp;lt;Button
    android:id="@+id/btnSave"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:backgroundTint="@color/gradientEnd"
    android:text="Save Pin"
    android:padding="16dp"
    android:layout_margin="25dp"
    android:textColor="#FFFFFF"
    android:textStyle="bold"
    android:layout_below="@+id/mtxtPass"
    /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&amp;lt;a name="passA"&amp;gt;&amp;lt;/a&amp;gt;

&amp;gt;activity_password_type.xml

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

&lt;/div&gt;


&lt;p&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br&gt;

    xmlns:android="http://schemas.android.com/apk/res/android"&lt;br&gt;
    android:layout_width="match_parent"&lt;br&gt;
    android:layout_height="match_parent"&lt;br&gt;
    android:background="@drawable/backgroud"&lt;br&gt;
    android:orientation="vertical"&lt;br&gt;
    &amp;gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ImageView
    android:id="@+id/imgAnd"
    android:layout_width="170dp"
    android:layout_height="170dp"
    android:layout_marginTop="5dp"
    android:src="@drawable/ic_baseline_android_24"
    android:layout_centerHorizontal="true"
    /&amp;gt;
&amp;lt;com.google.android.material.textfield.TextInputLayout
    android:id="@+id/mtxtName"
    android:padding="18dp"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/imgAnd"
    &amp;gt;
&amp;lt;/com.google.android.material.textfield.TextInputLayout&amp;gt;

&amp;lt;TextView
    android:id="@+id/txtPass"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:layout_marginTop="215dp"
    android:textColor="#EDE8E8"
    android:textStyle="bold"
    android:letterSpacing="1.5"
    android:textSize="22dp"
    android:maxLength="4"
    android:inputType="numberPassword"
    android:text="1234" /&amp;gt;

&amp;lt;LinearLayout
    android:id="@+id/keyBoard"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_alignParentBottom="true"
    &amp;gt;

    &amp;lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        &amp;gt;

        &amp;lt;Button
            android:id="@+id/btn1"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="15dp"
            android:text="1"
            android:textColor="@color/white"
            android:textSize="18dp"
            android:textStyle="bold" /&amp;gt;

        &amp;lt;Button
            android:id="@+id/btn2"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="15dp"
            android:text="2"
            android:textColor="@color/white"
            android:textSize="18dp"
            android:textStyle="bold" /&amp;gt;

        &amp;lt;Button
            android:id="@+id/btn3"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="15dp"
            android:text="3"
            android:textColor="@color/white"
            android:textSize="18dp"
            android:textStyle="bold" /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;

    &amp;lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"&amp;gt;

        &amp;lt;Button
            android:id="@+id/btn4"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="15dp"
            android:text="4"
            android:textColor="@color/white"
            android:textSize="18dp"
            android:textStyle="bold" /&amp;gt;

        &amp;lt;Button
            android:id="@+id/btn5"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="15dp"
            android:text="5"
            android:textColor="@color/white"
            android:textSize="18dp"
            android:textStyle="bold" /&amp;gt;

        &amp;lt;Button
            android:id="@+id/btn6"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="15dp"
            android:text="6"
            android:textColor="@color/white"
            android:textSize="18dp"
            android:textStyle="bold" /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;

    &amp;lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"&amp;gt;

        &amp;lt;Button
            android:id="@+id/btn7"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="15dp"
            android:text="7"
            android:textColor="@color/white"
            android:textSize="18dp"
            android:textStyle="bold" /&amp;gt;

        &amp;lt;Button
            android:id="@+id/btn8"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="15dp"
            android:text="8"
            android:textColor="@color/white"
            android:textSize="18dp"
            android:textStyle="bold" /&amp;gt;

        &amp;lt;Button
            android:id="@+id/btn9"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="15dp"
            android:text="9"
            android:textColor="@color/white"
            android:textSize="18dp"
            android:textStyle="bold" /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;

    &amp;lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"&amp;gt;

        &amp;lt;ImageButton
            android:id="@+id/btnErase"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="22dp"
            android:src="@drawable/ic_baseline_arrow_back_ios_24"
            android:textColor="@color/white"
            android:textSize="18dp"
            android:textStyle="bold" /&amp;gt;

        &amp;lt;Button
            android:id="@+id/btn0"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="15dp"
            android:text="0"
            android:textColor="@color/white"
            android:textSize="18dp"
            android:textStyle="bold" /&amp;gt;

        &amp;lt;ImageButton
            android:id="@+id/btnCheck"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="22dp"
            android:src="@drawable/ic_baseline_check_24"
            android:textColor="@color/white"
            android:textSize="18dp"
            android:textStyle="bold" /&amp;gt;
    &amp;lt;/LinearLayout&amp;gt;


&amp;lt;/LinearLayout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&amp;lt;a name="welA"&amp;gt;&amp;lt;/a&amp;gt;

&amp;gt; activity_welcome.xml

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

&lt;/div&gt;


&lt;p&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br&gt;

    xmlns:app="http://schemas.android.com/apk/res-auto"&lt;br&gt;
    xmlns:tools="http://schemas.android.com/tools"&lt;br&gt;
    android:layout_width="match_parent"&lt;br&gt;
    android:layout_height="match_parent"&lt;br&gt;
    tools:context=".WelcomeActivity"&lt;br&gt;
    android:background="@drawable/backgroud"&amp;gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="WELCOME !"
    android:textColor="@color/white"
    android:textSize="56sp"
    android:layout_centerInParent="true"
    android:layout_centerHorizontal="true"
    android:textStyle="bold"
    android:letterSpacing="0.1"
    /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&amp;lt;a name="back"&amp;gt;&amp;lt;/a&amp;gt;

##App's Backend

Similar to the UI, the app's backend is also divided into four parts namely :

- [MainActivity.kt ](#mainB)
- [SetPasswordActivity.kt ](#setB)
- [PasswordTypeActivity.kt](#passB)
- [WelcomeActivity.kt](#welB)

&amp;lt;a name="mainB"&amp;gt;&amp;lt;/a&amp;gt;

&amp;gt; MainActivity.kt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;package com.siddharthsinghbaghel.sharedpreferences&lt;/p&gt;

&lt;p&gt;import android.content.Intent&lt;br&gt;
import androidx.appcompat.app.AppCompatActivity&lt;br&gt;
import android.os.Bundle&lt;br&gt;
import android.widget.Button&lt;/p&gt;

&lt;p&gt;class MainActivity : AppCompatActivity() {&lt;br&gt;
    override fun onCreate(savedInstanceState: Bundle?) {&lt;br&gt;
        super.onCreate(savedInstanceState)&lt;br&gt;
        setContentView(R.layout.activity_main)&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    val buttonTypePin: Button = findViewById(R.id.buttonTypePin)
    val buttonSetPin: Button = findViewById(R.id.buttonSetPin)

    /* buttonSetPin will open the SetPasswordActivity.kt.
    *
    *  In other words the activity opened will
    *  overwrite the default shared preferences or set new values if not present.
    *
    *  You can further create it for reseting passwords or forgotten
    *  password option in your app
    * */

    buttonSetPin.setOnClickListener{
        val intent = Intent(this,SetPasswordActivity::class.java)
        startActivity(intent)
    }


    /*
    *  buttonTypePin will open the PasswordTypeActivit.kt
    *
    * If the user has already set the pin he/she
    * can just enter the pin correctly and can enter the
    * next screen.
    * */

    buttonTypePin.setOnClickListener{
        val intent = Intent(this,PasswordTypeActivity::class.java)
        startActivity(intent)

    }

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

&lt;/div&gt;
&lt;p&gt;}&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&amp;lt;a name="setB"&amp;gt;&amp;lt;/a&amp;gt;

&amp;gt; SetPasswordActivity.kt

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

&lt;/div&gt;


&lt;p&gt;package com.siddharthsinghbaghel.sharedpreferences&lt;/p&gt;

&lt;p&gt;import android.content.Intent&lt;br&gt;
import android.os.Bundle&lt;br&gt;
import android.widget.*&lt;br&gt;
import androidx.appcompat.app.AppCompatActivity&lt;/p&gt;

&lt;p&gt;class SetPasswordActivity : AppCompatActivity() {&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_set_password)


    val edtName: EditText = findViewById(R.id.edtName)
    val edtPass: EditText = findViewById(R.id.edtPass)
    val btnSave: Button = findViewById(R.id.btnSave)



    /* Creating the shared preference to store (name, password)
    *  as a key value pair.
    * */

    val sharedPref = getSharedPreferences("passPref", MODE_PRIVATE)
    val editor = sharedPref.edit()


    /*
    * onClick of btnSave the data present in edit texts
    * name and pass in .xml file will be  stored in our
    * shared preference (sharedpref)
    * */

    btnSave.setOnClickListener{

        val name: String = edtName.text.toString()
        val password: String = edtPass.text.toString()

        editor.apply {

            putString("name", name)
            putString("password", password)
            apply() /* can also use commit() here but apply() is the best practice according to google */
        }


        Toast.makeText(this, "PIN successfully set ", Toast.LENGTH_SHORT).show()

        /* On successfully creating the PIN user will
        *  will be directed to the PasswordTypeActivity screen
        *  where user have to enter the correct PIN to enter the WelcomeActivity.kt
        * */

        val intent = Intent(this,PasswordTypeActivity::class.java)
        startActivity(intent)
        finish()

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

&lt;/div&gt;
&lt;p&gt;}&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&amp;lt;a name="passB"&amp;gt;&amp;lt;/a&amp;gt;

&amp;gt; PasswordTypeActivity.kt

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

&lt;/div&gt;


&lt;p&gt;package com.siddharthsinghbaghel.sharedpreferences&lt;/p&gt;

&lt;p&gt;import android.content.Context&lt;br&gt;
import android.content.Intent&lt;br&gt;
import android.os.Bundle&lt;br&gt;
import android.preference.PreferenceManager&lt;br&gt;
import android.view.View&lt;br&gt;
import android.widget.Button&lt;br&gt;
import android.widget.ImageButton&lt;br&gt;
import android.widget.TextView&lt;br&gt;
import android.widget.Toast&lt;br&gt;
import androidx.appcompat.app.AppCompatActivity&lt;/p&gt;

&lt;p&gt;class PasswordTypeActivity : AppCompatActivity(), View.OnClickListener {&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* codeString is the string in which the PIN entered by user is stored.*/
private var codeString: String = ""

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_password_type)


    /* Since we have to check the whether the entered
    *  password by user is correct or not, we need
    *  shared preference where we stored that.
    *  To retrieve data from shared preference the below code
    *  is executed.
    * */
    val sharedPref = getSharedPreferences("passPref", MODE_PRIVATE)
    val password = sharedPref.getString("password", "1234")


    val txtPass: TextView = findViewById(R.id.txtPass)

    txtPass.text = "" /*Emptied the textview to show the simultaneous
                        entering effect of all 4 digits of PIN */

    val btn0: Button = findViewById(R.id.btn0)
    val btn1:Button = findViewById(R.id.btn1)
    val btn2:Button = findViewById(R.id.btn2)
    val btn3:Button = findViewById(R.id.btn3)
    val btn4:Button = findViewById(R.id.btn4)
    val btn5:Button = findViewById(R.id.btn5)
    val btn6:Button = findViewById(R.id.btn6)
    val btn7:Button = findViewById(R.id.btn7)
    val btn8:Button = findViewById(R.id.btn8)
    val btn9:Button = findViewById(R.id.btn9)
    val btnErase: ImageButton = findViewById(R.id.btnErase)
    val btnCheck: ImageButton = findViewById(R.id.btnCheck)


    btn0.setOnClickListener(this)
    btn1.setOnClickListener(this)
    btn2.setOnClickListener(this)
    btn3.setOnClickListener(this)
    btn4.setOnClickListener(this)
    btn5.setOnClickListener(this)
    btn6.setOnClickListener(this)
    btn7.setOnClickListener(this)
    btn8.setOnClickListener(this)
    btn9.setOnClickListener(this)
    btnErase.setOnClickListener(this)



    btnCheck.setOnClickListener{

        /* btnCheck is called means iuser enter the desired PIN
         * now it's our turn to check it.
        * */

        codeString = txtPass.text.toString()

        if(codeString == password)
        {
            Toast.makeText(this, "Correct PIN Welcome!", Toast.LENGTH_SHORT).show()
            val intent = Intent(this,WelcomeActivity::class.java)
            startActivity(intent)
            finish()
        }else{

            Toast.makeText(this, "Wrong PIN please try again", Toast.LENGTH_SHORT).show()
            txtPass.text = ""
            codeString = txtPass.text.toString()
        }


    }


}

private fun setDotView() {

    /* this function will simply set the values
    *  which user is entering one by one as PIN in
    *  textView (txtPass) to give a PIN entering
    *  view.
    * */

    val txtPass: TextView = findViewById(R.id.txtPass)
    txtPass.text = codeString
}

override fun onClick(v: View?) {
    when (v!!.id) {
        R.id.btn0 -&amp;gt; codeString += "0"
        R.id.btn1 -&amp;gt; codeString += "1"
        R.id.btn2 -&amp;gt; codeString += "2"
        R.id.btn3 -&amp;gt; codeString += "3"
        R.id.btn4 -&amp;gt; codeString += "4"
        R.id.btn5 -&amp;gt; codeString += "5"
        R.id.btn6 -&amp;gt; codeString += "6"
        R.id.btn7 -&amp;gt; codeString += "7"
        R.id.btn8 -&amp;gt; codeString += "8"
        R.id.btn9 -&amp;gt; codeString += "9"
        R.id.btnErase -&amp;gt; {
            codeString = removeLastChar(codeString).toString()
        }
        else -&amp;gt; {
        }
    }
    setDotView()
}


private fun removeLastChar(s: String?): String? {

    /* the erase button will erase the
    *  the last entered value from the keyboard.
    *  The Erase button's working is followed in this function.
    * */
    return if (s == null || s.length == 0) {
        s
    } else s.substring(0, s.length - 1)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;}&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&amp;lt;a name="welB"&amp;gt;&amp;lt;/a&amp;gt;

&amp;gt; WelcomeActivity.kt

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

&lt;/div&gt;


&lt;p&gt;package com.siddharthsinghbaghel.sharedpreferences&lt;/p&gt;

&lt;p&gt;import android.content.Intent&lt;br&gt;
import androidx.appcompat.app.AppCompatActivity&lt;br&gt;
import android.os.Bundle&lt;br&gt;
import android.widget.Toast&lt;/p&gt;

&lt;p&gt;class WelcomeActivity : AppCompatActivity() {&lt;/p&gt;

&lt;p&gt;/* Here we used onRestart() callback&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; because if user pushes the home button&lt;/li&gt;
&lt;li&gt; or opened any other application or just closed the app and &lt;/li&gt;
&lt;li&gt; restart it again, the first session will expire and the app&lt;/li&gt;
&lt;li&gt; will be locked up again. Thus user have to enter the password &lt;/li&gt;
&lt;li&gt; always when he/she stops and restart the app.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;*/&lt;/p&gt;

&lt;p&gt;override fun onRestart() {&lt;br&gt;
    super.onRestart()&lt;br&gt;
    val intent = Intent(this,PasswordTypeActivity::class.java)&lt;br&gt;
    startActivity(intent)&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;override fun onCreate(savedInstanceState: Bundle?) {&lt;br&gt;
    super.onCreate(savedInstanceState)&lt;br&gt;
    setContentView(R.layout.activity_welcome)&lt;br&gt;
}&lt;br&gt;
}&lt;/p&gt;
&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;a name="GitHub"&amp;gt;&amp;lt;/a&amp;gt; 
##GitHub Repository
* Fork the repository for better and easy understanding and for quick learning.

&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Siddharth-sing" rel="noopener noreferrer"&gt;
        Siddharth-sing
      &lt;/a&gt; / &lt;a href="https://github.com/Siddharth-sing/Material-UI-LockPIN-Demo" rel="noopener noreferrer"&gt;
        Material-UI-LockPIN-Demo
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Material-UI-LockPIN-Demo&lt;/h1&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Original Article on Dev.to Click below 👇&lt;/h2&gt;
&lt;/div&gt;
&lt;a href="https://dev.to/siddharthsing/androids-in-app-lock-screen-using-shared-preferences-material-ui-103" rel="nofollow"&gt;
  &lt;img src="https://camo.githubusercontent.com/1acec6bc44a5c4bc5f0b0fd5894f79683f95be00b9fdffea50be6ebd259fa71a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6465762e746f2d3041304130413f7374796c653d666f722d7468652d6261646765266c6f676f3d6465762e746f266c6f676f436f6c6f723d7768697465" height="200px" width="500px"&gt;
  &lt;/a&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;App's Overview&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;
In this article, I am going to create a multi-screen yet simple application that will be demonstrating the best way to create lock screens for the apps using shared preferences and some material UI components.   
&lt;/p&gt;



&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/a1b9b097838952935f9b8a7b2b2dd6602af603e876f9922ba4b23ce0f94ab849/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f75706c6f6164732f61727469636c65732f39726c39396f6438346d6c7672786e35786a38692e676966"&gt;&lt;img src="https://camo.githubusercontent.com/a1b9b097838952935f9b8a7b2b2dd6602af603e876f9922ba4b23ce0f94ab849/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f75706c6f6164732f61727469636c65732f39726c39396f6438346d6c7672786e35786a38692e676966" alt="Lock Screen Demo App"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Steps to proceed&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;
We will be proceeding in a very beginner-friendly way. All the steps are mentioned below.
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Material-UI-LockPIN-Demo#setup" rel="noopener noreferrer"&gt;Project Setup &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Material-UI-LockPIN-Demo#UI" rel="noopener noreferrer"&gt;Building the app's UI &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Material-UI-LockPIN-Demo#back" rel="noopener noreferrer"&gt;Creating the Backend of the app&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Material-UI-LockPIN-Demo#GitHub" rel="noopener noreferrer"&gt;GitHub Repo &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Material-UI-LockPIN-Demo#support" rel="noopener noreferrer"&gt;Writer's Support ❤️&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;





&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Setup&lt;/h2&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;First of all, create a brand new project in your android studio. Assuming that it will be an easy part, so not explaining all.
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/8034cb340d311559092c581e93b0586abb545e568355a207de2ebb7c67f2f87b/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f75706c6f6164732f61727469636c65732f697534796b76766f716e356731707272667672702e6a7067"&gt;&lt;img src="https://camo.githubusercontent.com/8034cb340d311559092c581e93b0586abb545e568355a207de2ebb7c67f2f87b/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f75706c6f6164732f61727469636c65732f697534796b76766f716e356731707272667672702e6a7067" alt="Image description"&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Then set up your emulator properly to check the application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we are good to go for next step.&lt;/p&gt;





&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Building the app's UI&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;
App's UI will be built in 4 steps :&lt;/p&gt;


&lt;ul&gt;

&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Material-UI-LockPIN-Demo#mainA" rel="noopener noreferrer"&gt;Main Activity UI (activity_main.xml)&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href="https://github.com/Siddharth-sing/Material-UI-LockPIN-Demo#setA" rel="noopener noreferrer"&gt;Set Password Screen UI (activity_set_password.xml)&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;

&lt;a href="https://github.com/Siddharth-sing/Material-UI-LockPIN-Demo#passA" rel="noopener noreferrer"&gt;PIN Entering screen UI&lt;/a&gt;…&lt;/li&gt;

&lt;/ul&gt;
&lt;/div&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Siddharth-sing/Material-UI-LockPIN-Demo" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;

&lt;p&gt;&amp;lt;a name="support"&amp;gt;&amp;lt;/a&amp;gt; &lt;/p&gt;
&lt;h2&gt;
  
  
  Writer's Support
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you find the article useful show some ❤️ by staring some of my repositories and following me on dev.to and github.
&amp;lt;div&amp;gt;
&amp;lt;p align="middle"&amp;gt;
&amp;lt;a href="&lt;a href="https://www.linkedin.com/in/siddharth-singh-baghel-912866190/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/siddharth-singh-baghel-912866190/&lt;/a&gt;"&amp;gt;
&amp;lt;img src="&lt;a href="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&amp;amp;logo=linkedin&amp;amp;logoColor=white" rel="noopener noreferrer"&gt;https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&amp;amp;amp;logo=linkedin&amp;amp;amp;logoColor=white&lt;/a&gt;"&amp;gt;
&amp;lt;/a&amp;gt;
&amp;lt;a href="&lt;a href="https://github.com/Siddharth-sing" rel="noopener noreferrer"&gt;https://github.com/Siddharth-sing&lt;/a&gt;"&amp;gt;
&amp;lt;img src="&lt;a href="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&amp;amp;logo=github&amp;amp;logoColor=white" rel="noopener noreferrer"&gt;https://img.shields.io/badge/GitHub-100000?style=for-the-badge&amp;amp;amp;logo=github&amp;amp;amp;logoColor=white&lt;/a&gt;"&amp;gt;
&amp;lt;/a&amp;gt;
&amp;lt;a href="&lt;a href="https://dev.to/siddharthsing"&gt;https://dev.to/siddharthsing&lt;/a&gt;"&amp;gt;
&amp;lt;img src="&lt;a href="https://img.shields.io/badge/dev.to-0A0A0A?style=for-the-badge&amp;amp;logo=dev.to&amp;amp;logoColor=white"&gt;https://img.shields.io/badge/dev.to-0A0A0A?style=for-the-badge&amp;amp;amp;logo=dev.to&amp;amp;amp;logoColor=white&lt;/a&gt;"&amp;gt;
&amp;lt;/a&amp;gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>beginners</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
