<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Michael Tech Blog]]></title><description><![CDATA[I am a tech enthusiast, interested in building solutions or writing about them.]]></description><link>https://blog.michaeltech.xyz</link><generator>RSS for Node</generator><lastBuildDate>Mon, 20 Apr 2026 03:04:40 GMT</lastBuildDate><atom:link href="https://blog.michaeltech.xyz/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to create your private VPN on the cloud]]></title><description><![CDATA[Background
As the world around us gets more and more intertwined with the World Wide Web, the need to secure our Internet experience has never been more important than ever. With the rise of IOT (Internet of Things), we are seeing an increasingly dig...]]></description><link>https://blog.michaeltech.xyz/how-to-create-your-private-vpn-on-the-cloud</link><guid isPermaLink="true">https://blog.michaeltech.xyz/how-to-create-your-private-vpn-on-the-cloud</guid><category><![CDATA[Cloud Computing]]></category><category><![CDATA[Cloud]]></category><category><![CDATA[Azure]]></category><category><![CDATA[AWS]]></category><category><![CDATA[GCP]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Wed, 20 Sep 2023 10:09:26 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/NEtFkKuo7VY/upload/1025afbb3cbadee43d4d968139a9e6e2.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-background">Background</h3>
<p>As the world around us gets more and more intertwined with the World Wide Web, the need to secure our Internet experience has never been more important than ever. With the rise of IOT (Internet of Things), we are seeing an increasingly digitalized world where almost everything has to be connected to the Internet to perform basic functions. The way the internet works, when we connect to the internet our ISPs(Internet Service Providers) allocate what is known as an IP address, an IP address can be easily described as an address used to identify a device on the internet, similar to the home address of an individual, which a postman uses to determine where specific letters (in digital terms packets of data) are eventually directed and sent to.</p>
<p>The major problem with surfing on the internet is that many times our browsing activities and transactions can be easily accessed and manipulated by malicious actors and hackers, this is where a VPN comes in, a VPN stands for Virtual Private Network it is used to encrypt and anonymize our activities on the web. , many users and organizations use it to secure their online activities that could be easily subjected to a cyberattack, many also use it to escape the limitation of location-based IP restrictions. VPN services are in quite demand, I will do a walkthrough on how we can easily build our own custom VPN server with the help of an opensource tool(OpenVPN) and using a cloud platform</p>
<p>We can create a server on any of the popular cloud platforms, most of these platforms offer basic free credits for the first few months of usage, I will demonstrate with the Azure cloud platform but it is basically the same step on other cloud platforms, we will create a compute instance where the OpenVPN tool is preinstalled using the OpenVPN Access Server, the tool has a free tier that allows for two VPN connections it can be easily accessed from the marketplace of any of the cloud platforms, a simple instance without much computing power will do the job.</p>
<h3 id="heading-setup-guide">Setup Guide</h3>
<p>From the Azure portal, search for '<em>Marketplace</em>', after navigating to Azure MarketPlace, search for OpenVPN, you will see the OpenVPN Access Server service</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695124013953/4d6548fe-af95-4ff9-9344-412a66d30020.png" alt class="image--center mx-auto" /></p>
<p>When the service has been selected, create an administrator username and password for the instance. you can leave most of the default settings the same, with Azure there is an option to enable auto shutdown keep that off to enable our VPN to be always available.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695124265906/a94bd4d1-1f0f-450e-97cc-46145ed849c5.png" alt class="image--center mx-auto" /></p>
<p>Once the instance has been created copy the public IP address it will be used to configure the OpenVPN server, after this is done SSH into the compute instance with your details.</p>
<pre><code class="lang-bash"> ssh openvpn@192.174.232.165
</code></pre>
<p>Read and accept the OpenVPN agreement and allow the default settings to be used, you can choose when you come to this option to create a different admin profile.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695127225640/ade002fa-0b6e-4e32-b3cd-aec7331ac73a.png" alt class="image--center mx-auto" /></p>
<p>When this is all done, log into the OpenVPN Server admin section with your public IP address.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695127461656/c6e05527-1f6f-4b30-8e4e-620d84bac8fa.png" alt class="image--center mx-auto" /></p>
<p>When inside, change the hostname to reflect your public IP address and save the settings. This is crucial to the VPN functionality as it should not be connected to a different IP address.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695143536501/8273e3f2-bc7e-4c40-8888-23f16f40d53b.png" alt class="image--center mx-auto" /></p>
<p>After this is done, download the client software on your system or device and download your VPN user profile which will configure the client profile.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695133917302/4877e97b-47cb-43f6-8f80-f371bc80c35d.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695134403383/b58dfa37-769c-4e11-a712-7bc7ac7e9561.png" alt class="image--center mx-auto" /></p>
<p>Input your password and connect to the VPN</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695134485297/ef399c1e-55d5-445b-8f9d-4645345ac6f0.png" alt class="image--center mx-auto" /></p>
<p>You should be able to connect to the internet with the VPN server, now if you check your IP it should be the same as the one on your VPN profile.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695136887592/b9b1ea05-6e82-4a52-8072-2d82db62f2b4.png" alt class="image--center mx-auto" /></p>
<p>Awesome! Your VPN is now up and running! This can also be further configured to fit your custom needs and requirements. Let me know in the comment section if you have any feedback or ideas about it.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding How Staking works on Ethereum]]></title><description><![CDATA[One of the key components of a blockchain is the ability to carry out a trustless consensus mechanism to verify transactions, the traditional means of validating transactions has been the Proof-Of-Stake mechanism which requires that for every transac...]]></description><link>https://blog.michaeltech.xyz/understanding-how-staking-works-on-ethereum</link><guid isPermaLink="true">https://blog.michaeltech.xyz/understanding-how-staking-works-on-ethereum</guid><category><![CDATA[Web3]]></category><category><![CDATA[Ethereum]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[defi]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Tue, 23 May 2023 11:28:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/I0psC25RqtE/upload/421b8eeeee18a6c216c9a80e08067b19.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>One of the key components of a blockchain is the ability to carry out a trustless consensus mechanism to verify transactions, the traditional means of validating transactions has been the Proof-Of-Stake mechanism which requires that for every transaction to be validated a certain complex cryptographical puzzle needs to be solved before that block of transaction can be added to the main chain. To solve the cryptographical puzzle, highly energy-intensive hardware which is specially designed for this work has to be put to use, afterwards the 'miner' as they are commonly called, will then be rewarded by the network with a token for the role he has performed. Due to the high rate of power consumption that such systems involve there have been pushes to move to a much more climate-friendly validation method, recently the Ethereum blockchain moved from a POW(Proof-Of-Work) consensus to a POS(Proof-Of-Stake) in what has now been called <a target="_blank" href="https://ethereum.org/en/roadmap/merge/">The Merge</a>.</p>
<p>The role of the miners is replaced with network validators, in other to be a validator you have to lock up 32 ETH in the network, the valdators are then randomly selected to start new blocks and verify transactions , if a validator is found liable of sabotage or collusion he loses a part of or all ofh is staked tokens in a process called slashing and for every successful validation he is rewarded accordingly.</p>
<h3 id="heading-types-of-staking">Types of Staking</h3>
<p>Here are some of the different types of staking being done at the moment;</p>
<p><strong>Solo Home staking</strong>:This is the most decentralized form of staking, you operate your own Ethereum node by providing your hardware and operating the necessary software for the validation services on the blockchain, apart from providing the compulsory 32 ETH this requires a dedicated computer and a sound understanding of how the network works.</p>
<p><strong>Staking as a service</strong>: In the case where not everyone has the necessary technical knowhow or the hardware requirements all they have to do is to signup with a staking provider service and deposit the 32 ETH, the provider will then carry out the uses validators duties on their behalf usually at a particular fee.</p>
<p><strong>Pooled Staking</strong>: Many might not be able to provide up to 32 ETH to establish a single validator node, there are services that allow users to contribute their deposits and manage them on their behalf. Other forms of this also include staking with popular centralized exchanges like Binanace, Coinbase, etc.</p>
<p>Since the <a target="_blank" href="https://www.forbes.com/advisor/investing/cryptocurrency/ethereum-shanghai-upgrade/#:~:text=What%20Is%20the%20Shanghai%20Upgrade,compatible%20with%20the%20upgraded%20version.">Shanghai upgrade</a> which allows for stakes to now be withdrawn, we have seen an increase in deposits for staking on Ethereum, this shows that there is an increased interest by users in staking and its earning potential. With the rise of staking pools which now account for a third of the total stakes on Ethereum, many fear the potential risk this poses by increasingly centralizing the network, one thing is for sure many people are beginning to see the intrinsic value that this technology has and desire to play a vital role in its future.</p>
]]></content:encoded></item><item><title><![CDATA[Reentrancy Attack in Solidity]]></title><description><![CDATA[With the rise of web3, we have seen financial solutions taking advantage of the blockchain to deliver innovative products and services, this has also brought about an accompanying rise of malicious actors and hackers seeking to find exploits in sever...]]></description><link>https://blog.michaeltech.xyz/reentrancy-attack-in-solidity</link><guid isPermaLink="true">https://blog.michaeltech.xyz/reentrancy-attack-in-solidity</guid><category><![CDATA[Solidity]]></category><category><![CDATA[software development]]></category><category><![CDATA[software architecture]]></category><category><![CDATA[hacking]]></category><category><![CDATA[Web3]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Thu, 30 Mar 2023 15:58:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/XIVDN9cxOVc/upload/8d24c8a6561642bff33a5c363b8c9b78.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>With the rise of web3, we have seen financial solutions taking advantage of the blockchain to deliver innovative products and services, this has also brought about an accompanying rise of malicious actors and hackers seeking to find exploits in several of such systems. In recent times there have been a lot of reports of cryptocurrency hacks causing losses of funds sometimes running into millions of dollars, it will be paramount for a developer to have a proper understanding of these exploits and how to secure their applications. One of the most common hacks is called the Reentracy hack attack, this attack is an exploit that uses a recursive call to a funded Smart contract to illegally withdraw tokens from it.</p>
<p>The following code example is a classic case of a Reentracy attack</p>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.8.17;</span>



<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">EtherWallet</span> </span>{
    <span class="hljs-keyword">mapping</span>(<span class="hljs-keyword">address</span> <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> <span class="hljs-keyword">uint</span>) <span class="hljs-keyword">public</span> balances; <span class="hljs-comment">// user's balances</span>

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">deposit</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">payable</span></span> </span>{
        balances[<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>] <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-built_in">msg</span>.<span class="hljs-built_in">value</span>;
    }

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">withdraw</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
        <span class="hljs-keyword">uint</span> bal <span class="hljs-operator">=</span> balances[<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>];
        <span class="hljs-built_in">require</span>(bal <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span>);

        (<span class="hljs-keyword">bool</span> sent, ) <span class="hljs-operator">=</span> <span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>.<span class="hljs-built_in">call</span>{<span class="hljs-built_in">value</span>: bal}(<span class="hljs-string">""</span>);
        <span class="hljs-built_in">require</span>(sent, <span class="hljs-string">"Failed to send Ether"</span>);

        balances[<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>] <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;
    }

    <span class="hljs-comment">// Helper function to check the balance of this contract</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getBalance</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">view</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint</span></span>) </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">address</span>(<span class="hljs-built_in">this</span>).<span class="hljs-built_in">balance</span>;
    }
}

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Attack</span> </span>{
    EtherWallet <span class="hljs-keyword">public</span> etherWallet;

    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> _etherWalletAddress</span>) </span>{
        etherWallet <span class="hljs-operator">=</span> EtherWallet(_etherWalletAddress);
    }

    <span class="hljs-comment">// Fallback is called when EtherWallet sends Ether to this contract.</span>
    <span class="hljs-function"><span class="hljs-keyword">fallback</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">payable</span></span> </span>{
        <span class="hljs-keyword">if</span> (<span class="hljs-keyword">address</span>(etherWallet).<span class="hljs-built_in">balance</span> <span class="hljs-operator">&gt;</span><span class="hljs-operator">=</span> <span class="hljs-number">1</span> <span class="hljs-literal">ether</span>) {
            etherWallet.withdraw();
        }
    }

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">attack</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">payable</span></span> </span>{
        <span class="hljs-built_in">require</span>(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">value</span> <span class="hljs-operator">&gt;</span><span class="hljs-operator">=</span> <span class="hljs-number">1</span> <span class="hljs-literal">ether</span>);
        etherWallet.deposit{<span class="hljs-built_in">value</span>: <span class="hljs-number">1</span> <span class="hljs-literal">ether</span>}();
        etherWallet.withdraw();
    }

    <span class="hljs-comment">// Helper function to check the balance of this contract</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getBalance</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">view</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint</span></span>) </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">address</span>(<span class="hljs-built_in">this</span>).<span class="hljs-built_in">balance</span>;
    }
}
</code></pre>
<p>There are two contracts in the above example the first one <em>etherWallet,</em> acts as a simple bank where users can deposit and withdraw their ethers. The second contract <em>Attack</em> is initialized with the <em>etherWallet</em> contract address, it has an <em>attack</em> function that when called, first invokes the <em>etherWallet.deposit</em> function to deposit 1 <em>ether</em>, it then moves to run <em>etherWallet.withdraw</em> function, which sends the 1 ether back to the <em>Attack</em> address,</p>
<pre><code class="lang-solidity"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">attack</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">payable</span></span> </span>{
        <span class="hljs-built_in">require</span>(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">value</span> <span class="hljs-operator">&gt;</span><span class="hljs-operator">=</span> <span class="hljs-number">1</span> <span class="hljs-literal">ether</span>);
        etherWallet.deposit{<span class="hljs-built_in">value</span>: <span class="hljs-number">1</span> <span class="hljs-literal">ether</span>}();
        etherWallet.withdraw();
    }
</code></pre>
<p>the function that receives the withdrawal is the <em>fallback</em> function which has another <em>etherWallet.withdraw</em> function within it, since the <em>etherWallet</em> contract hasn't updated the user balance for the <em>Attack</em> contract, it stills reads its balance as having 1 ether, this continues as a recursive loop until the <em>etherWallet</em> balance is completely drained.</p>
<pre><code class="lang-solidity"><span class="hljs-function"><span class="hljs-keyword">fallback</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">payable</span></span> </span>{
        <span class="hljs-keyword">if</span> (<span class="hljs-keyword">address</span>(etherWallet).<span class="hljs-built_in">balance</span> <span class="hljs-operator">&gt;</span><span class="hljs-operator">=</span> <span class="hljs-number">1</span> <span class="hljs-literal">ether</span>) {
            etherWallet.withdraw();
        }
    }
</code></pre>
<h3 id="heading-stopping-the-hack">Stopping the Hack</h3>
<p>A simple way of solving this will be to make sure the <em>withdraw</em> function updates the user's balance before sending the funds</p>
<pre><code class="lang-solidity"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">withdraw</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
        <span class="hljs-keyword">uint</span> bal <span class="hljs-operator">=</span> balances[<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>];
        <span class="hljs-built_in">require</span>(bal <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span>);
        balances[<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>] <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; <span class="hljs-comment">//Updated balance before sending</span>
        (<span class="hljs-keyword">bool</span> sent, ) <span class="hljs-operator">=</span> <span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>.<span class="hljs-built_in">call</span>{<span class="hljs-built_in">value</span>: bal}(<span class="hljs-string">""</span>);
        <span class="hljs-built_in">require</span>(sent, <span class="hljs-string">"Failed to send Ether"</span>);


    }
</code></pre>
<p>Another way is creating a function modifier that locks the withdrawal function when it is still being called and doesn't allow a concurrent call on it</p>
<pre><code class="lang-solidity"><span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">ReEntrancyLock</span> </span>{
    <span class="hljs-keyword">bool</span> <span class="hljs-keyword">internal</span> locked;

    <span class="hljs-function"><span class="hljs-keyword">modifier</span> <span class="hljs-title">noReentrant</span>(<span class="hljs-params"></span>) </span>{
        <span class="hljs-built_in">require</span>(<span class="hljs-operator">!</span>locked, <span class="hljs-string">"No re-entrancy"</span>);
        locked <span class="hljs-operator">=</span> <span class="hljs-literal">true</span>;
        <span class="hljs-keyword">_</span>;
        locked <span class="hljs-operator">=</span> <span class="hljs-literal">false</span>;
    }
}
</code></pre>
<p>OpenZeppelin has a ready-made implementation of a ReentracyGuard that can be easily integrated into your projects. One can clearly see that detailed attention and care must be put into building fault-tolerant applications that users can commit their precious funds into. Stay safe!</p>
]]></content:encoded></item><item><title><![CDATA[Using WebSocket to build a Real-time Cryptocurrency Tracker]]></title><description><![CDATA[In building web applications, the underlying communication architecture plays a vital role in determining the effectiveness of its functionalities. WebSocket is a TCP/IP communication protocol that allows for a consistent bidirectional(two-way )excha...]]></description><link>https://blog.michaeltech.xyz/using-websocket-to-build-a-real-time-cryptocurrency-tracker</link><guid isPermaLink="true">https://blog.michaeltech.xyz/using-websocket-to-build-a-real-time-cryptocurrency-tracker</guid><category><![CDATA[Web Development]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Cryptocurrency]]></category><category><![CDATA[websockets]]></category><category><![CDATA[Web3]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Wed, 15 Mar 2023 10:25:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/RDXcFY5g5O4/upload/f543f18d381ffd3fa4c3e9224bd940d6.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In building web applications, the underlying communication architecture plays a vital role in determining the effectiveness of its functionalities. WebSocket is a TCP/IP communication protocol that allows for a consistent bidirectional(two-way )exchange between the client and the server.</p>
<p>This is in stark contrast to the traditional HTTP protocol that allows for a oneway call and response to the server, there are use cases for certain solutions where data on the server side changes rapidly, for these changes to be appropriately reflected, repeated calls to the server has to be made. This method clearly proves to be inefficient in cases that require fast-changing data such as live video streaming, stock, cryptocurrency trading, etc, WebSocket is the best technology to be implemented.</p>
<p>To demonstrate this, we'll implement the WebSocket API to build a real-time Cryptocurrency Tracker. For real-time data around the prices of certain cryptocurrencies, we would be using the <a target="_blank" href="https://binance-docs.github.io/apidocs/websocket_api/en/#change-log">Binance</a> WebSocket API.</p>
<h3 id="heading-single-currency-example">Single Currency Example</h3>
<p>After initiating the basic variables, we use the WebSocket address to create the connection, the <em>onmessage</em> function listens for a message event which is then parsed to get our price property.</p>
<p>Here is the code sample to get the price stream for <em>ETH</em> to <em>USD</em></p>
<pre><code class="lang-javascript"><span class="hljs-comment">//Web socket ethusd stream</span>
<span class="hljs-keyword">let</span> ws= <span class="hljs-keyword">new</span> WebSocket(<span class="hljs-string">'wss://stream.binance.com:9443/ws/ethusdt@trade'</span>);


<span class="hljs-keyword">let</span> ethUsdt= <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'eth'</span>);
<span class="hljs-keyword">let</span> lastPrice = <span class="hljs-literal">null</span>;

<span class="hljs-keyword">let</span> price= <span class="hljs-literal">null</span>;

<span class="hljs-comment">//Recieves a message event and parses it as a JSON object</span>
ws.onmessage= <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span>{
    <span class="hljs-keyword">let</span> eventData = <span class="hljs-built_in">JSON</span>.parse(event.data);

        price=<span class="hljs-built_in">parseFloat</span>(eventData.p).toFixed(<span class="hljs-number">2</span>); <span class="hljs-comment">//parses the price property and rounds it up to two decimal places</span>

    ethUsdt.innerText=price;
}
</code></pre>
<p>Here it isimplemented on Codepen</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://codepen.io/MichaelEnigma/pen/BaOrPKV">https://codepen.io/MichaelEnigma/pen/BaOrPKV</a></div>
<p> </p>
<p>What of scenarios were we are watching for multiple currencies? From the Binance API guide, the WebSocket address will take this form, <em>wss://</em><a target="_blank" href="http://stream.binance.us:9443"><em>stream.binance.us:9443</em></a><em>/stream?streams=&lt;streamName1&gt;/&lt;streamName2&gt;/&lt;streamName3&gt;</em> where each stream represents a currency pair.</p>
<h3 id="heading-full-dashboard-integration">Full Dashboard Integration</h3>
<p>We will use a dashboard template to display the price stream for Bitcoin, Ethereum, Ripple, and Litecoin.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678866776191/a8109b5d-d133-40aa-ac12-e0066a84be80.png" alt class="image--center mx-auto" /></p>
<p>The WebSocket connection now streams in the message events for the various currency pairs, we'll create conditions to assign the proper currency events to their respective price variables.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">//Binance multicurrency stream</span>
<span class="hljs-keyword">let</span> ws= <span class="hljs-keyword">new</span> WebSocket(<span class="hljs-string">'wss://stream.binance.com/stream?streams=ethusdt@trade/btcusdt@trade/xrpusdt@trade/ltcusdt@trade'</span>);
<span class="hljs-comment">// we intialize the variables to hold our prices</span>
<span class="hljs-keyword">let</span> ethUsdt= <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'eth'</span>);
<span class="hljs-keyword">let</span> lastPrice = <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> btcUsdt= <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'btc'</span>);
<span class="hljs-keyword">let</span> btclastPrice = <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> xrpUsdt= <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'xrp'</span>);
<span class="hljs-keyword">let</span> xrplastPrice = <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> ltcUsdt= <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'ltc'</span>);
<span class="hljs-keyword">let</span> ltclastPrice = <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> price= <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> btcprice= <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> xrpprice= <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> ltcprice= <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> collection = <span class="hljs-built_in">document</span>.getElementsByClassName(<span class="hljs-string">"bi"</span>);

<span class="hljs-comment">//Recieves a message event and parses it as a JSON object</span>
ws.onmessage= <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span>{
    <span class="hljs-keyword">let</span> eventData = <span class="hljs-built_in">JSON</span>.parse(event.data);
<span class="hljs-comment">// these conditions assigns the various currency prices based on the currency pair</span>
    <span class="hljs-keyword">if</span> (eventData.stream==<span class="hljs-string">'ethusdt@trade'</span>){
        price=<span class="hljs-built_in">parseFloat</span>(eventData.data.p).toFixed(<span class="hljs-number">2</span>);



    }
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(eventData.stream==<span class="hljs-string">'btcusdt@trade'</span>){
        btcprice=<span class="hljs-built_in">parseFloat</span>(eventData.data.p).toFixed(<span class="hljs-number">2</span>);


    }
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(eventData.stream==<span class="hljs-string">'xrpusdt@trade'</span>){
        xrpprice=<span class="hljs-built_in">parseFloat</span>(eventData.data.p).toFixed(<span class="hljs-number">3</span>);


    }
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(eventData.stream==<span class="hljs-string">'ltcusdt@trade'</span>){
        ltcprice=<span class="hljs-built_in">parseFloat</span>(eventData.data.p).toFixed(<span class="hljs-number">2</span>);


    }


    ethUsdt.innerText=price;
</code></pre>
<p>For monitoring the changing prices on the dashboard, we'll use <a target="_blank" href="https://fontawesome.com/">Font Awesome</a> caret up and down icons to give visual indicators about whether the value of the prices is going up or down, an <em>&lt;i&gt;</em> element whose classes are dynamically changed will be used for this purpose.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"row m-t-25"</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"col-lg-3"</span>&gt;</span>
                    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card currency-card-rounded"</span>&gt;</span>
                        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card-body rounded bitcoin"</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"currency-card--icon pull-right"</span>&gt;</span>
                                <span class="hljs-tag">&lt;<span class="hljs-name">i</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"cc BTC-alt"</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"BTC"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">i</span>&gt;</span>
                            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">h4</span>&gt;</span>Bitcoin<span class="hljs-tag">&lt;/<span class="hljs-name">h4</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>
                                $<span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"btc"</span>&gt;</span>1.765<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">i</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"bi "</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">i</span>&gt;</span>
                            <span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>

                        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"col-lg-3"</span>&gt;</span>
                    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card currency-card-rounded"</span>&gt;</span>
                        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card-body rounded ethereum"</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"currency-card--icon pull-right"</span>&gt;</span>
                                <span class="hljs-tag">&lt;<span class="hljs-name">i</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"cc ETH-alt"</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"ETH"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">i</span>&gt;</span>
                            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">h4</span>&gt;</span>Ethereum<span class="hljs-tag">&lt;/<span class="hljs-name">h4</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>
                                $<span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"eth"</span>&gt;</span>1.765<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">i</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"bi "</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">i</span>&gt;</span>
                            <span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>

                        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"col-lg-3"</span>&gt;</span>
                    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card currency-card-rounded"</span>&gt;</span>
                        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card-body rounded ripple"</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"currency-card--icon pull-right"</span>&gt;</span>
                                <span class="hljs-tag">&lt;<span class="hljs-name">i</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"cc XRP-alt"</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"XRP"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">i</span>&gt;</span>
                            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">h4</span>&gt;</span>Ripple<span class="hljs-tag">&lt;/<span class="hljs-name">h4</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>
                                $<span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"xrp"</span>&gt;</span>1.765<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">i</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"bi "</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">i</span>&gt;</span>
                            <span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>

                        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"col-lg-3"</span>&gt;</span>
                    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card currency-card-rounded"</span>&gt;</span>
                        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card-body rounded litecoin"</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"currency-card--icon pull-right"</span>&gt;</span>
                                <span class="hljs-tag">&lt;<span class="hljs-name">i</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"cc LTC-alt"</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"LTC"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">i</span>&gt;</span>
                            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">h4</span>&gt;</span>Litecoin<span class="hljs-tag">&lt;/<span class="hljs-name">h4</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>
                                $<span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"ltc"</span>&gt;</span>1.765<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">i</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"bi "</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">i</span>&gt;</span>
                            <span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>

                        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>We'll then include the rest of the Javascript code that allows for this functionality.</p>
<pre><code class="lang-javascript">

<span class="hljs-comment">// let ws= new WebSocket('wss://stream.binance.com:9443/ws/ethusdt@trade');</span>
<span class="hljs-keyword">let</span> ws= <span class="hljs-keyword">new</span> WebSocket(<span class="hljs-string">'wss://stream.binance.com/stream?streams=ethusdt@trade/btcusdt@trade/xrpusdt@trade/ltcusdt@trade'</span>);

<span class="hljs-keyword">let</span> ethUsdt= <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'eth'</span>);
<span class="hljs-keyword">let</span> lastPrice = <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> btcUsdt= <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'btc'</span>);
<span class="hljs-keyword">let</span> btclastPrice = <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> xrpUsdt= <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'xrp'</span>);
<span class="hljs-keyword">let</span> xrplastPrice = <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> ltcUsdt= <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'ltc'</span>);
<span class="hljs-keyword">let</span> ltclastPrice = <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> price= <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> btcprice= <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> xrpprice= <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> ltcprice= <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> collection = <span class="hljs-built_in">document</span>.getElementsByClassName(<span class="hljs-string">"bi"</span>); <span class="hljs-comment">//holds the array of &lt;i&gt; elements</span>

ws.onmessage= <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span>{
    <span class="hljs-keyword">let</span> eventData = <span class="hljs-built_in">JSON</span>.parse(event.data);
    <span class="hljs-keyword">if</span> (eventData.stream==<span class="hljs-string">'ethusdt@trade'</span>){
        price=<span class="hljs-built_in">parseFloat</span>(eventData.data.p).toFixed(<span class="hljs-number">2</span>);



    }
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(eventData.stream==<span class="hljs-string">'btcusdt@trade'</span>){
        btcprice=<span class="hljs-built_in">parseFloat</span>(eventData.data.p).toFixed(<span class="hljs-number">2</span>);


    }
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(eventData.stream==<span class="hljs-string">'xrpusdt@trade'</span>){
        xrpprice=<span class="hljs-built_in">parseFloat</span>(eventData.data.p).toFixed(<span class="hljs-number">3</span>);


    }
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(eventData.stream==<span class="hljs-string">'ltcusdt@trade'</span>){
        ltcprice=<span class="hljs-built_in">parseFloat</span>(eventData.data.p).toFixed(<span class="hljs-number">2</span>);


    }


    ethUsdt.innerText=price;

    <span class="hljs-comment">// conditions to add the caret icons</span>
   <span class="hljs-keyword">if</span> (price&gt;lastPrice){
    collection[<span class="hljs-number">0</span>].classList.remove(<span class="hljs-string">"bi-caret-down-fill"</span>);
    collection[<span class="hljs-number">0</span>].classList.add( <span class="hljs-string">"bi-caret-up-fill"</span> );
    collection[<span class="hljs-number">0</span>].style.color=<span class="hljs-string">'green'</span>;
   }
   <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (price&lt;lastPrice){
    collection[<span class="hljs-number">0</span>].classList.remove(<span class="hljs-string">"bi-caret-up-fill"</span>);
    collection[<span class="hljs-number">0</span>].classList.add( <span class="hljs-string">"bi-caret-down-fill"</span> );
    collection[<span class="hljs-number">0</span>].style.color=<span class="hljs-string">'red'</span>;
   }


    lastPrice=price; <span class="hljs-comment">// after the conditons are fulfilled the value of the lastprice is changed to the current price</span>

    btcUsdt.innerText=btcprice;

    <span class="hljs-keyword">if</span> (btcprice&gt;btclastPrice){
        collection[<span class="hljs-number">1</span>].classList.remove(<span class="hljs-string">"bi-caret-down-fill"</span>);
        collection[<span class="hljs-number">1</span>].classList.add( <span class="hljs-string">"bi-caret-up-fill"</span> );
        collection[<span class="hljs-number">1</span>].style.color=<span class="hljs-string">'green'</span>;
       }
       <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (btcprice&lt;btclastPrice){
        collection[<span class="hljs-number">1</span>].classList.remove(<span class="hljs-string">"bi-caret-up-fill"</span>);
        collection[<span class="hljs-number">1</span>].classList.add( <span class="hljs-string">"bi-caret-down-fill"</span> );
        collection[<span class="hljs-number">1</span>].style.color=<span class="hljs-string">'red'</span>;
       }    

    btclastPrice=btcprice;

    xrpUsdt.innerText=xrpprice;

    <span class="hljs-keyword">if</span> (xrpprice&gt;xrplastPrice){
        collection[<span class="hljs-number">2</span>].classList.remove(<span class="hljs-string">"bi-caret-down-fill"</span>);
        collection[<span class="hljs-number">2</span>].classList.add( <span class="hljs-string">"bi-caret-up-fill"</span> );
        collection[<span class="hljs-number">2</span>].style.color=<span class="hljs-string">'green'</span>;
       }
       <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (xrpprice&lt;xrplastPrice){
        collection[<span class="hljs-number">2</span>].classList.remove(<span class="hljs-string">"bi-caret-up-fill"</span>);
        collection[<span class="hljs-number">2</span>].classList.add( <span class="hljs-string">"bi-caret-down-fill"</span> );
        collection[<span class="hljs-number">2</span>].style.color=<span class="hljs-string">'red'</span>;
       }

    xrplastPrice=xrpprice;

    ltcUsdt.innerText=ltcprice;

    <span class="hljs-keyword">if</span> (ltcprice&gt;ltclastPrice){
        collection[<span class="hljs-number">3</span>].classList.remove(<span class="hljs-string">"bi-caret-down-fill"</span>);
        collection[<span class="hljs-number">3</span>].classList.add( <span class="hljs-string">"bi-caret-up-fill"</span> );
        collection[<span class="hljs-number">3</span>].style.color=<span class="hljs-string">'green'</span>;
       }
       <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (ltcprice&lt;ltclastPrice){
        collection[<span class="hljs-number">3</span>].classList.remove(<span class="hljs-string">"bi-caret-up-fill"</span>);
        collection[<span class="hljs-number">3</span>].classList.add( <span class="hljs-string">"bi-caret-down-fill"</span> );
        collection[<span class="hljs-number">3</span>].style.color=<span class="hljs-string">'red'</span>;
       }

    ltclastPrice=ltcprice;


}
</code></pre>
<p>And voila! we have our real-time dashboard, the link to the full code is in this <a target="_blank" href="https://github.com/MicahelE/CoinWatcher">repo</a></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678875724346/92ca4aad-6f48-4094-a2af-93d9d8539e9e.gif" alt class="image--center mx-auto" /></p>
<p>Awesome! We have demonstrated the practical use of WebSockets in building a real-time cryptocurrency dashboard, what project ideas do you have that this technology will prove to be valuable? Let me know in the comments section.</p>
]]></content:encoded></item><item><title><![CDATA[How to Create an NFT Token]]></title><description><![CDATA[NFT(Non-Fungible Tokens) are tokens used to represent digital assets with inherent properties that are unique and that cannot be exchanged or interchanged(fungible), in many cases, they are used to represent items like images, art, etc. The Ethereum ...]]></description><link>https://blog.michaeltech.xyz/how-to-create-an-nft-token</link><guid isPermaLink="true">https://blog.michaeltech.xyz/how-to-create-an-nft-token</guid><category><![CDATA[Web Development]]></category><category><![CDATA[Web3]]></category><category><![CDATA[software development]]></category><category><![CDATA[Ethereum]]></category><category><![CDATA[NFT]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Mon, 27 Feb 2023 15:36:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/jaApF6TiJ7s/upload/c1d0736bfe7bc0e902acc06712e5c277.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>NFT(Non-Fungible Tokens) are tokens used to represent digital assets with inherent properties that are unique and that cannot be exchanged or interchanged(fungible), in many cases, they are used to represent items like images, art, etc. The Ethereum blockchain has a unique standard called the ERC721 for defining the functionality of these tokens. We will follow the template pattern of using Hardhat, Metamask, Alchemy, etc to build our smart contract just like in our other solidity <a target="_blank" href="https://blog.michaeltech.xyz/deploying-a-custom-created-cryptocurrency-on-the-ethereum-network">tutorials</a></p>
<h3 id="heading-project-setup">Project Setup</h3>
<pre><code class="lang-bash">mkdir MikNFT
<span class="hljs-built_in">cd</span> MikNFT
npm init -y

npm install --save-dev hardhat
npx hardhat

npm i @openzeppelin/contracts
</code></pre>
<p>The code below imports the ERC721 library and inherits all the function implementation for ERC721, it also uses the Counters library which will be used for counting the number of tokens and giving each a unique positive integer value.</p>
<p>The contract is initialized with the name and symbol for the token the <em>mintNFT</em> function takes into two parameters the <em>address</em> where the NFT will be sent and the <em>tokenURI</em> which gives the metadata description of the token, it then returns the unique integer id of the token</p>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.8.17;</span>

<span class="hljs-keyword">import</span> <span class="hljs-string">"@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"@openzeppelin/contracts/utils/Counters.sol"</span>;

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">MikNFT</span> <span class="hljs-keyword">is</span> <span class="hljs-title">ERC721URIStorage</span> </span>{
    <span class="hljs-keyword">using</span> <span class="hljs-title">Counters</span> <span class="hljs-title"><span class="hljs-keyword">for</span></span> <span class="hljs-title">Counters</span>.<span class="hljs-title">Counter</span>;
    Counters.Counter <span class="hljs-keyword">private</span> _tokenIds;

    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) <span class="hljs-title">ERC721</span>(<span class="hljs-params"><span class="hljs-string">"MikNFT"</span>, <span class="hljs-string">"NFT"</span></span>) </span>{}

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">mintNFT</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> recipient, <span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> tokenURI</span>)
        <span class="hljs-title"><span class="hljs-keyword">public</span></span>

        <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint256</span></span>)
    </span>{
        _tokenIds.increment();

        <span class="hljs-keyword">uint256</span> newItemId <span class="hljs-operator">=</span> _tokenIds.current();
        _mint(recipient, newItemId);
        _setTokenURI(newItemId, tokenURI);

        <span class="hljs-keyword">return</span> newItemId;
    }
}
</code></pre>
<p>after it has successfully complied with this command,</p>
<pre><code class="lang-bash">npx hardhat compile
</code></pre>
<p>we'll install the <em>dotenv</em> package to enable us to interact with our environment variables. The environment variables that will be used are the wallet private key, <em>API_URL,</em> and <em>API_KEY,</em> these will be kept in a <em>.env</em> file that will be added to the project's <em>.gitignore</em> list as these variables are quite sensitive and are not to be uploaded to a public repository.</p>
<pre><code class="lang-bash">npm install dotenv --save
</code></pre>
<pre><code class="lang-bash">API_URL = <span class="hljs-string">"https://eth-goerli.g.alchemy.com/v2/api-key"</span>
PRIVATE_KEY = <span class="hljs-string">"metamask-private-key"</span>
API_KEY = <span class="hljs-string">"api-key"</span>
</code></pre>
<p>We'll go straight ahead to create our <em>hardhat.config.js</em> in the root folder and <em>deploy.js</em> in the scripts folder respectively, the <em>deploy.js</em> script uses the <em>Ethers.js</em> library to handle the deployment of our smart contract.</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">require</span>(<span class="hljs-string">'dotenv'</span>).config();
<span class="hljs-built_in">require</span>(<span class="hljs-string">"@nomiclabs/hardhat-ethers"</span>);


<span class="hljs-keyword">const</span> { API_URL, PRIVATE_KEY } = process.env;

<span class="hljs-built_in">module</span>.exports = {
  <span class="hljs-attr">solidity</span>: <span class="hljs-string">"0.8.17"</span>,
  <span class="hljs-attr">defaultNetwork</span>: <span class="hljs-string">"goerli"</span>,
  <span class="hljs-attr">networks</span>: {
    <span class="hljs-attr">hardhat</span>: {},
    <span class="hljs-attr">goerli</span>: {
       <span class="hljs-attr">url</span>: API_URL,
       <span class="hljs-attr">accounts</span>: [<span class="hljs-string">`0x<span class="hljs-subst">${PRIVATE_KEY}</span>`</span>]
    }
 },
};
</code></pre>
<pre><code class="lang-javascript">

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">main</span>(<span class="hljs-params"></span>) </span>{

<span class="hljs-comment">// Grab Contract Factory</span>
  <span class="hljs-keyword">const</span> MikNFT = <span class="hljs-keyword">await</span> ethers.getContractFactory(<span class="hljs-string">"MikNFT"</span>);

     <span class="hljs-comment">// Start deployment, returning a promise that resolves to a contract object</span>
  <span class="hljs-keyword">const</span> mikNFT= <span class="hljs-keyword">await</span> MikNFT.deploy(); <span class="hljs-comment">// Instance of the contract </span>

  <span class="hljs-built_in">console</span>.log(
    <span class="hljs-string">"Contract deployed to address:"</span>, mikNFT.address );
}

<span class="hljs-comment">// We recommend this pattern to be able to use async/await everywhere</span>
<span class="hljs-comment">// and properly handle errors.</span>
main()
.then(<span class="hljs-function">()=&gt;</span> process.exit(<span class="hljs-number">0</span>))
.catch(<span class="hljs-function">(<span class="hljs-params">error</span>) =&gt;</span> {
  <span class="hljs-built_in">console</span>.error(error);
  process.exit(<span class="hljs-number">1</span>);
});
</code></pre>
<p>Let's deploy the smart contract on the goerli testnet</p>
<pre><code class="lang-bash">npx hardhat run scripts/deploy.js --network goerli
</code></pre>
<p>At the end of the deployment, the contract address will be shown, this is what we'll use to check the details of our transaction on goerli etherscan</p>
<pre><code class="lang-bash">Contract deployed to address: 0x52Fb82C6D01F4077F18508C1ab59560c651A9099
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677502583866/aef4ae65-baa1-4ae9-8b6f-8c75fcf82fac.png" alt class="image--center mx-auto" /></p>
<p>You have successfully deployed your NFT smart contract! The next step is to use the contract to mint an NFT</p>
<h3 id="heading-minting-nft">Minting NFT</h3>
<p>So we will decide what we want to put up as an NFT, I 'dreamed' up a really cool art piece using an AI image generation <a target="_blank" href="https://dream.ai/">tool</a> called Wombo, you can check it out.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677510545877/8f7846e1-dabc-403b-93a7-29759a5d5a2d.png" alt class="image--center mx-auto" /></p>
<p>The primary way to store NFTs is on IPFS(Interplanetary File System) platforms which are decentralized file-sharing networks for keeping data. We'll use <a target="_blank" href="https://www.pinata.cloud/">Pinata</a> for our example. After creating an account on the platform, we'll upload our image and copy the hash code or content identifier that was generated from the successful upload, the address of the image will be represented like this <a target="_blank" href="https://gateway.pinata.cloud/ipfs/">https://gateway.pinata.cloud/ipfs/</a><a target="_blank" href="https://gateway.pinata.cloud/ipfs/QmarPqdEuzh5RsWpyH2hZ3qSXBCzC5RyK3ZHnFkAsk7u2f">&lt;</a>hash-code&gt;</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677505110141/ffd9c678-bd89-4234-89ee-4db404ab322d.png" alt class="image--center mx-auto" /></p>
<p>Then go ahead to create a nft-metadata.json file that provides all the vital attributes for your NFT, make sure the image points to the address of the image, and when this is done make sure this is also uploaded to Pinata and the URL address noted.</p>
<pre><code class="lang-json">{
    <span class="hljs-attr">"attributes"</span> : [ {
      <span class="hljs-attr">"trait_type"</span> : <span class="hljs-string">"Background"</span>,
      <span class="hljs-attr">"value"</span> : <span class="hljs-string">"forest"</span>
    }, {
      <span class="hljs-attr">"trait_type"</span> : <span class="hljs-string">"flag"</span>,
      <span class="hljs-attr">"value"</span> : <span class="hljs-string">"Nigeria"</span>
    } ],
    <span class="hljs-attr">"description"</span> : <span class="hljs-string">"car moving in a country background, flag seen in the skyline, locally dressed man"</span>,
    <span class="hljs-attr">"image"</span> : <span class="hljs-string">"https://gateway.pinata.cloud/ipfs/Qmcp8yj1rBBSJAHmUq3rd3oYF5Uhy2ftBLGLGG4SpPSvzP"</span>,
    <span class="hljs-attr">"name"</span> : <span class="hljs-string">"Nairaland"</span>
}
</code></pre>
<p>we then create a mint-nft.js file that will execute the minting of our NFT, we'll use the contracts' ABI for that, the ABI is a json formatted interface used to interact with the contract, it is automatically generated by hardhat when the contract is compiled, the ABI for this contract is generated in this location.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> contract = <span class="hljs-built_in">require</span>(<span class="hljs-string">"../artifacts/contracts/MikNFT.sol/MikNFT.json"</span>);
</code></pre>
<p>the contract will use the ether library to connect with our node provider using our API key earlier defined in our .env file, it will also use the wallet's private key, the contract's address and the contract's abi to define the contract</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">require</span>(<span class="hljs-string">'dotenv'</span>).config();
<span class="hljs-keyword">const</span> { AlchemyProvider } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'@ethersproject/providers'</span>);
<span class="hljs-keyword">const</span> ethers= <span class="hljs-built_in">require</span>(<span class="hljs-string">'ethers'</span>);

<span class="hljs-comment">// Get Alchemy API key</span>
<span class="hljs-keyword">const</span> API_KEY= process.env.API_KEY;
<span class="hljs-comment">// Define an Alchemy Provider</span>
<span class="hljs-keyword">const</span> provider= <span class="hljs-keyword">new</span> ethers.providers.AlchemyProvider(<span class="hljs-string">'goerli'</span>, API_KEY);

<span class="hljs-keyword">const</span> privateKey=process.env.PRIVATE_KEY;
<span class="hljs-keyword">const</span> signer= <span class="hljs-keyword">new</span> ethers.Wallet(privateKey, provider);
<span class="hljs-comment">// Get contract ABI and address</span>
<span class="hljs-keyword">const</span> abi=contract.abi;
<span class="hljs-keyword">const</span> contractAddress=<span class="hljs-string">'0x52fb82c6d01f4077f18508c1ab59560c651a9099'</span>;

<span class="hljs-comment">// Create a contract instance</span>
<span class="hljs-keyword">const</span> myNftContract= <span class="hljs-keyword">new</span> ethers.Contract(contractAddress, abi, signer);
</code></pre>
<p>the <em>tokenURI</em> for our NFT image will now be used and defined in our script, this is how the final version of our <em>mint-nft.js</em> script will look like</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> contract = <span class="hljs-built_in">require</span>(<span class="hljs-string">"../artifacts/contracts/MikNFT.sol/MikNFT.json"</span>);
<span class="hljs-built_in">require</span>(<span class="hljs-string">'dotenv'</span>).config();
<span class="hljs-keyword">const</span> { AlchemyProvider } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'@ethersproject/providers'</span>);
<span class="hljs-keyword">const</span> ethers= <span class="hljs-built_in">require</span>(<span class="hljs-string">'ethers'</span>);

<span class="hljs-comment">// Get Alchemy API key</span>
<span class="hljs-keyword">const</span> API_KEY= process.env.API_KEY;
<span class="hljs-comment">// Define an Alchemy Provider</span>
<span class="hljs-keyword">const</span> provider= <span class="hljs-keyword">new</span> ethers.providers.AlchemyProvider(<span class="hljs-string">'goerli'</span>, API_KEY);




<span class="hljs-keyword">const</span> privateKey=process.env.PRIVATE_KEY;
<span class="hljs-keyword">const</span> signer= <span class="hljs-keyword">new</span> ethers.Wallet(privateKey, provider);

<span class="hljs-comment">// Get contract ABI and address</span>
<span class="hljs-keyword">const</span> abi=contract.abi;
<span class="hljs-keyword">const</span> contractAddress=<span class="hljs-string">'0x52fb82c6d01f4077f18508c1ab59560c651a9099'</span>;

<span class="hljs-comment">// Create a contract instance</span>
<span class="hljs-keyword">const</span> myNftContract= <span class="hljs-keyword">new</span> ethers.Contract(contractAddress, abi, signer);

<span class="hljs-keyword">const</span> tokenUri= <span class="hljs-string">"https://gateway.pinata.cloud/ipfs/QmQRJK9mMtueyJN9APfQGCdsT1pHELZ9dKN1mcjaRV8qHo"</span>;

<span class="hljs-comment">// Call mintNFT function</span>
<span class="hljs-keyword">const</span> mintNFT = <span class="hljs-keyword">async</span> () =&gt; {
    <span class="hljs-keyword">let</span> nftTxn = <span class="hljs-keyword">await</span> myNftContract.mintNFT(signer.address, tokenUri)
    <span class="hljs-keyword">await</span> nftTxn.wait()
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`NFT Minted! Check it out at: https://goerli.etherscan.io/tx/<span class="hljs-subst">${nftTxn.hash}</span>`</span>)
}

mintNFT()
    .then(<span class="hljs-function">() =&gt;</span> process.exit(<span class="hljs-number">0</span>))
    .catch(<span class="hljs-function">(<span class="hljs-params">error</span>) =&gt;</span> {
        <span class="hljs-built_in">console</span>.error(error);
        process.exit(<span class="hljs-number">1</span>);
    });
</code></pre>
<p>run the below command to execute our script</p>
<pre><code class="lang-bash">node scripts/mint-nft.js
</code></pre>
<p>Our output will be like this</p>
<pre><code class="lang-bash">NFT Minted! Check it out at: https://goerli.etherscan.io/tx/0x907e775d3b45507eb17af5bd97b65c58457b7354354157c7ef148e32f2f8f31c
</code></pre>
<p>Awesome! what cool NFT project can you spin-off? Happy NFTing!</p>
]]></content:encoded></item><item><title><![CDATA[Deploying a custom-created cryptocurrency on the Ethereum network.]]></title><description><![CDATA[The advent of web3 has brought with it an ability to design tokens that act as a store of value or as virtual concurrency on the blockchain, the ERC20 is an Ethereum standard for creating fungible tokens, it provides the standard functionalities that...]]></description><link>https://blog.michaeltech.xyz/deploying-a-custom-created-cryptocurrency-on-the-ethereum-network</link><guid isPermaLink="true">https://blog.michaeltech.xyz/deploying-a-custom-created-cryptocurrency-on-the-ethereum-network</guid><category><![CDATA[Web Development]]></category><category><![CDATA[Web3]]></category><category><![CDATA[Cryptocurrency]]></category><category><![CDATA[token]]></category><category><![CDATA[Ethereum]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Sat, 11 Feb 2023 20:44:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/aD77eIRI320/upload/f2a374119ff151f46b12273587a776c7.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The advent of web3 has brought with it an ability to design tokens that act as a store of value or as virtual concurrency on the blockchain, the ERC20 is an Ethereum standard for creating fungible tokens, it provides the standard functionalities that should be incorporated to make it follow best practices. We'll be looking at how to set up and deploy a custom coin with the necessary attributes of an ERC20 token.</p>
<p>To get this done we'll need a decentralized wallet like Metamask and a web3 node provider like Alchemy. An Ethereum development environment like Truffle or hardhat plays an essential role in producing a smooth code-building experience we'll use Hardhat to write, configure and deploy our solidity code for this exercise.</p>
<h3 id="heading-initializing-our-project"><strong>Initializing our project</strong></h3>
<p>Make sure you have Node js installed on the system, create and navigate to the token project folder and run npm init to initialize the project</p>
<pre><code class="lang-bash">mkdir PokeCoin
<span class="hljs-built_in">cd</span> PokeCoin
npm init -y
</code></pre>
<h3 id="heading-install-and-create-hardhat-project">Install and create hardhat project</h3>
<pre><code class="lang-bash">npm install --save-dev hardhat
npx hardhat
</code></pre>
<p>A welcome message and some options will be shown, go ahead to select ' Create a JavaScript Project'. Delete the default <em>Lock.sol</em> and <em>Lock.js</em> files in the contracts and test folders respectively.</p>
<p>Install the <em>openzeppelin</em> library with the below command to access the ERC20 standard that will be imported to create our token</p>
<pre><code class="lang-bash">npm i @openzeppelin/contracts
</code></pre>
<p>Under the contract folder create a file called PokeCoin.sol, this is where we'll write the smart contract that implements our PokeCoin token. The contract is quite self-explanatory, the first two lines specify the license type of the contract and the solidity compiler version to be used for the file, the ERC20 library is then imported and then immediately inherited by the PokeCoin contract, the token name and symbol are then loaded and then passed through the constructor parameters, we'll go ahead to use the base function <em>mint</em> in the ERC20 contract, this will mint the initial desired amount of token and send it to the creator's wallet.</p>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: UNLICENSED</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.8.9;</span>

 <span class="hljs-keyword">import</span> <span class="hljs-string">"@openzeppelin/contracts/token/ERC20/ERC20.sol"</span>;


<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">PokeCoin</span> <span class="hljs-keyword">is</span> <span class="hljs-title">ERC20</span></span>{

    <span class="hljs-keyword">uint</span> <span class="hljs-keyword">constant</span> _initial_supply<span class="hljs-operator">=</span> <span class="hljs-number">100</span> <span class="hljs-operator">*</span> (<span class="hljs-number">10</span><span class="hljs-operator">*</span><span class="hljs-operator">*</span><span class="hljs-number">18</span>); <span class="hljs-comment">// Initial deposit in creators wallet </span>

    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) <span class="hljs-title">ERC20</span>(<span class="hljs-params"><span class="hljs-string">"PokeCoin"</span>, <span class="hljs-string">"POK"</span></span>)  </span>{ <span class="hljs-comment">// Token description</span>

        _mint(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, _initial_supply);

    }

}
</code></pre>
<h3 id="heading-connect-wallet-and-node-provider"><strong>Connect Wallet and Node Provider</strong></h3>
<p>We'll use Metamask as our wallet, and Alchemy as the node provider, our wallet's private key and the unique Alchemy project key, these will be stored and used in a .env file for the deployment and interaction of the contract. Follow these <a target="_blank" href="https://metamask.zendesk.com/hc/en-us/articles/360015289632-How-to-Export-an-Account-Private-Key">steps</a> to get your Metamask private key and the below image for <a target="_blank" href="https://www.alchemy.com/">Alchemy</a></p>
<p><img src="https://3169887760-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB17w56kk7ZnRMWdqOL%2F-MUtwV_6rca7wa6qwo-C%2F-MUtx0zE2RLVnSseCfFG%2Fget%20alchemy%20api%20key.gif?alt=media&amp;token=7cfb36de-acb4-480a-aac8-bc64dc134339" alt="HTTP Alchemy API URL" /></p>
<p>Make sure when committing this project to your git repository that your .env file is part of the .gitignore list of files and folders as the information there are quite sensitive and could be easily used by hackers to tamper with your accounts.</p>
<p>Create your .<em>env</em> file with this command..</p>
<pre><code class="lang-bash">npm install dotenv --save
</code></pre>
<p>and put the necessary keys in the .env file like this</p>
<pre><code class="lang-bash">API_URL = <span class="hljs-string">"https://eth-goerli.g.alchemy.com/v2/your-api-key"</span>
PRIVATE_KEY = <span class="hljs-string">"your-metamask-private-key"</span>
</code></pre>
<h3 id="heading-install-etherjs-and-configure-deployment"><strong>Install Ether.js and configure deployment</strong></h3>
<p>We'll use the hardhat plugin <em>hardhat-ethers</em> that is integrated with <em>Ethers.js</em> this allows for simple interactions with the Ethereum blockchain</p>
<pre><code class="lang-bash">npm install --save-dev @nomiclabs/hardhat-ethers <span class="hljs-string">"ethers@^5.0.0"</span>
</code></pre>
<p>Then go ahead to configure the <em>hardhat.config.js</em> to require the ether library and the Goerli test network we're going to be using</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">require</span>(<span class="hljs-string">"@nomicfoundation/hardhat-toolbox"</span>);




<span class="hljs-built_in">require</span>(<span class="hljs-string">'dotenv'</span>).config();
<span class="hljs-built_in">require</span>(<span class="hljs-string">"@nomiclabs/hardhat-ethers"</span>);

<span class="hljs-keyword">const</span> { API_URL, PRIVATE_KEY } = process.env;

<span class="hljs-built_in">module</span>.exports = {
  <span class="hljs-attr">solidity</span>: <span class="hljs-string">"0.8.17"</span>,
  <span class="hljs-attr">defaultNetwork</span>: <span class="hljs-string">"goerli"</span>,
  <span class="hljs-attr">networks</span>: {
    <span class="hljs-attr">hardhat</span>: {},
    <span class="hljs-attr">goerli</span>: {
       <span class="hljs-attr">url</span>: API_URL,
       <span class="hljs-attr">accounts</span>: [<span class="hljs-string">`0x<span class="hljs-subst">${PRIVATE_KEY}</span>`</span>]
    }
 },
};
</code></pre>
<p>We can go ahead to compile the solidity file with the command</p>
<pre><code class="lang-bash">npx hardhat compile
</code></pre>
<p>Once this is successful, we'll configure our deployment script <em>deploy.js</em> to work like this</p>
<pre><code class="lang-javascript">

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">main</span>(<span class="hljs-params"></span>) </span>{

  <span class="hljs-keyword">const</span> [deployer]= <span class="hljs-keyword">await</span> ethers.getSigners();
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Deploying contracts with the account: "</span>,deployer.address);
  <span class="hljs-keyword">const</span> weiAmount = (<span class="hljs-keyword">await</span> deployer.getBalance()).toString();

  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Account balance:"</span>, (<span class="hljs-keyword">await</span> ethers.utils.formatEther(weiAmount)));
  <span class="hljs-keyword">const</span> Token = <span class="hljs-keyword">await</span> ethers.getContractFactory(<span class="hljs-string">"Mikoin"</span>);
  <span class="hljs-keyword">const</span> token = <span class="hljs-keyword">await</span> Token.deploy();

  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Token Address"</span>, token.address);

}

main()
.then(<span class="hljs-function">() =&gt;</span> process.exit(<span class="hljs-number">0</span>))
.catch(<span class="hljs-function">(<span class="hljs-params">error</span>) =&gt;</span> {
  <span class="hljs-built_in">console</span>.error(error);
  process.exit(<span class="hljs-number">1</span>);
}
)

<span class="hljs-comment">// We recommend this pattern to be able to use async/await everywhere</span>
<span class="hljs-comment">// and properly handle errors.</span>
</code></pre>
<p>Go ahead to deploy your contract to the goerli testnet</p>
<pre><code class="lang-javascript">npx hardhat run scripts/deploy.js --network goerli
</code></pre>
<p>When the script is run successfully from the deployment script the console output logs the contract address, account balance, and token address. Congratulations! You can check out the record of the goerli transaction using the contract or token address using <a target="_blank" href="https://goerli.etherscan.io/">https://goerli.etherscan.io/</a>. Your custom token has also been sent to your Metamask account. To see your token, use your token's contract address to import your token.</p>
<p><img src="https://metamask.zendesk.com/hc/article_attachments/10106386660251" alt="Import custom token MetaMask Extension" /></p>
<p>Awesome! What other token functionalities can you implement? Tinker with your smart contract and find out!</p>
]]></content:encoded></item><item><title><![CDATA[Configuring PHP for  debugging using Xdebug and VScode]]></title><description><![CDATA[Every good developer knows that in the process of software development, the ability to debug the application properly plays a vital role in the overall software delivery cycle, even for newer developers a lot is learned simply by debugging code. In t...]]></description><link>https://blog.michaeltech.xyz/configuring-php-for-debugging-using-xdebug-and-vscode</link><guid isPermaLink="true">https://blog.michaeltech.xyz/configuring-php-for-debugging-using-xdebug-and-vscode</guid><category><![CDATA[software development]]></category><category><![CDATA[debugging]]></category><category><![CDATA[PHP]]></category><category><![CDATA[XDebug]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Fri, 27 Jan 2023 22:33:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1674852581670/f57ea6a5-f6b2-42b2-b70c-e04eb5832d69.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every good developer knows that in the process of software development, the ability to debug the application properly plays a vital role in the overall software delivery cycle, even for newer developers a lot is learned simply by debugging code. In the PHP language, functions like <em>print_r, var_dump</em> are a part of the language's inbuilt tool for debugging, enabling error logging also gives the developer valuable insights into potential issues with the code.</p>
<p>That brings us to Xdebug, a PHP extension that changes the entire development feature by enriching it with features like step debugging, improved error reporting, profiling, etc. We will do a step-by-step process for installing Xdebug and using it with Vscode.</p>
<h3 id="heading-installing-xdebug-for-php">Installing Xdebug for PHP</h3>
<p>The first step is to determine the root location of the PHP you use for your local development, for me, I have multiple bundled web servers with several versions of PHP, so I had to be specific about the one I was working with to avoid confusion</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674839495604/379e4503-bf9f-4670-9dd7-fdd76fa1417c.png" alt class="image--center mx-auto" /></p>
<p>Using their <a target="_blank" href="https://xdebug.org/docs/">documentation</a></p>
<p><strong>For Unix-like systems;</strong></p>
<p>Xdebug can be easily installed using a package manager</p>
<p>Run:</p>
<pre><code class="lang-bash">pecl install xdebug
</code></pre>
<p><strong>For Windows:</strong></p>
<p>You will need to copy the output of phpinfo() or <code>php -i</code> into their installation wizard, this will give you the right version of Xdebug to install along with some instructions to install it</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674840546791/549dcaf1-3813-421d-a5cd-e2bd3f91736f.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674840292577/ef981c99-08a9-4a03-bb52-5dbc56f4d4a7.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674840690422/bb42f609-a66f-4c53-90c9-c86da7f7bd36.png" alt class="image--center mx-auto" /></p>
<p>Carefully follow the above instructions about placing the php_debug.dll file in the ext folder</p>
<p>and edit the php.ini file to add this</p>
<pre><code class="lang-php">zend_extension = xdebug
xdebug.mode    = debug
</code></pre>
<p>Run the phpinfo() or <code>php -i</code> again to determine if the extension is operational</p>
<p>then we'll install the Xdebug based extension on Vscode called PHP Debug.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674844213400/910f3966-ee2a-4d03-a153-8547315c583c.png" alt class="image--center mx-auto" /></p>
<p>From the Debug tab add configuration and select the PHP environment, this will bring out a launch.json file in the root of the project directory</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674847699497/9210cf88-c012-43bc-a5c1-94b0169dd076.png" alt class="image--center mx-auto" /></p>
<p>When you run the debugger you can add breakpoints to the code, these are the points where the code execution is paused and allows the functionalities of stepping over, in, and out of the code line by line. We also glean valuable insights into Stack traces, scope variables, superglobals, and user-defined constants as they are shown at each stage of the execution with the options to edit them, the debug console brings out all the output and relevant logs of the script.</p>
<p><img src="https://github.com/xdebug/vscode-php-debug/raw/HEAD/images/demo.gif" alt="Demo GIF" /></p>
<p>Awesome, we will now see that with the proper debugging environment setup, the whole debugging experience is transformed from a dreaded and burdensome session to a more delightful one enhancing the much-needed productivity of the development process. Happy bug-hunting!</p>
]]></content:encoded></item><item><title><![CDATA[2023 Writing Commitment]]></title><description><![CDATA[2023! it's a new year that promises to be a really great one. There are technologies to master, products to build, etc. I believe there is also a growing demand for not just software developers but sound software developers that can build systems and...]]></description><link>https://blog.michaeltech.xyz/2023-writing-commitment</link><guid isPermaLink="true">https://blog.michaeltech.xyz/2023-writing-commitment</guid><category><![CDATA[Web Development]]></category><category><![CDATA[Technical writing ]]></category><category><![CDATA[software development]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Mon, 16 Jan 2023 05:20:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/FHnnjk1Yj7Y/upload/c3864e8ecd6ea3ea7934b1f9f58275ac.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>2023! it's a new year that promises to be a really great one. There are technologies to master, products to build, etc. I believe there is also a growing demand for not just software developers but <em>sound</em> software developers that can build systems and applications that are good and reliable, superficial knowledge won't do anymore and only those that know their stuff will be able to thrive in the coming years</p>
<p>That being said, I have committed this year to invest in more consistent self-development, which involves things like standard software architecture, building projects in public, contributions to open source projects, adhering to clean practices, etc. I believe one of the best ways to cement understandings around certain domains is to teach them or articulate them in a well-written format that will be instructive to others. I look at producing biweekly( once in two weeks) articles inspired by the challenge started by <a target="_blank" href="https://twitter.com/olanetsoft/"><strong>Idris Olubisi</strong></a> <a target="_blank" href="https://twitter.com/olanetsoft/status/1606650175799365632">https://twitter.com/olanetsoft/status/1606650175799365632</a>. This is a public commitment aimed to foster accountability, I believe it is going to be an interesting and demanding journey, I might stumble around a few things, but I can only get better and better at this, that being said it's time to get to work!</p>
<iframe src="https://giphy.com/embed/8SuKOupsVwBUGGButK" width="480" height="480" class="giphy-embed"></iframe>

<p><a target="_blank" href="https://giphy.com/gifs/DiamondPetFoods-dogs-adventure-diamond-pet-foods-8SuKOupsVwBUGGButK">via GIPHY</a></p>
]]></content:encoded></item><item><title><![CDATA[Solidity Variables]]></title><description><![CDATA[Solidity is a statically typed language, which means that the type of each variable (state and local) needs to be specified.
There are 3 types of variables in Solidity

local

declared inside a function

not stored on the blockchain



state

declare...]]></description><link>https://blog.michaeltech.xyz/solidity-variables</link><guid isPermaLink="true">https://blog.michaeltech.xyz/solidity-variables</guid><category><![CDATA[Solidity]]></category><category><![CDATA[software development]]></category><category><![CDATA[Web3]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Blockchain]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Thu, 12 Jan 2023 18:34:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/gcgves5H_Ac/upload/3affc21b584c9fa952c958c9824e0ed4.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Solidity is a statically typed language, which means that the type of each variable (state and local) needs to be specified.</p>
<p>There are 3 types of variables in Solidity</p>
<ul>
<li><p><strong>local</strong></p>
<ul>
<li><p>declared inside a function</p>
</li>
<li><p>not stored on the blockchain</p>
</li>
</ul>
</li>
<li><p><strong>state</strong></p>
<ul>
<li><p>declared outside a function</p>
</li>
<li><p>stored on the blockchain</p>
</li>
</ul>
</li>
<li><p><strong>global</strong> (provides information about the blockchain)</p>
</li>
</ul>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.7.3;</span>

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Variables</span> </span>{
    <span class="hljs-comment">// State variables are stored on the blockchain.</span>
    <span class="hljs-keyword">string</span> <span class="hljs-keyword">public</span> text <span class="hljs-operator">=</span> <span class="hljs-string">"Hello"</span>;
    <span class="hljs-keyword">uint</span> <span class="hljs-keyword">public</span> num <span class="hljs-operator">=</span> <span class="hljs-number">123</span>;

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">doSomething</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
        <span class="hljs-comment">// Local variables are not saved to the blockchain.</span>
        <span class="hljs-keyword">uint</span> i <span class="hljs-operator">=</span> <span class="hljs-number">456</span>;

        <span class="hljs-comment">// Here are some global variables</span>
        <span class="hljs-keyword">uint</span> timestamp <span class="hljs-operator">=</span> <span class="hljs-built_in">block</span>.<span class="hljs-built_in">timestamp</span>; <span class="hljs-comment">// Current block timestamp</span>
        <span class="hljs-keyword">address</span> sender <span class="hljs-operator">=</span> <span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>; <span class="hljs-comment">// address of the caller</span>
    }
}
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673523262672/8eb3ef8d-dac5-4bfb-91c9-f314e5930bd9.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Data types in Solidity]]></title><description><![CDATA[Here we introduce you to some primitive data types available in Solidity.

boolean The possible values are constants true and false

uintint / uint: Signed and unsigned integers of various sizes. Keywords uint8 to uint256 in steps of 8 (unsigned of 8...]]></description><link>https://blog.michaeltech.xyz/data-types-in-solidity</link><guid isPermaLink="true">https://blog.michaeltech.xyz/data-types-in-solidity</guid><category><![CDATA[Solidity]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Web3]]></category><category><![CDATA[Blockchain]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Thu, 12 Jan 2023 18:33:30 GMT</pubDate><content:encoded><![CDATA[<p>Here we introduce you to some primitive data types available in Solidity.</p>
<ul>
<li><p><code>boolean</code> The possible values are constants <code>true</code> and <code>false</code></p>
</li>
<li><p><code>uintint</code> / <code>uint</code>: Signed and unsigned integers of various sizes. Keywords <code>uint8</code> to <code>uint256</code> in steps of <code>8</code> (unsigned of 8 up to 256 bits) and <code>int8</code> to <code>int256</code>. <code>uint</code> and <code>int</code> are aliases for <code>uint256</code> and <code>int256</code>, respectively.</p>
</li>
<li><p><code>address</code>The address type comes in two flavors, which are largely identical:</p>
<ul>
<li><p><code>address</code>: Holds a 20-byte value (the size of an Ethereum address).</p>
</li>
<li><p><code>address payable</code>: Same as <code>address</code>, but with the additional members <code>transfer</code> and <code>send</code>.</p>
</li>
</ul>
</li>
</ul>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.8.17;</span>

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Primitives</span> </span>{
    <span class="hljs-keyword">bool</span> <span class="hljs-keyword">public</span> boo <span class="hljs-operator">=</span> <span class="hljs-literal">true</span>;

    <span class="hljs-comment">/*
    uint stands for unsigned integer, meaning non negative integers
    different sizes are available
        uint8   ranges from 0 to 2 ** 8 - 1
        uint16  ranges from 0 to 2 ** 16 - 1
        ...
        uint256 ranges from 0 to 2 ** 256 - 1
    */</span>
    <span class="hljs-keyword">uint8</span> <span class="hljs-keyword">public</span> u8 <span class="hljs-operator">=</span> <span class="hljs-number">1</span>;
    <span class="hljs-keyword">uint</span> <span class="hljs-keyword">public</span> u256 <span class="hljs-operator">=</span> <span class="hljs-number">456</span>;
    <span class="hljs-keyword">uint</span> <span class="hljs-keyword">public</span> u <span class="hljs-operator">=</span> <span class="hljs-number">123</span>; <span class="hljs-comment">// uint is an alias for uint256</span>

    <span class="hljs-comment">/*
    Negative numbers are allowed for int types.
    Like uint, different ranges are available from int8 to int256

    int256 ranges from -2 ** 255 to 2 ** 255 - 1
    int128 ranges from -2 ** 127 to 2 ** 127 - 1
    */</span>
    <span class="hljs-keyword">int8</span> <span class="hljs-keyword">public</span> i8 <span class="hljs-operator">=</span> <span class="hljs-number">-1</span>;
    <span class="hljs-keyword">int</span> <span class="hljs-keyword">public</span> i256 <span class="hljs-operator">=</span> <span class="hljs-number">456</span>;
    <span class="hljs-keyword">int</span> <span class="hljs-keyword">public</span> i <span class="hljs-operator">=</span> <span class="hljs-number">-123</span>; <span class="hljs-comment">// int is same as int256</span>

    <span class="hljs-comment">// minimum and maximum of int</span>
    <span class="hljs-keyword">int</span> <span class="hljs-keyword">public</span> minInt <span class="hljs-operator">=</span> <span class="hljs-keyword">type</span>(<span class="hljs-keyword">int</span>).<span class="hljs-built_in">min</span>;
    <span class="hljs-keyword">int</span> <span class="hljs-keyword">public</span> maxInt <span class="hljs-operator">=</span> <span class="hljs-keyword">type</span>(<span class="hljs-keyword">int</span>).<span class="hljs-built_in">max</span>;

    <span class="hljs-keyword">address</span> <span class="hljs-keyword">public</span> addr <span class="hljs-operator">=</span> <span class="hljs-number">0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c</span>;

    <span class="hljs-comment">/*
    In Solidity, the data type byte represent a sequence of bytes. 
    Solidity presents two type of bytes types :

     - fixed-sized byte arrays
     - dynamically-sized byte arrays.

     The term bytes in Solidity represents a dynamic array of bytes. 
     It’s a shorthand for byte[] .
    */</span>
    <span class="hljs-keyword">bytes1</span> a <span class="hljs-operator">=</span> <span class="hljs-number">0xb5</span>; <span class="hljs-comment">//  [10110101]</span>
    <span class="hljs-keyword">bytes1</span> b <span class="hljs-operator">=</span> <span class="hljs-number">0x56</span>; <span class="hljs-comment">//  [01010110]</span>

    <span class="hljs-comment">// Default values</span>
    <span class="hljs-comment">// Unassigned variables have a default value</span>
    <span class="hljs-keyword">bool</span> <span class="hljs-keyword">public</span> defaultBoo; <span class="hljs-comment">// false</span>
    <span class="hljs-keyword">uint</span> <span class="hljs-keyword">public</span> defaultUint; <span class="hljs-comment">// 0</span>
    <span class="hljs-keyword">int</span> <span class="hljs-keyword">public</span> defaultInt; <span class="hljs-comment">// 0</span>
    <span class="hljs-keyword">address</span> <span class="hljs-keyword">public</span> defaultAddr; <span class="hljs-comment">// 0x0000000000000000000000000000000000000000</span>
}
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Solidity: Constructors]]></title><description><![CDATA[A constructor is an optional function that is executed upon contract creation.
Here are examples of how to pass arguments to constructors.
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.3;

// Base contract X
contract X {
    string public name...]]></description><link>https://blog.michaeltech.xyz/solidity-constructors</link><guid isPermaLink="true">https://blog.michaeltech.xyz/solidity-constructors</guid><category><![CDATA[Solidity]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Web3]]></category><category><![CDATA[Blockchain]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Thu, 12 Jan 2023 18:32:17 GMT</pubDate><content:encoded><![CDATA[<p>A <code>constructor</code> is an optional function that is executed upon contract creation.</p>
<p>Here are examples of how to pass arguments to <code>constructors</code>.</p>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.7.3;</span>

<span class="hljs-comment">// Base contract X</span>
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">X</span> </span>{
    <span class="hljs-keyword">string</span> <span class="hljs-keyword">public</span> name;

    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> _name</span>) </span>{
        name <span class="hljs-operator">=</span> _name;
    }
}

<span class="hljs-comment">// Base contract Y</span>
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Y</span> </span>{
    <span class="hljs-keyword">string</span> <span class="hljs-keyword">public</span> text;

    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> _text</span>) </span>{
        text <span class="hljs-operator">=</span> _text;
    }
}

<span class="hljs-comment">// There are 2 ways to initialize parent contract with parameters.</span>

<span class="hljs-comment">// Pass the parameters here in the inheritance list.</span>
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">B</span> <span class="hljs-keyword">is</span> <span class="hljs-title">X</span>(<span class="hljs-params"><span class="hljs-string">"Input to X"</span></span>), <span class="hljs-title">Y</span>(<span class="hljs-params"><span class="hljs-string">"Input to Y"</span></span>) </span>{

}

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">C</span> <span class="hljs-keyword">is</span> <span class="hljs-title">X</span>, <span class="hljs-title">Y</span> </span>{
    <span class="hljs-comment">// Pass the parameters here in the constructor,</span>
    <span class="hljs-comment">// similar to function modifiers.</span>
    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> _name, <span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> _text</span>) <span class="hljs-title">X</span>(<span class="hljs-params">_name</span>) <span class="hljs-title">Y</span>(<span class="hljs-params">_text</span>) </span>{}
}

<span class="hljs-comment">// Parent constructors are always called in the order of inheritance</span>
<span class="hljs-comment">// regardless of the order of parent contracts listed in the</span>
<span class="hljs-comment">// constructor of the child contract.</span>

<span class="hljs-comment">// Order of constructors called:</span>
<span class="hljs-comment">// 1. X</span>
<span class="hljs-comment">// 2. Y</span>
<span class="hljs-comment">// 3. D</span>
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">D</span> <span class="hljs-keyword">is</span> <span class="hljs-title">X</span>, <span class="hljs-title">Y</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) <span class="hljs-title">X</span>(<span class="hljs-params"><span class="hljs-string">"X was called"</span></span>) <span class="hljs-title">Y</span>(<span class="hljs-params"><span class="hljs-string">"Y was called"</span></span>) </span>{}
}

<span class="hljs-comment">// Order of constructors called:</span>
<span class="hljs-comment">// 1. X</span>
<span class="hljs-comment">// 2. Y</span>
<span class="hljs-comment">// 3. E</span>
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">E</span> <span class="hljs-keyword">is</span> <span class="hljs-title">X</span>, <span class="hljs-title">Y</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) <span class="hljs-title">Y</span>(<span class="hljs-params"><span class="hljs-string">"Y was called"</span></span>) <span class="hljs-title">X</span>(<span class="hljs-params"><span class="hljs-string">"X was called"</span></span>) </span>{}
}
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673523712754/6ae563e7-d262-40e2-a9a8-f5692e7a5871.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Solidity:Events]]></title><description><![CDATA[Events allow logging to the Ethereum blockchain. Some use cases for events are:

Listening for events and updating user interface

A cheap form of storage


// SPDX-License-Identifier: MIT
pragma solidity ^0.7.3;

contract Event {
    // Event declar...]]></description><link>https://blog.michaeltech.xyz/solidityevents</link><guid isPermaLink="true">https://blog.michaeltech.xyz/solidityevents</guid><category><![CDATA[Web Development]]></category><category><![CDATA[Web3]]></category><category><![CDATA[Solidity]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Thu, 12 Jan 2023 17:07:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/mH_E0K581Yk/upload/942eff6e56af719c439bddd53c19a91b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><code>Events</code> allow logging to the Ethereum blockchain. Some use cases for events are:</p>
<ul>
<li><p>Listening for events and updating user interface</p>
</li>
<li><p>A cheap form of storage</p>
</li>
</ul>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.7.3;</span>

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Event</span> </span>{
    <span class="hljs-comment">// Event declaration</span>
    <span class="hljs-comment">// Up to 3 parameters can be indexed.</span>
    <span class="hljs-comment">// Indexed parameters helps you filter the logs by the indexed parameter</span>
    <span class="hljs-function"><span class="hljs-keyword">event</span> <span class="hljs-title">Log</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> <span class="hljs-keyword">indexed</span> sender, <span class="hljs-keyword">string</span> message</span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">event</span> <span class="hljs-title">AnotherLog</span>(<span class="hljs-params"></span>)</span>;

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">test</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
        <span class="hljs-keyword">emit</span> Log(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, <span class="hljs-string">"Hello World!"</span>);
        <span class="hljs-keyword">emit</span> Log(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, <span class="hljs-string">"Hello EVM!"</span>);
        <span class="hljs-keyword">emit</span> AnotherLog();
    }
}
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673525030323/cc94bcf0-9560-4d74-ba6c-38768e7a567f.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Solidity: Inheritance]]></title><description><![CDATA[Solidity supports multiple inheritance. Contracts can inherit other contract by using the is keyword.
Function that is going to be overridden by a child contract must be declared as virtual.
Function that is going to override a parent function must u...]]></description><link>https://blog.michaeltech.xyz/solidity-inheritance</link><guid isPermaLink="true">https://blog.michaeltech.xyz/solidity-inheritance</guid><category><![CDATA[Web3]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Solidity]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Thu, 12 Jan 2023 17:06:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/26PeYRqpBh8/upload/1636222835d40433ed9c1df6209e408b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Solidity supports multiple inheritance. Contracts can inherit other contract by using the <code>is</code> keyword.</p>
<p>Function that is going to be overridden by a child contract must be declared as <code>virtual</code>.</p>
<p>Function that is going to override a parent function must use the keyword <code>override</code>.</p>
<p>Order of inheritance is important.</p>
<p>You have to list the parent contracts in the order from “most base-like” to “most derived”.</p>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.7.3;</span>

<span class="hljs-comment">/* Graph of inheritance
    A
   / \
  B   C
 / \ /
F  D,E

*/</span>

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">A</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">foo</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">pure</span></span> <span class="hljs-title"><span class="hljs-keyword">virtual</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span></span>) </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-string">"A"</span>;
    }
}

<span class="hljs-comment">// Contracts inherit other contracts by using the keyword 'is'.</span>
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">B</span> <span class="hljs-keyword">is</span> <span class="hljs-title">A</span> </span>{
    <span class="hljs-comment">// Override A.foo()</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">foo</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">pure</span></span> <span class="hljs-title"><span class="hljs-keyword">virtual</span></span> <span class="hljs-title"><span class="hljs-keyword">override</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span></span>) </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-string">"B"</span>;
    }
}

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">C</span> <span class="hljs-keyword">is</span> <span class="hljs-title">A</span> </span>{
    <span class="hljs-comment">// Override A.foo()</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">foo</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">pure</span></span> <span class="hljs-title"><span class="hljs-keyword">virtual</span></span> <span class="hljs-title"><span class="hljs-keyword">override</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span></span>) </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-string">"C"</span>;
    }
}

<span class="hljs-comment">// Contracts can inherit from multiple parent contracts.</span>
<span class="hljs-comment">// When a function is called that is defined multiple times in</span>
<span class="hljs-comment">// different contracts, parent contracts are searched from</span>
<span class="hljs-comment">// right to left, and in depth-first manner.</span>

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">D</span> <span class="hljs-keyword">is</span> <span class="hljs-title">B</span>, <span class="hljs-title">C</span> </span>{
    <span class="hljs-comment">// D.foo() returns "C"</span>
    <span class="hljs-comment">// since C is the right most parent contract with function foo()</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">foo</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">pure</span></span> <span class="hljs-title"><span class="hljs-keyword">override</span></span>(<span class="hljs-params">B, C</span>) <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span></span>) </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">super</span>.foo();
    }
}

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">E</span> <span class="hljs-keyword">is</span> <span class="hljs-title">C</span>, <span class="hljs-title">B</span> </span>{
    <span class="hljs-comment">// E.foo() returns "B"</span>
    <span class="hljs-comment">// since B is the right most parent contract with function foo()</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">foo</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">pure</span></span> <span class="hljs-title"><span class="hljs-keyword">override</span></span>(<span class="hljs-params">C, B</span>) <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span></span>) </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">super</span>.foo();
    }
}

<span class="hljs-comment">// Inheritance must be ordered from âmost base-likeâ to âmost derivedâ.</span>
<span class="hljs-comment">// Swapping the order of A and B will throw a compilation error.</span>
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">F</span> <span class="hljs-keyword">is</span> <span class="hljs-title">A</span>, <span class="hljs-title">B</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">foo</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">pure</span></span> <span class="hljs-title"><span class="hljs-keyword">override</span></span>(<span class="hljs-params">A, B</span>) <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span></span>) </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">super</span>.foo();
    }
}
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673525340121/8373b17f-a36a-474f-9cac-138ce80cc03b.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Solidity: View and Pure Functions]]></title><description><![CDATA[Getter functions can be declared view or pure.
View function declares that no state will be changed.
Pure function declares that no state variable will be changed or read.
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.3;

contract ViewAndPure ...]]></description><link>https://blog.michaeltech.xyz/solidity-view-and-pure-functions</link><guid isPermaLink="true">https://blog.michaeltech.xyz/solidity-view-and-pure-functions</guid><category><![CDATA[software development]]></category><category><![CDATA[Solidity]]></category><category><![CDATA[Web3]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Thu, 12 Jan 2023 17:05:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/BfrQnKBulYQ/upload/b030af771e8fa443b2c6f5ad791b4d60.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Getter functions can be declared <code>view</code> or <code>pure</code>.</p>
<p><code>View</code> function declares that no state will be changed.</p>
<p><code>Pure</code> function declares that no state variable will be changed or read.</p>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.7.3;</span>

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">ViewAndPure</span> </span>{
    <span class="hljs-keyword">uint</span> <span class="hljs-keyword">public</span> x <span class="hljs-operator">=</span> <span class="hljs-number">1</span>;

    <span class="hljs-comment">// Promise not to modify the state.</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addToX</span>(<span class="hljs-params"><span class="hljs-keyword">uint</span> y</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">view</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint</span></span>) </span>{
        <span class="hljs-keyword">return</span> x <span class="hljs-operator">+</span> y;
    }

    <span class="hljs-comment">// Promise not to modify or read from the state.</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params"><span class="hljs-keyword">uint</span> i, <span class="hljs-keyword">uint</span> j</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">pure</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint</span></span>) </span>{
        <span class="hljs-keyword">return</span> i <span class="hljs-operator">+</span> j;
    }
}
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Hello Solidity]]></title><description><![CDATA[With the advent of web3 and blockchain technology, much interest has been put into programming and building applications on web3. Solidity is one of the choice programming languages for creating smart contracts (applications on the blockchain)
This i...]]></description><link>https://blog.michaeltech.xyz/hello-solidity</link><guid isPermaLink="true">https://blog.michaeltech.xyz/hello-solidity</guid><category><![CDATA[Web Development]]></category><category><![CDATA[Web3]]></category><category><![CDATA[Solidity]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[beginner]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Thu, 12 Jan 2023 08:31:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/SyvsTmuuZyM/upload/ef47b44d090f006f34de099609c641ce.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>With the advent of web3 and blockchain technology, much interest has been put into programming and building applications on web3. Solidity is one of the choice programming languages for creating smart contracts (applications on the blockchain)</p>
<p>This is the beginning of a series of <em>short</em> articles on the fundamentals of the Solidity language, the language is explained in a series of code examples designed to give readers the feel of how the programming language works, learners are encouraged to test code examples on the online Solidity IDE <a target="_blank" href="https://remix.ethereum.org/">REMIX</a>.</p>
<p>We start with a simple Hello World implementation, the first line tells you that the source code is licensed under the MIT license. Machine-readable license specifiers are essential in a setting where publishing the source code is the default, the pragma keyword specifies the compiler version</p>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-comment">// compiler version must be greater than or equal to 0.7.3</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> &gt;=0.7.3;</span>

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">HelloWorld</span> </span>{
    <span class="hljs-keyword">string</span> <span class="hljs-keyword">public</span> greet <span class="hljs-operator">=</span> <span class="hljs-string">"Hello World!"</span>;
}
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673512089874/a8dcbf70-688a-43d5-9976-5d2c00ab432d.png" alt class="image--center mx-auto" /></p>
<p>This is the result of the code on Remix</p>
]]></content:encoded></item><item><title><![CDATA[Deploying a Smart Contract to the Blockchain Network]]></title><description><![CDATA[We'll be looking at a quick guide to writing and deploying a smart contract to the blockchain network.
Let's begin by looking at a simple contract program that stores and retrieves the value of a variable on the blockchain.
// SPDX-License-Identifier...]]></description><link>https://blog.michaeltech.xyz/deploying-a-smart-contract-to-the-blockchain-network</link><guid isPermaLink="true">https://blog.michaeltech.xyz/deploying-a-smart-contract-to-the-blockchain-network</guid><category><![CDATA[Blockchain]]></category><category><![CDATA[Web3]]></category><category><![CDATA[Solidity]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Mon, 28 Nov 2022 12:51:02 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1669639678328/BQ35gyunm.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We'll be looking at a quick guide to writing and deploying a smart contract to the blockchain network.</p>
<p>Let's begin by looking at a simple contract program that stores and retrieves the value of a variable on the blockchain.</p>
<pre><code class="lang-plaintext">// SPDX-License-Identifier: GPL-3.0
pragma solidity &gt;=0.4.16 &lt;0.9.0;
</code></pre>
<p>The first line of code identifies the license in use for the program, the second line is a directive that specifies the version of solidity compilers that should be used for the contract.</p>
<p>The <em>uint</em> (unsigned integer) variable <em>storedData</em> is declared. two functions *set *and *get *are created to alter and return the variable's value.</p>
<pre><code class="lang-plaintext">pragma solidity &gt;=0.4.16 &lt;0.9.0;

contract SimpleStorage {
    uint storedData;

    function set(uint x) public {
        storedData = x;
    }

    function get() public view returns (uint) {
        return storedData;
    }
}
</code></pre>
<p>We'll be interacting with our Solidity project with the use of an online Solidity IDE called <a target="_blank" href="https://remix-project.org/">Remix</a></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1669636964419/Ua6EB_-Hy.png" alt="image.png" /></p>
<p>Once the contract has been compiled successfully you can deploy and interact with it on the Remix IDE. When the contract has been deployed, under Deployed contracts you will see the name of the contract and the two buttons <em>set</em> and <em>get</em> representing the two functions in the contract which can be used to modify and retrieve the value of the stored variable.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1669637600115/maT2niW5P.png" alt="image.png" /></p>
<p>In real-time use cases, contracts are deployed to blockchain networks, let's deploy this contract to the Polygon network, Contracts on the blockchain require a gas fee(cost of making a blockchain transaction) but we'll be using a test network which will not require real money. For us to pay the gas fee we'll be using a cryptocurrency wallet like <a target="_blank" href="https://metamask.io/download/">Metamask</a> , download <a target="_blank" href="https://metamask.io/download/">Metamask</a> here though you can choose to use any other non-custodial wallet. We'll be using the Polygon Mumbai Test network to host our smart contract, To connect your MetaMask Wallet to the Polygon Mumbai Testnet, visit this website https://chainlist.org/ and search for polygon, you'll see the Mumbai option under the search results, go ahead and select it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1669638795737/LBiBCGsqN.png" alt="image.png" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1669638810705/JVs45T-S4.png" alt="image.png" /></p>
<p>Once you have done that, you need to get some test MATICS to start with, you will get it from <a target="_blank" href="https://faucet.polygon.technology/">here</a>. Input your wallet address and voila you've got some cash!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1671542612161/OgMSu3bOi.png" alt class="image--center mx-auto" /></p>
<p>To deploy your contract to the testnet, go to the Remix IDE, and instead of the default JavaScript VM, select Injected Web3.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1669639033842/MqQpAamHn.png" alt="image.png" /></p>
<p>Your wallet will pop up and require permission, your contract is now deployed and hosted on the Polygon Mumbai Testnet. Congrats on the successful deployment of your smart contract!</p>
]]></content:encoded></item><item><title><![CDATA[Welcome to the Crypto Relsivolution!]]></title><description><![CDATA[Relsify-Revolution

The times they are a-changin

 as the phrase of a popular song goes, this fits aptly to how digital innovations are changing the way we do things in today's present time. Searches for terms like crypto, blockchains, web3 , have co...]]></description><link>https://blog.michaeltech.xyz/welcome-to-the-crypto-relsivolution</link><guid isPermaLink="true">https://blog.michaeltech.xyz/welcome-to-the-crypto-relsivolution</guid><category><![CDATA[Web3]]></category><category><![CDATA[crypto]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[Startups]]></category><category><![CDATA[Applications]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Fri, 31 Dec 2021 11:16:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1640944741953/A6jphpExK.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-relsify-revolution">Relsify-Revolution</h2>
<blockquote>
<p>The times they are a-changin</p>
</blockquote>
<p> as the phrase of a popular song goes, this fits aptly to how digital innovations are changing the way we do things in today's present time. Searches for terms like <em>crypto</em>, <em>blockchains</em>, <em>web3 </em>, have come on an increase as the world seeks to understand some of the shifts that have been ongoing for years now.</p>
<p>One major innovation of these times is known as blockchain technology, what is a blockchain? 
A blockchain is a system of recording information in a way that makes it difficult or impossible to change (immutable), hack, or cheat the system, it is an architecture that gives participants the ability to share a ledger that's updated through peer-to-peer replication each time a transaction occurs. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640947568043/JfMbEYOO2.jpeg" alt="smallblock.jpg" />
This model has gained a lot of traction for its ability to take out the middleman, the traditional methods for recording transactions and tracking assets in the hands of a <em>central </em>figure are made redundant,  We have seen how the rise of digital currencies like the <em>bitcoin</em>, <em>ethereum</em>, etc. built on this technology have taken the world by storm.</p>
<p>This brings us back to the center of our discussion.</p>
<h2 id="heading-what-is-relsify-and-what-do-they-offer">What is Relsify and what do they offer?</h2>
<p>Relsify is a property technology company incorporating blockchain technology to provide quality real estate experience by solving decades of real-time problems in the region (Africa). They plan to undertake this by taking physical real estate assets representing them as unique blockchain-based digital assets (security tokens) giving access to many to have fractional investments and stakes while also providing the liquidity and funding required by real estate developers. Taking Nigeria a country in Africa as an example, the country is faced with several crippling challenges in its real estate sector:</p>
<ul>
<li><p>There is a huge housing and developmental deficit, a place like Lagos the economic capital of Nigeria has a shortfall of housing units to cater to its teeming population.</p>
</li>
<li><p>Limited access to funding by real estate developers</p>
</li>
<li><p>Poor document authenticity around properties often gives rise to disputes</p>
</li>
<li><p>Low foreign investments, as many have fears of doing business and have to resort to trying to find a trusted middleman</p>
</li>
</ul>
<h2 id="heading-the-relsify-process">The Relsify Process</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640930804997/KlgcUMhuHm.png" alt="image.png" /></p>
<p>The purpose of Relsify is to act as a global decentralized marketplace where there is a low barrier of entry and the average Joe with as little as $1 can invest or have a stake in a piece of real estate. The developers host their properties and get access to fundings via transactions between them and the investors without the need for middlemen.</p>
<p> On the Relsify platform, the <em>RELS</em> token will act as the utility token or currency for the ecosystem
, customers create accounts on the platform and check out verified properties they can choose to invest in, developers create unique security tokens for every property listed, which are given to the investors.</p>
<p>The Relsify ecosystem provides secure processing of these transactions by the power of the blockchain affording several benefits like:</p>
<ul>
<li><p>It creates a safe pool for Developers, Investors, and Crypto Enthusiasts to access capital or properties that were previously inaccessible</p>
</li>
<li><p>Bring about global participation and foreign investments</p>
</li>
<li><p>Completely shatter the real estate investment entry barrier</p>
</li>
<li><p>Solve the issue of document authenticity by a blockchain-backed system of immutability</p>
</li>
<li><p>Simply ease  of property ownership transfers to around 1-5mins</p>
</li>
</ul>
<p>The list of novel benefits this innovation is bringing is quite endless, we are poised to see several more use-cases adopted in the times to come. For more information about Relsify and how they seek to implement this unique solution, you can check out their <em>whitepaper </em>on their website  <a target="_blank" href="https://relsify.com/">Relsify</a>. </p>
<p>  This is a rare oppurtunity to be an early contributor or stakeholder in something so innovative and disruptive, you are welcome to join the growing community here at https://t.me/relsify_official  come and be part of the ongoing <em>relsivolution</em>! Thanks for your time.</p>
]]></content:encoded></item><item><title><![CDATA[Building a stopwatch with HTML, CSS and JavaScript]]></title><description><![CDATA[One of the most effective ways of mastering the field of web development is by building real-world projects with practical use cases. I will be going through a step-by-step tutorial on building a stopwatch with HTML, CSS, and plain JavaScript.
The pr...]]></description><link>https://blog.michaeltech.xyz/building-a-stopwatch-with-html-css-and-javascript</link><guid isPermaLink="true">https://blog.michaeltech.xyz/building-a-stopwatch-with-html-css-and-javascript</guid><category><![CDATA[Web Development]]></category><category><![CDATA[Web Design]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[HTML]]></category><category><![CDATA[CSS]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Tue, 28 Dec 2021 08:47:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1640607708226/h7UdINrzIh.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p> One of the most effective ways of mastering the field of web development is by building real-world projects with practical use cases. I will be going through a step-by-step tutorial on building a stopwatch with HTML, CSS, and plain JavaScript.</p>
<p>The project is available on CodePen with the source code</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://codepen.io/MichaelEnigma/pen/LYzNaKw">https://codepen.io/MichaelEnigma/pen/LYzNaKw</a></div>
<p>I urge you to also try to tweak the code and add a little stuff here and there, different colors, new features, you could even go ahead and add a countdown feature, that's how we master web development concepts.</p>
<p><strong>HTML</strong></p>
<p>Let's start with the basic HTML structure</p>
<pre><code><span class="hljs-operator">&lt;</span>html lang<span class="hljs-operator">=</span><span class="hljs-string">"en"</span><span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span>head<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span>title<span class="hljs-operator">&gt;</span>StopWatch<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>title<span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>head<span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span>body<span class="hljs-operator">&gt;</span>

        <span class="hljs-operator">&lt;</span>div id<span class="hljs-operator">=</span><span class="hljs-string">"mainstopwatch"</span><span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>div class<span class="hljs-operator">=</span><span class="hljs-string">"maintime"</span><span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>span id<span class="hljs-operator">=</span><span class="hljs-string">"mainminute"</span><span class="hljs-operator">&gt;</span>00<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>span<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span>span id<span class="hljs-operator">=</span><span class="hljs-string">"mainsecond"</span><span class="hljs-operator">&gt;</span>00<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>span<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span>span id<span class="hljs-operator">=</span><span class="hljs-string">"milliseconds"</span><span class="hljs-operator">&gt;</span>00<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>span<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span><span class="hljs-operator">&lt;</span>br<span class="hljs-operator">&gt;</span>

    <span class="hljs-operator">&lt;</span>button id<span class="hljs-operator">=</span><span class="hljs-string">"start"</span> onclick<span class="hljs-operator">=</span><span class="hljs-string">"start();"</span><span class="hljs-operator">&gt;</span>Start<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span>button id<span class="hljs-operator">=</span><span class="hljs-string">"stop"</span> onclick<span class="hljs-operator">=</span><span class="hljs-string">"stop();"</span><span class="hljs-operator">&gt;</span>Stop<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span>button id<span class="hljs-operator">=</span><span class="hljs-string">"stop"</span> onclick<span class="hljs-operator">=</span><span class="hljs-string">"reset();"</span><span class="hljs-operator">&gt;</span>Reset<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>          
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>body<span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>html<span class="hljs-operator">&gt;</span>
</code></pre><p>So to the skeleton of the code is quite simple we add three '00' and three buttons. We will be using <em>div </em>and <em>span </em>tags as containers to effectively style the HTML elements. </p>
<p>A <em>div </em>is a block element so it starts on a new line and occupies the full width of the screen, on the other hand, a <em>span </em>tag is an inline element container, in other words, it doesn't start on a new line and can be used to style just a small part of a text. </p>
<p>We also added several attributes to the different  elements like the id and class for the styling, the <em>onclick </em>event attribute to be used in javascript, we examine them as we go along.</p>
<p>This how it going to look like now</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640596251145/pMEPL92KX.png" alt="image.png" /></p>
<p><strong>CSS</strong></p>
<p>So for the <em>body </em>element, we add the <em>font</em> to <em>Arial </em>and set its background to light gray 
then for the <em>div </em> with the id of <em>mainstopwatch </em> we add the following styles to it to give it shape and beauty. 
  We use the <em>margin</em> and <em>padding</em> properties to properly position it in relation to the screen, the <em>text-align</em> centers the text, the <em>border-radius</em> makes its corners rounded. </p>
<p>Note how the box-shadow style brings out a unique effect by adding light and dark shadows to the Stopwatch outline.</p>
<pre><code><span class="hljs-selector-tag">body</span> {
    <span class="hljs-attribute">font-family</span>: arial;
    <span class="hljs-attribute">background</span>: <span class="hljs-number">#e0e0e0</span>;
  }
  <span class="hljs-selector-id">#mainstopwatch</span>{
    <span class="hljs-attribute">width</span>: <span class="hljs-number">300px</span>;

    <span class="hljs-attribute">margin</span>: <span class="hljs-number">100px</span> auto;
    <span class="hljs-attribute">padding</span>: <span class="hljs-number">60px</span> <span class="hljs-number">50px</span> <span class="hljs-number">100px</span>;
    <span class="hljs-attribute">text-align</span>: center;
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">40px</span>;
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">38px</span>;
    <span class="hljs-attribute">box-shadow</span>: <span class="hljs-number">6px</span> -<span class="hljs-number">6px</span> <span class="hljs-number">8px</span> <span class="hljs-number">#9d9d9d</span>,
      -<span class="hljs-number">6px</span> <span class="hljs-number">6px</span> <span class="hljs-number">8px</span> <span class="hljs-number">#ffffff</span>;

  }
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640599868513/8CXrOB98R.png" alt="image.png" /></p>
<p>The rest of the styling is easy to follow along, the <em>span</em>'s display is set to <em>inline-block</em>.
The <em>nth-of-type</em> and <em>last-child</em> selectors are used to give varying background colors to the buttons, the buttons are made to have a change in background color on <em>hover</em>. </p>
<p>This is the complete CSS code</p>
<pre><code><span class="hljs-selector-tag">body</span> {
    <span class="hljs-attribute">font-family</span>: arial;
    <span class="hljs-attribute">background</span>: <span class="hljs-number">#e0e0e0</span>;
  }
  <span class="hljs-selector-id">#mainstopwatch</span>{
    <span class="hljs-attribute">width</span>: <span class="hljs-number">300px</span>;

    <span class="hljs-attribute">margin</span>: <span class="hljs-number">100px</span> auto;
    <span class="hljs-attribute">padding</span>: <span class="hljs-number">60px</span> <span class="hljs-number">50px</span> <span class="hljs-number">100px</span>;
    <span class="hljs-attribute">text-align</span>: center;
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">40px</span>;
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">38px</span>;
    <span class="hljs-attribute">box-shadow</span>: <span class="hljs-number">6px</span> -<span class="hljs-number">6px</span> <span class="hljs-number">8px</span> <span class="hljs-number">#9d9d9d</span>,
      -<span class="hljs-number">6px</span> <span class="hljs-number">6px</span> <span class="hljs-number">8px</span> <span class="hljs-number">#ffffff</span>;

  }


  <span class="hljs-selector-id">#mainstopwatch</span> <span class="hljs-selector-tag">span</span> {
    <span class="hljs-attribute">width</span>: <span class="hljs-number">55px</span>;
    <span class="hljs-attribute">color</span>:<span class="hljs-number">#0776de</span>;
    <span class="hljs-attribute">margin</span>: <span class="hljs-number">3px</span>;
    <span class="hljs-attribute">padding</span>: <span class="hljs-number">10px</span>;
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">38px</span>;
    <span class="hljs-attribute">display</span>: inline-block;
   <span class="hljs-attribute">box-shadow</span>: <span class="hljs-number">6px</span> -<span class="hljs-number">6px</span> <span class="hljs-number">8px</span> <span class="hljs-number">#9d9d9d</span>,
      -<span class="hljs-number">6px</span> <span class="hljs-number">6px</span> <span class="hljs-number">8px</span> <span class="hljs-number">#ffffff</span>;
  }
  <span class="hljs-selector-id">#mainstopwatch</span> <span class="hljs-selector-tag">button</span> {
    <span class="hljs-attribute">border</span>: none;
    <span class="hljs-attribute">-webkit-appearance</span>: none; 
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">22px</span>;
    <span class="hljs-attribute">width</span>: <span class="hljs-number">140px</span>;
    <span class="hljs-attribute">height</span>: <span class="hljs-number">55px</span>;
    <span class="hljs-attribute">color</span>: white; 
    <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#2e80b3</span>;
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">33px</span>;
    <span class="hljs-attribute">transition</span>: .<span class="hljs-number">3s</span>;
   <span class="hljs-attribute">box-shadow</span>: <span class="hljs-number">6px</span> -<span class="hljs-number">6px</span> <span class="hljs-number">8px</span> <span class="hljs-number">#9d9d9d</span>,
      -<span class="hljs-number">6px</span> <span class="hljs-number">6px</span> <span class="hljs-number">8px</span> <span class="hljs-number">#ffffff</span>;
  }
  <span class="hljs-selector-id">#mainstopwatch</span> <span class="hljs-selector-tag">button</span><span class="hljs-selector-pseudo">:nth-of-type(2)</span> {
    <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#ae7617</span>;
  }
  <span class="hljs-selector-id">#mainstopwatch</span> <span class="hljs-selector-tag">button</span><span class="hljs-selector-pseudo">:last-child</span> {
      <span class="hljs-attribute">margin-top</span>: <span class="hljs-number">12px</span>;
    <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#17ae38</span>;
  }
  <span class="hljs-selector-id">#mainstopwatch</span> <span class="hljs-selector-tag">button</span><span class="hljs-selector-pseudo">:hover</span> {
    <span class="hljs-attribute">background</span>: <span class="hljs-number">#333</span>;
    <span class="hljs-attribute">color</span>: <span class="hljs-number">#e0e0e0</span>;
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">38px</span>;
  }
</code></pre><p>And this is how it should look</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640605332238/tGKkGrk6d.png" alt="new Stopwatch.png" /></p>
<p><strong>JavaScript</strong></p>
<p>Now we are at the <em>meat</em> of the work, we have a pretty-looking stopwatch, but the only thing now is that it doesn't work yet. It's from adding the relevant Javascript code that we get it to work properly.
Here it is.</p>
<pre><code><span class="hljs-keyword">var</span> timer <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;
<span class="hljs-keyword">var</span> timerInterval;
<span class="hljs-keyword">var</span> ms <span class="hljs-operator">=</span> document.getElementById(<span class="hljs-string">'milliseconds'</span>);
<span class="hljs-keyword">var</span> second <span class="hljs-operator">=</span> document.getElementById(<span class="hljs-string">'mainsecond'</span>);
<span class="hljs-keyword">var</span> minute <span class="hljs-operator">=</span> document.getElementById(<span class="hljs-string">'mainminute'</span>);
</code></pre><p>The variables we'll be using are initialized here, the <em>timer</em> is set to 0 by default and we use the <em>getElementById</em> method to access the three spans we created all using their respective ids</p>
<pre><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">start</span>(<span class="hljs-params"></span>)</span>{
  stop();
  timerInterval <span class="hljs-operator">=</span> setInterval( <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
     timer <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-number">1</span><span class="hljs-operator">/</span><span class="hljs-number">60</span>;
    msVal <span class="hljs-operator">=</span> Math.floor((timer <span class="hljs-operator">-</span> Math.floor(timer) )<span class="hljs-operator">*</span><span class="hljs-number">100</span>); <span class="hljs-comment">// Gives the milliseconds value</span>
     secondVal <span class="hljs-operator">=</span> Math.floor(timer) <span class="hljs-operator">-</span> Math.floor(timer<span class="hljs-operator">/</span><span class="hljs-number">60</span>) <span class="hljs-operator">*</span><span class="hljs-number">60</span>; <span class="hljs-comment">// Gives the Second values</span>
    minuteVal <span class="hljs-operator">=</span> Math.floor(timer<span class="hljs-operator">/</span><span class="hljs-number">60</span>); <span class="hljs-comment">// Gives the Minute value</span>
    ms.textContent <span class="hljs-operator">=</span> msVal <span class="hljs-operator">&lt;</span><span class="hljs-number">10</span> ? <span class="hljs-string">"0"</span> <span class="hljs-operator">+</span> msVal.toString() : msVal;
     second.textContent <span class="hljs-operator">=</span> secondVal <span class="hljs-operator">&lt;</span> <span class="hljs-number">10</span> ? <span class="hljs-string">"0"</span> <span class="hljs-operator">+</span> secondVal.toString() : secondVal;
     minute.textContent <span class="hljs-operator">=</span> minuteVal <span class="hljs-operator">&lt;</span> <span class="hljs-number">10</span> ? <span class="hljs-string">"0"</span> <span class="hljs-operator">+</span> minuteVal.toString() : minuteVal;
  }, <span class="hljs-number">1000</span><span class="hljs-operator">/</span><span class="hljs-number">60</span>);

}
</code></pre><p>Let's examine the above function <em>start()</em>, from the first line the function <em>stop()</em> is called which we'll look at later, the <em>setInterval</em> method <em>timerInterval</em> calls an anonymous function every millisecond this makes the <em>timer</em> variable initially set at 0 add a millisecond each time.</p>
<p>For the getting the milliseconds, seconds, and minutes value the <em>Math.Floor</em> function was heavily used, this function returns the highest integer less than or equal to the given number.
For example;</p>
<pre><code>  console.log(Math.floor(<span class="hljs-number">5.95</span>));
<span class="hljs-comment">// expected output: 5</span>
</code></pre><p>To get the current millisecond value the <em>timer </em>value is subtracted from its floored value, multiplied by 100, and floored again.</p>
<p>The second value, the <em>timer </em>is already in seconds, we use it with a <em>Math.floor</em> expression to make sure it shows the exact second.</p>
<p>The minute value is gotten by dividing the <em>timer </em>by 60.</p>
<p>For the next three lines, the values of the respective spans are changed with the <em>.textContent</em> method using a ternary operator to add an extra '0' to values less than 10 </p>
<pre><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">stop</span>(<span class="hljs-params"></span>)</span>{
  clearInterval(timerInterval);
}
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">reset</span>(<span class="hljs-params"></span>)</span>{
    stop();
    timer <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;
    ms.textContent <span class="hljs-operator">=</span> <span class="hljs-string">'00'</span>;
    second.textContent <span class="hljs-operator">=</span> <span class="hljs-string">'00'</span>;
    minute.textContent <span class="hljs-operator">=</span> <span class="hljs-string">'00'</span>;
  }
</code></pre><p>For the next function <em>stop()</em> which was called in the first line of the previous function it simply makes use of the <em>clearInterval</em> function to stop the SetInterval function.</p>
<p>It is also used in the first line of the <em>reset()</em> function. In the <em>reset()</em> function the values of all the values are set to their default state.</p>
<p>Every button calls a similarly named function based on the <em>onclick</em> event attribute. Here is the full Javascript code below</p>
<pre><code><span class="hljs-keyword">var</span> timer <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;
<span class="hljs-keyword">var</span> timerInterval;
<span class="hljs-keyword">var</span> ms <span class="hljs-operator">=</span> document.getElementById(<span class="hljs-string">'milliseconds'</span>);
<span class="hljs-keyword">var</span> second <span class="hljs-operator">=</span> document.getElementById(<span class="hljs-string">'mainsecond'</span>);
<span class="hljs-keyword">var</span> minute <span class="hljs-operator">=</span> document.getElementById(<span class="hljs-string">'mainminute'</span>);
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">start</span>(<span class="hljs-params"></span>)</span>{
  stop();
  timerInterval <span class="hljs-operator">=</span> setInterval( <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
     timer <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-number">1</span><span class="hljs-operator">/</span><span class="hljs-number">60</span>;
    msVal <span class="hljs-operator">=</span> Math.floor((timer <span class="hljs-operator">-</span> Math.floor(timer) )<span class="hljs-operator">*</span><span class="hljs-number">100</span>); <span class="hljs-comment">// Gives the milliseconds value</span>
     secondVal <span class="hljs-operator">=</span> Math.floor(timer) <span class="hljs-operator">-</span> Math.floor(timer<span class="hljs-operator">/</span><span class="hljs-number">60</span>) <span class="hljs-operator">*</span><span class="hljs-number">60</span>; <span class="hljs-comment">// Gives the Second values</span>
    minuteVal <span class="hljs-operator">=</span> Math.floor(timer<span class="hljs-operator">/</span><span class="hljs-number">60</span>); <span class="hljs-comment">// Gives the Minute value</span>
    ms.textContent <span class="hljs-operator">=</span> msVal <span class="hljs-operator">&lt;</span><span class="hljs-number">10</span> ? <span class="hljs-string">"0"</span> <span class="hljs-operator">+</span> msVal.toString() : msVal;
     second.textContent <span class="hljs-operator">=</span> secondVal <span class="hljs-operator">&lt;</span> <span class="hljs-number">10</span> ? <span class="hljs-string">"0"</span> <span class="hljs-operator">+</span> secondVal.toString() : secondVal;
     minute.textContent <span class="hljs-operator">=</span> minuteVal <span class="hljs-operator">&lt;</span> <span class="hljs-number">10</span> ? <span class="hljs-string">"0"</span> <span class="hljs-operator">+</span> minuteVal.toString() : minuteVal;
  }, <span class="hljs-number">1000</span><span class="hljs-operator">/</span><span class="hljs-number">60</span>);

}
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">stop</span>(<span class="hljs-params"></span>)</span>{
  clearInterval(timerInterval);
}
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">reset</span>(<span class="hljs-params"></span>)</span>{
    stop();
    timer <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;
    ms.textContent <span class="hljs-operator">=</span> <span class="hljs-string">'00'</span>;
    second.textContent <span class="hljs-operator">=</span> <span class="hljs-string">'00'</span>;
    minute.textContent <span class="hljs-operator">=</span> <span class="hljs-string">'00'</span>;
  }
</code></pre><p>And there we have it a fully working stopwatch.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640547703428/6_CTftHiK.gif" alt="Hnet-image.gif" /></p>
<p>So like I earlier advised try and <em>own</em> the code, you can build on it or just get inspired to build something else that is really cool. If you have any useful suggestions or ideas let me know in the comment section. Thanks for your time.</p>
]]></content:encoded></item><item><title><![CDATA[Defining the Object: Understanding Object Oriented Programming]]></title><description><![CDATA[We will be looking at a very fundamental foundation of modern programming called Object Oriented Programming(OOP),this is a concept in programming that every good developer needs to be well grounded in as it shows a level of mastery and ability to us...]]></description><link>https://blog.michaeltech.xyz/defining-the-object-understanding-object-oriented-programming</link><guid isPermaLink="true">https://blog.michaeltech.xyz/defining-the-object-understanding-object-oriented-programming</guid><category><![CDATA[Object Oriented Programming]]></category><category><![CDATA[Productivity]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Tue, 14 Sep 2021 04:48:02 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1631595761636/oJeyGMjMj.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We will be looking at a very fundamental foundation of modern programming called Object Oriented Programming(OOP),this is a concept in programming that every good developer needs to be well grounded in as it shows a level of mastery and ability to use to higher order concepts in programming.
In the early days of programming the major paradigm was procedural, code solutions were implemented in a step by step fashion or the computer carried out instructions following the laid down sequence, this can be quite straight forward for simple programs but as the complexity of the program increases , it gets more difficult to maintain the codebase and many times several code routines are repeated. OOP promotes the reuse of data, helping reduce development time and complexity</p>
<p><em>So what is Object Oriented Programming? </em></p>
<p>OOP is a programming language structure that groups certain data(properties) and functions(method) into singular entities called objects, it refers to how objects in real world  are modelled based on their attributes and behavior, for example a real world like a car possesses several features like it has a make eg. Toyota. it has a certain color these are its attributes or properties,  then it performs certain actions like it moves, it breaks to slow down or stop it movement, these actions or functions are called methods. All this features are grouped together in what is called a class, a class is basically a blueprint of an object, an object is an instance of a class or simply stated a class is to an object what a recipe is to a cake.</p>
<p>There are four major pillars in Object Oriented Programming</p>
<ul>
<li><p><strong>Abstraction</strong></p>
</li>
<li><p><strong>Encapsulation</strong></p>
</li>
<li><p><strong>Inheritance</strong></p>
</li>
<li><p><strong>Polymorphism</strong></p>
</li>
</ul>
<p><strong>Abstraction</strong>: Abstraction is the hiding or shielding away of the internal implementation of an object while only showing the essential parts to the user, the information are hidden within the object definitions, they are a lot of things and tools we use that we don't understand their inward workings but we interact with them to produce certain desired results   For example, there are a lot of complexities in how the engine works to drive a car but we don't have to bother ourselves with that all we do is interact with it to transport ourselves from one place to another, this concept is important in programming so that in cases where even when the internal configuration of our code changes, it doesn't have to change our outward result.</p>
<p><strong>Encapsulation</strong>: Encapsulation is a means of abstraction, in a program, different objects interact with each other, encapsulation is achieved when each object keeps its state private i.e. their properties can't be changed directly except through the object's own public methods. The Car class has a fuel state which can not be tampered with except by going through its methods, like the refuel() method adds more to the fuel state while the move() method reduces it. Encapsulation enforces modularity and keeps programs less prone to errors.</p>
<p><strong>Inheritance</strong>: Inheritance just like the name involves how an object can take up all or some of the properties of another object, just in the same fashion a child inherits traits and characteristics from his/her parents, 
Our Car class is a child of the Vehicle Class, it inherits properties like wheels, and methods like move(), a Motorcycle class also inherits from the Vehicle class, but the wheel property is unique and different from that of the Car class, inheritance helps in code reusability and reduces redundancy.  </p>
<p><strong>Polymorphism</strong>: Polymorphism comes from a compound greek word meaning many shapes, Polymorphism comes as a result of inheritance, OOP allows for the use of methods in various forms. Putting this simply, it refers to the use of methods in a way that a method works different for different objects using it.  Both Bicycle and Car class have the move method in common, but they all implement their move action uniquely, another example we can use is a Mammal Class, this class has a method called mammalSound(). The sub-classes of Mammals could be Dogs, cats, elephants, and horses. Each of these would have their own iteration of a mammal sound (dog-barks, cat-meows).</p>
<p>The OOP paradigm helps in giving proper structure and shape to programs, as one is made to break up requirements into reusable classes that become the blueprints for different objects in the program. Overall, this gives room for better data structures and reusability, producing a more efficient work in the long run.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding the MVC Software Architecture]]></title><description><![CDATA[Introducing the MVC Framework
We will examining closely the subject of the MVC (Model-View-Controller) software architecture, firstly when we speak of software architecture just like in the classical practice of architecture, which is about providing...]]></description><link>https://blog.michaeltech.xyz/understanding-the-mvc-software-architecture</link><guid isPermaLink="true">https://blog.michaeltech.xyz/understanding-the-mvc-software-architecture</guid><category><![CDATA[software architecture]]></category><category><![CDATA[software development]]></category><category><![CDATA[design patterns]]></category><category><![CDATA[mvc]]></category><category><![CDATA[SEO]]></category><dc:creator><![CDATA[Michael Etokakpan]]></dc:creator><pubDate>Wed, 26 May 2021 07:53:42 GMT</pubDate><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621643008679/6enef_I6R.png" alt="image.png" /></p>
<h3 id="introducing-the-mvc-framework">Introducing the MVC Framework</h3>
<p>We will examining closely the subject of the MVC (Model-View-Controller) software architecture, firstly when we speak of software architecture just like in the classical practice of architecture, which is about providing a blueprint or plan for the design and functionality of a building or structure, so also in the domain of software design there needs to be a working design for the implementation and building of the application. The design of a building largely depends on the purpose for which that structure serves.</p>
<p>The Model-View-Controller (MVC) framework was designed with the purpose of separating the business logic and presentation layer from each other, the application is separated into three units, the Model, the View and the Controller, it is one of the most popular design patterns, because of the way in which components handles a certain developmental aspect of the application, it is extensively used for team based developments. Some well known frameworks that use the MVC concept are Ruby on Rails, Laravel, ASP.NET, AngularJS, Django, and Flask. </p>
<p>An eli5 example is for instance, you're a car dealership, with many different cars in your inventory (model). When a customer asks to see a car, you (controller) looks in the inventory (model), retrieve the car and present it to the customer (view).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1621630402000/3nqULJZBS.png" alt="image.png" />
Let us examine each of the components</p>
<h3 id="model">MODEL</h3>
<p>This carries the data logic and the interaction with the databases(SELECT, INSERT, UPDATE, DELETE). It is commonly referred to as the brain of the application as it communicates with the database</p>
<h3 id="view">VIEW</h3>
<p>This is the what the end-user sees and interacts with, A view requests the model to give information so that it presents the output presentation to the user, most MVC frameworks use template engines, at runtime, a template engine replaces variables in a template file with actual values, and transforms the template into an HTML file sent to the client. This approach makes it easier to pass dynamic data to an HTML page.</p>
<h3 id="controller">CONTROLLER</h3>
<p> The Controller acts as a middleman between the View and the Model, it takes in user input from the View, processes the request and returns the data gotten from the Model back to the view.</p>
<p><strong>Pseudocode:</strong></p>
<pre><code>http:<span class="hljs-comment">//yourapp.com/users/profile/1</span>
/routes
    users/profile/:id = Users.getProfile(id)

<span class="hljs-comment">/* Controller */</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Users</span></span>{
  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getProfile</span>(<span class="hljs-params">id</span>)</span>{
    profile= <span class="hljs-built_in">this</span>.UserModel.getProfile(id)

    renderView(<span class="hljs-string">'users/profile'</span>, profile)
  }
}
<span class="hljs-comment">/* Model */</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">UserModel</span></span>{ 
  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getProfile</span>(<span class="hljs-params">id</span>)</span>{
    data = <span class="hljs-built_in">this</span>.db.get(<span class="hljs-string">'SELECT * FROM users WHERE id = id'</span>)
    <span class="hljs-keyword">return</span> data;
}
<span class="hljs-comment">/* View */</span>
    /users
        /profile
&lt;h1&gt;{{profile.name}}&lt;/h1&gt;
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Email:{{profile.email}}<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Phone:{{profile.phone}}<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span></span>
</code></pre><p>The above code retrieves the profile details of a particular user, the user id is passed in through the URL which passes the request to the Controller which goes on to query the Model and then finally returns a View containing the associated data</p>
<h3 id="conclusion">CONCLUSION</h3>
<p>Some of the key benefits of using the MVC framework are</p>
<ul>
<li>Ability to maintain and keep extendible healthy codebase.</li>
<li>Support for collaborative development, each components can be worked on in parallel.</li>
<li>Helps in the building of SEO( Search Engine Optimization)-friendly applications or pages.</li>
</ul>
<p>Thus, today there are many organization and enterprises which are opting for the development of software applications based on the MVC design pattern, this is surely one design pattern will continue to play an important role in the world of software development for many years to come.</p>
]]></content:encoded></item></channel></rss>