<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Alex Kubica 🇮🇱</title>
    <description>The latest articles on Forem by Alex Kubica 🇮🇱 (@alexkubica).</description>
    <link>https://forem.com/alexkubica</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%2F294008%2Fb0c69b3a-517d-4206-bbbd-2f217efcfa39.png</url>
      <title>Forem: Alex Kubica 🇮🇱</title>
      <link>https://forem.com/alexkubica</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/alexkubica"/>
    <language>en</language>
    <item>
      <title>Get the latest Software Engineering blog articles from the top tech companies in telegram</title>
      <dc:creator>Alex Kubica 🇮🇱</dc:creator>
      <pubDate>Sat, 28 Oct 2023 13:09:05 +0000</pubDate>
      <link>https://forem.com/alexkubica/get-the-latest-software-engineering-blog-articles-from-the-top-tech-companies-in-telegram-3a67</link>
      <guid>https://forem.com/alexkubica/get-the-latest-software-engineering-blog-articles-from-the-top-tech-companies-in-telegram-3a67</guid>
      <description>&lt;p&gt;If you're a fellow professional software engineer, you probably enjoy staying up to date with the latest tech blogs from major companies like Monday.com, Wix, Meta, LinkedIn, Netflix, and more.&lt;/p&gt;

&lt;p&gt;You can receive all the updates with AI-generated summaries on Telegram, check this out👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://t.me/softwareengineeringblogs"&gt;https://t.me/softwareengineeringblogs&lt;/a&gt; &lt;/p&gt;

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

&lt;p&gt;Help us spread the word and give us feedback so we can improve the feed 🙏&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>blog</category>
      <category>telegram</category>
      <category>resources</category>
    </item>
    <item>
      <title>Create a simple web3 app to connect and sign with your wallet in 7 minutes</title>
      <dc:creator>Alex Kubica 🇮🇱</dc:creator>
      <pubDate>Wed, 05 Apr 2023 09:54:39 +0000</pubDate>
      <link>https://forem.com/alexkubica/create-a-simple-web3-app-to-connect-and-sign-with-your-wallet-in-7-minutes-3fp7</link>
      <guid>https://forem.com/alexkubica/create-a-simple-web3-app-to-connect-and-sign-with-your-wallet-in-7-minutes-3fp7</guid>
      <description>&lt;p&gt;Are you ready to learn how to connect to a wallet and sign a message using Web3.js and MetaMask? 🤩 This step-by-step guide will show you how to get started with these powerful tools to create this &lt;a href="https://zhljt9.csb.app/" rel="noopener noreferrer"&gt;web3 app&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With just a few lines of code, you'll be able to connect to a wallet and sign a message in no time! 😎 And don't worry if you're new to Web3.js and MetaMask, we've got you covered with detailed explanations and easy-to-follow instructions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Create a new CodeSandbox project
&lt;/h2&gt;

&lt;p&gt;Go to &lt;a href="https://codesandbox.io/" rel="noopener noreferrer"&gt;CodeSandbox&lt;/a&gt; and create a new project by clicking the "Create Sandbox" button. Choose the "Vanilla" template to create a new sandbox with a basic HTML, CSS, and JavaScript setup.&lt;br&gt;
You should install the &lt;code&gt;web3&lt;/code&gt; dependency which we will use in the next step.&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%2Fzfvj2bypixezd742krho.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%2Fzfvj2bypixezd742krho.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Modify the HTML file
&lt;/h2&gt;

&lt;p&gt;In the CodeSandbox editor, open the &lt;code&gt;index.html&lt;/code&gt; file and replace its contents with the following code:&lt;/p&gt;

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

&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Wallet Connection Example&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Wallet Connection Example&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"connectBtn"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Connect Wallet&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"signBtn"&lt;/span&gt; &lt;span class="na"&gt;disabled&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Sign Message&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"confirmation"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"./src/index.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;This code defines a basic HTML page with two buttons and a div to display the signed message confirmation. We've also included a script tag to load our JavaScript code, which we'll write in the next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Modify the JavaScript file
&lt;/h2&gt;

&lt;p&gt;Now Open the &lt;code&gt;src/index.js&lt;/code&gt; file and replace its contents with the following code:&lt;/p&gt;

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

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Web3&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;web3&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;connectBtn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;connectBtn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;signBtn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;signBtn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;confirmationDiv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;confirmation&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Check if MetaMask is installed&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethereum&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;connectBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Install MetaMask&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;connectBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;disabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Connect to the wallet&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;web3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;connectWallet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Prompt user to connect to MetaMask&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethereum&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;eth_requestAccounts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="c1"&gt;// Get the provider object&lt;/span&gt;
    &lt;span class="nx"&gt;web3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Web3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ethereum&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// Update button text&lt;/span&gt;
    &lt;span class="nx"&gt;connectBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Logout&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Enable sign button&lt;/span&gt;
    &lt;span class="nx"&gt;signBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;disabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;connectBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;connectWallet&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Sign a message&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;signMessage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Get the current account&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;accounts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;web3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;eth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAccounts&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;account&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;accounts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="c1"&gt;// Create a message to sign&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello, world!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Sign the message&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;signature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;web3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;eth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;personal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;account&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// Display the signature in the confirmation div&lt;/span&gt;
    &lt;span class="nx"&gt;confirmationDiv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`Signed message: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;signature&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;signBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;signMessage&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;This code uses the import statement to import the Web3 library from the web3 package. It defines three variables to reference the two buttons and the confirmation div in our HTML code. We also check if MetaMask is installed and display a message if it is not.&lt;/p&gt;

&lt;p&gt;The connectWallet function uses the &lt;code&gt;window.ethereum&lt;/code&gt; object to prompt the user to connect to MetaMask and authorize the connection. It then initializes the web3 object with the provider returned by MetaMask and updates the button text and disabled status.&lt;/p&gt;

&lt;p&gt;The signMessage function gets the current account from MetaMask, creates a message to sign, and uses the &lt;code&gt;web3.eth.personal.sign&lt;/code&gt; method to sign the message with the current account. It then displays the signed message confirmation in the div below the Sign Message button.&lt;/p&gt;

&lt;p&gt;Finally, we add event listeners to the Connect Wallet and Sign Message buttons to call the connectWallet and signMessage functions, respectively, when they are clicked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Preview the HTML file in the browser
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftalarkk0wi95o0841mug.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%2Ftalarkk0wi95o0841mug.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To test our code, click the "Preview" button at the top of the CodeSandbox editor to open a new tab with the preview of the HTML page. Click the Connect Wallet button to connect to MetaMask and authorize the connection. Once connected, the Sign Message button will be enabled. Click it to sign the "Hello, world!" message and display the signed message confirmation.&lt;/p&gt;

&lt;p&gt;Congratulations, you've successfully connected to a wallet and signed a message using Web3.js and MetaMask in CodeSandbox!&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://codesandbox.io/s/simple-web3-connect-and-sign-project-zhljt9" rel="noopener noreferrer"&gt;Final CodeSandbox project&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://zhljt9.csb.app/" rel="noopener noreferrer"&gt;Live demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://web3js.readthedocs.io/en/v1.8.2/getting-started.html" rel="noopener noreferrer"&gt;web3js's docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's a wrap! If you liked this tutorial let me know in the comments and tell me what you'd like to learn next 😎&lt;/p&gt;

</description>
      <category>web3</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>ethereum</category>
    </item>
    <item>
      <title>Pros and cons of TypeScript</title>
      <dc:creator>Alex Kubica 🇮🇱</dc:creator>
      <pubDate>Thu, 09 Jul 2020 10:44:10 +0000</pubDate>
      <link>https://forem.com/alexkubica/pros-and-cons-of-typescript-8o5</link>
      <guid>https://forem.com/alexkubica/pros-and-cons-of-typescript-8o5</guid>
      <description>&lt;p&gt;This is going to be &lt;a href="https://www.google.com/search?q=typescript+pros+and+cons"&gt;yet another article&lt;/a&gt; about the pros and cons of TypeScript based on my experience. I hope to give you a better understanding on it. I also hope to help you decide whether switching to it or not is worth for you.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is TypeScript?
&lt;/h1&gt;

&lt;p&gt;Simply put, &lt;a href="https://www.quora.com/Why-is-TypeScript-a-superset-of-JavaScript"&gt;TypeScript is a JavaScript superset&lt;/a&gt;. Meaning the TypeScript code is compiled into the plain old JavaScript that most browsers can run.&lt;/p&gt;

&lt;p&gt;TypeScript adds to JavaScript some missing features such as static types system (you probably guessed from its name 😊). You can easily learn it yourself using &lt;a href="https://www.typescriptlang.org/docs/home.html"&gt;its documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  My experience with TypeScript
&lt;/h1&gt;

&lt;p&gt;In my first job we used to develop and maintain a legacy code written in &lt;a href="https://www.typescriptlang.org/docs/home.html"&gt;angularjs&lt;/a&gt;, a.k.a angular 1. The codebase was not a pretty sight.&lt;/p&gt;

&lt;p&gt;There were global variables referenced from everywhere. You changed a line of code to fix a bug only to discover you made 3 other bugs somewhere else.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg8tz2g6ki1ej03wy7jre.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg8tz2g6ki1ej03wy7jre.png" alt="Fixed 1 bug 99 more bugs appeared! - Bug solving" width="302" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There was no real use of dependency injection which was the main thing about angularjs at the time. There were also no tests so you couldn’t tell if you broke something while fiddling with the code.&lt;/p&gt;

&lt;p&gt;After about 2 years of working this way we decided to refactor and switch to &lt;a href="https://reactjs.org/"&gt;React&lt;/a&gt;. React was such an improvement to our frontend stack. Our code was divided into smaller, more maintainable components and we used &lt;a href="https://reactjs.org/docs/typechecking-with-proptypes.html"&gt;PropTypes&lt;/a&gt; for dynamically type checking.&lt;/p&gt;

&lt;p&gt;After a while into using React my teammate convinced us to start using TypeScript and boy, how I loved it. The setup wasn’t easy, it took a few days to make it work with the existing code. But after doing that things started to get much smoother.&lt;/p&gt;

&lt;p&gt;Now warnings and errors that showed in the browser’s console or the development server were now compile errors. It meant no more procrastinating. We fixed issues as soon as they rose instead of lazing out and waiting for them to become bugs.&lt;/p&gt;

&lt;p&gt;A few years have passed since my first role in that organization. Now I’m in another project which doesn’t use TypeScript so I decided to write this article and I dedicate it to the team ❤.&lt;/p&gt;
&lt;h1&gt;
  
  
  Pros 👍
&lt;/h1&gt;
&lt;h2&gt;
  
  
  Static type checking
&lt;/h2&gt;

&lt;p&gt;In JavaScript you don’t need (actually you can’t as far as I know) to define types for variables. In some cases it has its advantages. But since you don’t enforce types &lt;strong&gt;you can misuse or misinterpret code  easily which can lead to bugs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ali&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ba&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// prints "aliNaN"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In that case I could assume that “double” takes strings as argument and duplicate them. So in the example I would expect the output: “alibaba”.&lt;/p&gt;

&lt;p&gt;In TypeScript you define parameter types which saves you from mistakes like that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ali&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ba&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// error: Argument of type '"ba"' is not assignable to parameter of type 'number'.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course it applies on other things besides parameters such as variables, function outputs, etc. See &lt;a href="https://www.typescriptlang.org/docs/handbook/basic-types.html"&gt;Basic Types&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compilation prevents from errors to get into production
&lt;/h2&gt;

&lt;p&gt;JavaScript is a scripting language which is executed line by line. Because of that you will discover if the code is broken only when it’s executed by runtime environments.&lt;/p&gt;

&lt;p&gt;In other hand TypeScript code must be compiled. So you’ll see the errors in your terminal or code editor right away which can save you time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh9i1r18m6pn6k717g8rn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh9i1r18m6pn6k717g8rn.png" alt="TypeScript error shown in the editor" width="760" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TypeScript can work with vanilla JavaScript
&lt;/h2&gt;

&lt;p&gt;In other static languages like Java you must define types everywhere. But because TypeScript is a &lt;strong&gt;subset&lt;/strong&gt; of JavaScript &lt;a href="https://stackoverflow.com/questions/38318542/how-to-use-javascript-in-typescript/38318565#38318565"&gt;it can work alongside it, you just need to configure it&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Better code documentation and design
&lt;/h2&gt;

&lt;p&gt;When you incorporate types in your code you basically make it self-documenting. You also make it easier to understand how to use it properly.&lt;/p&gt;

&lt;p&gt;Furthermore you’re enforced to pay more attention and effort into design rather then rushing into implementation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fiisonfjmunbf1pw6nqsl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fiisonfjmunbf1pw6nqsl.png" alt="JavaScript is faster to develop but easier to misuse" width="193" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Extensive IDE integration
&lt;/h2&gt;

&lt;p&gt;TypeScript is already supported on most used code editors and IDEs:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5u6jyjpywthamoa8dgn2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5u6jyjpywthamoa8dgn2.png" alt="Supported code editors according to TypeScript’s website" width="681" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That means you can start developing with TypeScript today without replacing you favorite developing tools.&lt;/p&gt;

&lt;p&gt;Visual Studio Code for example &lt;a href="https://dev.toSupported%20code%20editors%20according%20to%20TypeScript%E2%80%99s%20website"&gt;supports navigation, formatting, code suggestions, syntax highlighting and many more&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Ready TypeScript definitions for non TypeScript libraries
&lt;/h2&gt;

&lt;p&gt;Some libraries are written with TypeScript and are shipped with the type definitions out of the box, for example: &lt;a href="https://material-ui.com/"&gt;material-ui&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But in reality many libraries are still written in JavaScript so you need to get the type definitions somehow. Lucky for us the most of them have &lt;a href="https://www.npmjs.com/search?q=%40types"&gt;type definitions written by the community&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you can’t find any types you can still &lt;a href="https://medium.com/@steveruiz/using-a-javascript-library-without-type-declarations-in-a-typescript-project-3643490015f3"&gt;write your own type declarations&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;TypeScript sounds amazing, I’ll start using it today!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Wait, hold on! I do love TypeScript there are also drawbacks to consider which I’ll discuss about in this section.&lt;/p&gt;

&lt;h1&gt;
  
  
  Cons 👎
&lt;/h1&gt;

&lt;h2&gt;
  
  
  It needs to be compiled
&lt;/h2&gt;

&lt;p&gt;Earlier I mentioned compilation as an advantage but it’s also a disadvantage since it adds time to development and building.&lt;/p&gt;

&lt;p&gt;I think the compilation time isn’t that critical but I don’t have experience working with large scale projects.&lt;/p&gt;

&lt;p&gt;I will mention that, mainly in frontend, you will run some tools to modify your code anyway such as &lt;a href="https://webpack.js.org/"&gt;webpack&lt;/a&gt;, &lt;a href="https://babeljs.io"&gt;babel&lt;/a&gt;, etc. So compiling to TypeScript isn’t so different than bundling or minifying.&lt;/p&gt;

&lt;p&gt;It’s nice to know that &lt;a href="https://deno.land"&gt;deno&lt;/a&gt; (a potential successor to nodejs) supports TypeScript out of the box without needing to compile!&lt;/p&gt;

&lt;h2&gt;
  
  
  It takes time to learn and get used to
&lt;/h2&gt;

&lt;p&gt;I agree that the syntax might be a little intimidating at first.&lt;/p&gt;

&lt;p&gt;Lucky for us the TypeScript documentation is good.&lt;/p&gt;

&lt;p&gt;You even have the &lt;a href="https://www.typescriptlang.org/play/index.html"&gt;playground&lt;/a&gt; to fiddle with and test TypeScript’s features.&lt;/p&gt;

&lt;h2&gt;
  
  
  We already have type checking with PropTypes (React developers’ argument)
&lt;/h2&gt;

&lt;p&gt;Surely there are alternatives to type checking such as PropTypes for React components’ props. But what if I want to check types for other things?&lt;/p&gt;

&lt;p&gt;PropTypes is also easily replaceable by TypeScript. You just have to define interfaces for your props instead or &lt;a href="https://react-etc.net/entry/automatic-react-proptypes-to-typescript-conversion"&gt;you can use automatic tools for that&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Final words
&lt;/h1&gt;

&lt;p&gt;I hope you enjoyed reading this article. Please leave a comment and let me know what you choose because I’m really looking forward to hearing it 😁&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frp5rz482c419dx3k8zax.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frp5rz482c419dx3k8zax.png" alt="Which do you choose?" width="645" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  PS
&lt;/h1&gt;

&lt;p&gt;I’ll appreciate it if you share this article and motivate me to write more content about dev stuff 🤓.&lt;/p&gt;

&lt;p&gt;I’m new into writing but I hope my content will become of better quality with time. If it’ll help you to make better products that serve the needs of your customers I’ve done my job😁&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>prosandcons</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
