<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sunington</title>
    <description>The latest articles on DEV Community by Sunington (@sunington).</description>
    <link>https://dev.to/sunington</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F861046%2Faf8d7579-58e9-4aef-8020-fe573d2c1d4a.jpg</url>
      <title>DEV Community: Sunington</title>
      <link>https://dev.to/sunington</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sunington"/>
    <language>en</language>
    <item>
      <title>Understanding Mapping in Solidity (set, get, delete, iterate and nested mapping)</title>
      <dc:creator>Sunington</dc:creator>
      <pubDate>Mon, 26 Dec 2022 19:21:03 +0000</pubDate>
      <link>https://dev.to/sunington/understanding-mapping-in-solidity-set-get-delete-iterate-and-nested-mapping-4bdi</link>
      <guid>https://dev.to/sunington/understanding-mapping-in-solidity-set-get-delete-iterate-and-nested-mapping-4bdi</guid>
      <description>&lt;ol&gt;
&lt;li&gt;What is Mapping?&lt;/li&gt;
&lt;li&gt;Creating a Mapping&lt;/li&gt;
&lt;li&gt;Set, Add, Get, Updat and Delete Mapping&lt;/li&gt;
&lt;li&gt;Nested Mapping&lt;/li&gt;
&lt;li&gt;Iterable Mappings&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Mapping in solidity is like a hash table containing a Key Type and Value Type used to store data. Mapping are used to map or associate a keytype to a value type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt; : &lt;em&gt;Mapping(KeyType =&amp;gt; ValueType) ;&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;The KeyType can be any built-in value types, strings or bytes. The ValueType can be any type including complex types like structs, mappings or arrays.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Considerations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Mapping can only have a data location of storage and thus are allowed for state variable.&lt;/li&gt;
&lt;li&gt;Mappings can be marked public &lt;/li&gt;
&lt;li&gt;Mappings are not iterable except you implement a data structure then iterate over that.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Creating a Mapping
&lt;/h2&gt;

&lt;p&gt;To create a mapping in solidity the keytype and the Value type sould be specified.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Sample&lt;/strong&gt; : In the code sample below, the contract name &lt;em&gt;mappingExample&lt;/em&gt; defines a contract, a mapping of keytype, &lt;em&gt;address&lt;/em&gt; and value type &lt;em&gt;uint&lt;/em&gt; is created.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  How to Set, Get, Delete and Update mapping.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1) Setting or Adding Value
&lt;/h3&gt;

&lt;p&gt;We can set or add value to a mapping.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code sample&lt;/strong&gt; : In the code sample below, we created a contract called &lt;em&gt;mappingExample&lt;/em&gt;, a mapping called &lt;em&gt;myMapping&lt;/em&gt; is defined and values are added to the mapping through the function &lt;em&gt;addMapping()&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;The address is set to &lt;em&gt;msg.sender&lt;/em&gt; and its mapping value type to uint, of values from &lt;em&gt;"input"&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;If &lt;em&gt;"input" = 123;&lt;/em&gt; then &lt;em&gt;myMapping[msg.sender] = 123;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#note&lt;/strong&gt; : If the value for the mapping was not set it will always return the default value.&lt;/p&gt;

&lt;h3&gt;
  
  
  2) Getting Value
&lt;/h3&gt;

&lt;p&gt;We have added values to the mapping. Let's create function to retrieve the values from the mapping .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#note&lt;/strong&gt; : If the value of mapping was not set it always return &lt;em&gt;0&lt;/em&gt;, the default value for uint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Sample&lt;/strong&gt; : In the code sample below, a mapping &lt;em&gt;myMapping&lt;/em&gt; is defined. We get the mapping value from the mapping through the function &lt;em&gt;getMapping()&lt;/em&gt; using &lt;em&gt;myMapping[msg.sender]&lt;/em&gt;&lt;/p&gt;

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

&lt;h3&gt;
  
  
  3) Deleting Value
&lt;/h3&gt;

&lt;p&gt;We can delete or remove the value of a mapping, resetting it to the default value, 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Sample&lt;/strong&gt; : In the code sample below, a mapping &lt;em&gt;myMapping&lt;/em&gt; is defined, we delete values from the mapping through &lt;em&gt;deleteMapping()&lt;/em&gt; using delete &lt;em&gt;myMapping[msg.sender]&lt;/em&gt;&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Nested Mapping
&lt;/h2&gt;

&lt;p&gt;Nested mapping is a mapping within another mapping; that's a mapping that maps to another mapping and we access the inner mapping through the outer mapping.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt; : &lt;em&gt;mapping(address =&amp;gt; mapping(address =&amp;gt; uint)) name&lt;/em&gt;;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Sample&lt;/strong&gt; : In the code sample below, a nested outer mapping &lt;em&gt;myNestedMapping&lt;/em&gt; is created mapping from address to another mapping, mapping to a uint. We add value to the mapping through the function &lt;em&gt;addNestedMapping()&lt;/em&gt;, get value of the nested mapping through the function &lt;em&gt;getNestedMapping()&lt;/em&gt; and also delete value with the function &lt;em&gt;deleteNestedMapping()&lt;/em&gt;&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Iterable Mapping
&lt;/h2&gt;

&lt;p&gt;We cannot iterate over mapping, meaning that their keys cannot be enumerated.&lt;/p&gt;

&lt;p&gt;However, it's possible to iterate mapping only if we implement a data structure on top of them and iterate over that.&lt;/p&gt;

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

&lt;p&gt;Access the code here &lt;a href="https://solidity-by-example.org/app/iterable-mapping/" rel="noopener noreferrer"&gt;Solidity By Example&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Example : Creating a mapping that transfers and approves transactions.
&lt;/h2&gt;

&lt;p&gt;In the code sample below, a contract &lt;em&gt;mappingExample&lt;/em&gt; is created and a mapping _&lt;em&gt;balances&lt;/em&gt; and nested mapping _&lt;em&gt;allowances&lt;/em&gt;, mapping from address to uint are created respectively.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Copy code below to run on your server.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;contract MappingExample {
mapping (address =&amp;gt; uint256) private _balances;
    mapping (address =&amp;gt; mapping (address =&amp;gt; uint256)) private _allowances;

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);

    function allowance(address owner, address spender) public view returns (uint256) {
        return _allowances[owner][spender];
    }

    function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
        require(_allowances[sender][msg.sender] &amp;gt;= amount, "ERC20: Allowance not high enough.");
        _allowances[sender][msg.sender] -= amount;
        _transfer(sender, recipient, amount);
        return true;
    }

    function approve(address spender, uint256 amount) public returns (bool) {
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[msg.sender][spender] = amount;
        emit Approval(msg.sender, spender, amount);
        return true;
    }

    function _transfer(address sender, address recipient, uint256 amount) internal {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");
        require(_balances[sender] &amp;gt;= amount, "ERC20: Not enough funds.");

        _balances[sender] -= amount;
        _balances[recipient] += amount;
        emit Transfer(sender, recipient, amount);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CONCLUSION
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;That's a wrap guys!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I've tried to cover the basics of Mappings in solidity. It's up to you to do more research on this topic for deep knowledge. Expect more indepth research and resources on Web3, Smart Contracts, and Blockchain in my subsequent Blog posts.&lt;/p&gt;

&lt;p&gt;I'm Sunington, you can connect with me on &lt;a href="https://www.twitter.com/sunington" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; and on &lt;a href="https://www.linkedin.com/in/sunnyakujobi" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Until we meet again&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#KeepSunning!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>mentorship</category>
      <category>gratitude</category>
    </item>
    <item>
      <title>Understanding Array in Solidity (Push, Pop, Length)</title>
      <dc:creator>Sunington</dc:creator>
      <pubDate>Tue, 22 Nov 2022 08:23:45 +0000</pubDate>
      <link>https://dev.to/sunington/understanding-array-in-solidity-push-pop-length-56eb</link>
      <guid>https://dev.to/sunington/understanding-array-in-solidity-push-pop-length-56eb</guid>
      <description>&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arrays&lt;/li&gt;
&lt;li&gt;Array Types&lt;/li&gt;
&lt;li&gt;Array Members&lt;/li&gt;
&lt;li&gt;Removing Array element by shifting to the last and using pop() command.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;1) What is an Array?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Array is a data structure used to store a collection of data or variables of the same type. Instead of declaring &lt;em&gt;number = number1, number2, number3. . . number(nth)&lt;/em&gt;, we can group it as &lt;em&gt;number[] = [1, 2, 3. . . nth].&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;What we simply did here is instead of declaring numberous individual value repeatedly, we create one array and allocate all the value in one collection of array where each value can be accessed by the index.&lt;br&gt;
Now let’s talk about index. The first value in any array is of index &lt;em&gt;0&lt;/em&gt;. Ie : for &lt;em&gt;number[] = [1, 2, 3. . . nth]&lt;/em&gt; discussed earlier, the index &lt;em&gt;0&lt;/em&gt; denoted as *number[0] = 1, number[1] = 2, number[2] = 3. . . number[n] = n+1.&lt;br&gt;
*&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating an Array
&lt;/h2&gt;

&lt;p&gt;To create an array in Solidity, the data type of the elements and the number of elements should be specified. The size of the array must be a positive integer for fixed-sized arrays and data should be a valid Solidity type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; &lt;em&gt;type[] public arrayName = [elements]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;type[]&lt;/em&gt; is the data type of the values in the array, where &lt;em&gt;[]&lt;/em&gt; shows it’s an array.&lt;br&gt;
&lt;em&gt;arrayName&lt;/em&gt; is the name of the array defined while &lt;em&gt;elements&lt;/em&gt; is the value or elements of the array. The elements should be the same value type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In the code example below, the contract myPractise defines a contract, an array type uint named arrayValue is created, values are assigned to the array defined.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pragma solidity ^ 0.8.0;
// //SPDX-License-Identifier: MIT;

contract myPractise {

uint[] public arrayValue = [1, 2, 3, 4, 5, 6, 7];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Accessing an Array
&lt;/h2&gt;

&lt;p&gt;An element in an array is accessed by indexing the array name. This is done by placing the index of the element within square brackets after the name of the array. For example  given an array &lt;/p&gt;

&lt;p&gt;uint[] public arrayValue = [1, 2, 3, 4, 5, 6, 7];&lt;/p&gt;

&lt;p&gt;We can access any value of the array. For instance, to access the value 4 in the array, we use the index 3, that is &lt;em&gt;arrayValue[3]&lt;/em&gt; which outputs &lt;em&gt;4&lt;/em&gt; if we run it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Sample&lt;/strong&gt; :&lt;/p&gt;

&lt;p&gt;In the code example below, the contract &lt;em&gt;myPractise&lt;/em&gt; defines a contract, an array type uint named &lt;em&gt;arrayValue&lt;/em&gt; is created, values are assigned to the array defined. The function &lt;em&gt;getArrayValue()&lt;/em&gt; is created to get the index value of 3. We then assigns &lt;em&gt;x&lt;/em&gt; to the index then returns &lt;em&gt;x&lt;/em&gt; to get the index value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pragma solidity ^ 0.8.0;
 // //SPDX-License-Identifier: MIT;

 contract myPractise {

 uint[] public arrayValue = [1, 2, 3, 4, 5, 6, 7];
 function getArrayValue() public view returns (uint) {  

 uint x = arrayValue[3];
 return x;}
 }

 //Ouput = 4

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

&lt;/div&gt;



&lt;p&gt;Output : 4.&lt;/p&gt;

&lt;h2&gt;
  
  
  2) Array Types
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Dynamic Array
&lt;/h3&gt;

&lt;p&gt;Dynamic arrays are not predefined and are modifiable. The size and length increases automatically when we add an element to the array.&lt;/p&gt;

&lt;p&gt;Syntax : &lt;em&gt;type[] public arrayName = [array1, array2, array3. . .]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code example&lt;/strong&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uint[] public dynamicArray = [1,3,5,7,9];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Fixed-Sized Array
&lt;/h3&gt;

&lt;p&gt;As the name suggests, the size of the array are predefined and fixed. This type of array are not modifiable. Note also that the number of array elements can not exceed the predefined size.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt; : &lt;em&gt;type[n] public arrayName = [array1, array2, array3, array(nth)]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the above syntax, n is the predefined size value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code sample&lt;/strong&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uint[5] public fixedArray = [0,2,4,6,8];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3) Array Members
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Push()
&lt;/h3&gt;

&lt;p&gt;Push is used to add new element to a dynamic array, when you push a value to an array, it becomes the last value (nth element)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt; : &lt;em&gt;arrayName.push(x)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code example&lt;/strong&gt; : &lt;/p&gt;

&lt;p&gt;In the code example below, an array type uint named arrayValue is created, values are assigned to the array defined. The function popArrayValue() is created to add value to at the end. With the synthax arrayValue.push(8) we add 8 to the array, which becomes the last value of the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uint[] public arrayValue = [1, 2, 3, 4, 5, 6, 7];
function pushArrayValue() public {  
arrayValue.push(8);}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pop()
&lt;/h3&gt;

&lt;p&gt;Pop is used to delete or remove an element in a dynamic array from the end.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt; : &lt;em&gt;arrayName.pop()&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code example&lt;/strong&gt; :&lt;/p&gt;

&lt;p&gt;In the code example below, an array type uint named arrayValue is created, values are assigned to the array defined. The function popArrayValue() is created to remove the last value. With the syntax arrayValue.pop() we remove the last value, 7.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uint[] public arrayValue = [1, 2, 3, 4, 5, 6, 7];
 function popArrayValue() public {  
 arrayValue.pop();}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  .Length
&lt;/h3&gt;

&lt;p&gt;Length of an array is the number of the elements contained in an array. The length of an array is of value type, uint. Length of an array is fixed when declared but can change depending on runtime parameters or modification.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt; : &lt;em&gt;arrayName.length&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code sample&lt;/strong&gt; : &lt;/p&gt;

&lt;p&gt;In the code example below, an array type uint named arrayValue is created, values are assigned to the array defined. The function &lt;em&gt;lenthOfArrayValue()&lt;/em&gt; is created to get the length of the array. We assigns &lt;em&gt;x&lt;/em&gt; to &lt;em&gt;arrayValue.length&lt;/em&gt; to return the length of the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uint[] public arrayValue = [1, 2, 3, 4, 5, 6, 7];
 function lengthOfArrayValue() public view returns (uint) {  
 uint x = arrayValue.length;
 return x;}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Delete
&lt;/h3&gt;

&lt;p&gt;Delete is used to remove the index value in an array and automatically set it to 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt; : &lt;em&gt;delete arrayName[x]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code sample&lt;/strong&gt; : &lt;/p&gt;

&lt;p&gt;In the code example below, an array type uint named arrayValue is created, values are assigned to the array defined. The function deleteArrayValue() is created to delete a value from the array. We use delete arrrayValue[2[ to delete the index value 3 from the array, which sets it to 0.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;#Note that 2 is the index number of the index value 3.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uint[] public arrayValue = [1, 2, 3, 4, 5, 6, 7];
function deleteArrayValue() public {  
delete arrayValue[2];}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The difference between delete and pop()
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Delete&lt;/strong&gt; removes an array value in any location, while &lt;strong&gt;pop()&lt;/strong&gt; only removes a value at the end of an array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Delete&lt;/strong&gt; removes a value and automatically sets it to 0, while &lt;strong&gt;pop()&lt;/strong&gt; entirely removes a value from an array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Delete&lt;/strong&gt; is executed with the command ‘&lt;em&gt;delete arrayValue[x]&lt;/em&gt;’ while &lt;strong&gt;pop()&lt;/strong&gt; is executed with the command ‘arrayValue.pop()’.&lt;/p&gt;

&lt;h2&gt;
  
  
  4) Removing Array By Shifting To The Last And Using The Pop()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Code sample&lt;/strong&gt; : &lt;/p&gt;

&lt;p&gt;In the code example below, an array type uint named arrayValue is defined, values are assigned to the array defined. The function removeValue(_input) is created to accept input. We then shift the input value to the last value and pop() the last value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//REMOVING THE VALUE OF ARRAY BY SHIFTING THE VALUE INPUTED TO THE LAST,
 //THEN POP THE LAST VALUE

 uint[] public arrayValue = [1, 2, 3, 4, 5, 6, 7];
 function removeValue(uint _input) public  {
    //This shifts the input value from the array to the last value in the array
    arrayValue[_input] = arrayValue[arrayValue.length - 1];
    arrayValue.pop();}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Array Literal
&lt;/h2&gt;

&lt;p&gt;An Array literals is a comma-seperated list of one or more elements in a square bracket. The elements in the array of a literal array should be of the same type otherwise it throws an error because the elements can not be implicitly converted.&lt;/p&gt;

&lt;p&gt;For example, the array literal [1, -1] is invalid because the type of the first element is uint8 while the type of the second is int8 and they can not be implicitly converted to each other to make it work, e have to use [int(8), -1]&lt;/p&gt;

&lt;p&gt;Code example : &lt;/p&gt;

&lt;h3&gt;
  
  
  CONCLUSION
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;That's a wrap guys!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I've tried to cover the basics of Arrays in solidity. It's up to you to do more research on this topic for deep knowledge. Expect more indepth research and resources on Web3, Smart Contracts, and Blockchain in my subsequent Blog posts.&lt;/p&gt;

&lt;p&gt;I'm Sunington, you can connect with me on &lt;a href="https://www.twitter.com/sunington"&gt;Twitter&lt;/a&gt; and on &lt;a href="https://www.linkedin.com/in/sunnyakujobi"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Until we meet again&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#KeepSunning&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>web3</category>
      <category>smartcontract</category>
      <category>solidity</category>
    </item>
    <item>
      <title>Running Your First Smart Contract with Solidity using Remix IDE. (For Newbies)</title>
      <dc:creator>Sunington</dc:creator>
      <pubDate>Sun, 12 Jun 2022 06:33:35 +0000</pubDate>
      <link>https://dev.to/sunington/running-your-first-smart-contract-with-solidity-using-remix-ide-for-newbies-3dmc</link>
      <guid>https://dev.to/sunington/running-your-first-smart-contract-with-solidity-using-remix-ide-for-newbies-3dmc</guid>
      <description>&lt;p&gt;Since you are here, I promise you one thing : You will learn how to run your first smart contract coded in solidity.&lt;/p&gt;

&lt;p&gt;Wait solidity? what is that?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solidity is a contract-oriented, statically typed high-level programming language for implementing smart contracts.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solidity&lt;/strong&gt; is used to write contracts in DApps, DeFi, NFTs Applications and even to building Web3 Application from scratch.&lt;/p&gt;

&lt;p&gt;It is highly influenced by C++, Python and JavaScript and has been designed to target the Ethereum Virtual Machine (EVM).&lt;/p&gt;

&lt;p&gt;To write our first Smart Contract, we will be using Remix IDE to Compile and Run our Solidity Code base.&lt;/p&gt;

&lt;p&gt;Let's begin...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP ONE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Head over to &lt;a href="https://remix.ethereum.org"&gt;https://remix.ethereum.org&lt;/a&gt; to start your remix coding environment (Online Editor)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Or&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can get the offline (For Desktop) &lt;a href="https://github.com/ethereum/remix-desktop/releases"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KJEUVbJM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aa3lvgjxd7wn0sp39cxq.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KJEUVbJM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aa3lvgjxd7wn0sp39cxq.PNG" alt="Remix IDE Homepage" width="880" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP TWO&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next is to create a Solidity file. To do that head over to ‘File Explorer’ then click on ‘Create File’ following the marked area on the picture below.&lt;/p&gt;

&lt;p&gt;Note : You can name it whatever you want but make sure to end it with ‘.sol’&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;STEP THREE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Copy the code below and paste in Remix IDE coding section.&lt;/p&gt;

&lt;p&gt;Code Example&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pragma solidity ^0.5.0;&lt;br&gt;
contract SolidityTest {&lt;br&gt;
   constructor() public{&lt;br&gt;
   }&lt;br&gt;
   function getResult() public view returns(uint){&lt;br&gt;
      uint a = 1;&lt;br&gt;
      uint b = 2;&lt;br&gt;
      uint result = a + b;&lt;br&gt;
      return result;&lt;br&gt;
   }&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;STEP FOUR&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Under Compile Tab, click Start to Compile button to compile your Solidity code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ACO7UYc_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n7sa73wh7poo0uhqwv8n.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ACO7UYc_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n7sa73wh7poo0uhqwv8n.PNG" alt="Remix Compile" width="880" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP FIVE&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Next is to deploy and run your code. To do that go to the ‘Deploy and Run Transactions’ tab, then click ‘Deploy’ button. Make sure all the parameters under the run and deploy section is set right from img below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RrrzNZcY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x6esxud9t227ox9egdpb.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RrrzNZcY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x6esxud9t227ox9egdpb.PNG" alt="Remix Deploy" width="880" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP SIX&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Under Run Tab, where you will see the Transaction record,, Select 0x75a05ff94d0c9608b8265bc08… in drop-down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lkI84bxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q4c7n6sixcx16k8hj67v.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lkI84bxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q4c7n6sixcx16k8hj67v.PNG" alt="Remix Deployed image" width="880" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP SEVEN&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To get the deployed result, Click ‘getResult’ button to display the result in the terminal.&lt;/p&gt;

&lt;p&gt;Output = 3&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;VIOLA!&lt;/strong&gt; You just deployed your first Smart contract!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To explain what we just did.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We assigned value a = 1, (&lt;code&gt;uint a = 1&lt;/code&gt;) and b = 2  (&lt;code&gt;uint a = 1&lt;/code&gt;) . Then we carried a simple math operation in solidity.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;uint result a + b&lt;/code&gt; = (1 + 2) = 3. &lt;/p&gt;

&lt;p&gt;Therefore &lt;code&gt;3&lt;/code&gt; is the right output.&lt;/p&gt;

&lt;p&gt;This is just the surface of writing smart contracts in solidity. As you go on, you get to see more complex code.&lt;/p&gt;

&lt;p&gt;I’m Sunington, you can connect with me on &lt;a href="https://twitter.com/sunington"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Until we meet again,&lt;/p&gt;

&lt;p&gt;&lt;em&gt;#KeepSunning.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>web3</category>
      <category>smartcontract</category>
    </item>
    <item>
      <title>Wait! I’m stuck. Which is the Best TRUFFLE or HARDHAT?</title>
      <dc:creator>Sunington</dc:creator>
      <pubDate>Mon, 06 Jun 2022 09:12:11 +0000</pubDate>
      <link>https://dev.to/sunington/wait-im-stuck-which-is-the-best-truffle-or-hardhat-4569</link>
      <guid>https://dev.to/sunington/wait-im-stuck-which-is-the-best-truffle-or-hardhat-4569</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;INTRODUCTION&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Web3 and Blockchain are new technologies that rely heavily on smart contracts and to run smart contract you need a development environment that can help to compile, test, debug and deploy ethereum software (Ethereum Nodes)&lt;/p&gt;

&lt;h2&gt;
  
  
  WHAT IS A DEVELOPMENT ENVIRONMENT?
&lt;/h2&gt;

&lt;p&gt;A Development Environment is an environment to develop, test and deploy Smart contracts carefully and initialize contracts in a better and more secure way.&lt;/p&gt;

&lt;p&gt;There are a handful of development environments that perform such operations but Hardhat and Truffle are among the best. Even though Hardhat and Truffle are way similar we will be considering some of the differences and similarities between the two.&lt;/p&gt;

&lt;p&gt;So let's look at some of the features of Hardhat first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table of Content&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hardhat - What is Hardhat?&lt;/li&gt;
&lt;li&gt;Key Features of Hardhat&lt;/li&gt;
&lt;li&gt;Truffle - What is Truffle?&lt;/li&gt;
&lt;li&gt;Key Feature of Truffle&lt;/li&gt;
&lt;li&gt;The Differences&lt;/li&gt;
&lt;li&gt;The Similarities&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;HARDHAT&lt;/strong&gt; : Hardhat dubs itself as the Ethereum development environment for professionals. It is an Ethereum based Development environment to build, develop, compile and deploy smart contracts created by the team at Nomic Foundation. It facilitates performing frequent tasks, such as running tests, automatically checking code for mistakes or interacting with a smart contract.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  KEY FEATURES OF HARDHAT
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Debugging contracts&lt;/strong&gt; : (Supports Console.log)&lt;/p&gt;

&lt;p&gt;Hardhat makes it a lot easy to debug your smart contract. You get solidity stack traces, can use console.log command and shows error messages when transaction fails which is very essential for developers to know where the application fails and how ro solve the error making the debugging process a lot easier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing and Deploying Contracts&lt;/strong&gt; (Pre-installed Ethereum local Testnet)&lt;/p&gt;

&lt;p&gt;You can run solidity locally, easily deploy your contracts, run tests and debug Solidity code without dealing with live environments. &lt;/p&gt;

&lt;p&gt;Hardhat comes with a pre-installed local ethereum network testnet. It makes it easier and possible to interact with smart contracts in testing directly without using a third party testing environment account and blockchain network like Ganache UI or Ganache CLI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Plugins Ecosystem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hardhat houses a range of Plugins and Libraries that enhance the functionality of hardhat and integrate your existing tools into a smooth workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Community and Resources&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hardhat has an active and supportive community, but being the baby in the house previously has no much resources as compared to truffle. But with the speed of mass Developers adopting Hardhat  there is now an avalanche of resources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage and Flexibility&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is it, where Hardhat wears the crown for its ease of integration, flexible functionalities, allowing you to change anything you like and customizable design with little constraints.&lt;/p&gt;

&lt;p&gt;It allows you to keep using your existing tools while enabling deeper interoperability between them and has all the utilities you need to address your project-specific needs.&lt;/p&gt;

&lt;p&gt;Now let's look at some of the features of Truffle now&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TRUFFLE&lt;/strong&gt; : Truffle Suite as the Trufflesuite team puts it is a world class development environment, testing framework and asset pipeline for blockchain using the ethereum virtual machine crafted by ConsenSys Inc&lt;/p&gt;

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

&lt;p&gt;Truffle Suite has three components: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Truffle&lt;/strong&gt; : It is a Development Environment, Testing Framework and Asset pipeline for Ethereum Blokchains.&lt;br&gt;
&lt;strong&gt;Ganache&lt;/strong&gt; : Ganache is a personal Ethereum Blockchain used to test smart contracts where you can deploy contracts, develop applications, run tests and perform other tasks without any cost.&lt;br&gt;
&lt;strong&gt;Drizzle&lt;/strong&gt; : Drizzle is a collection of libraries used to create easy and better front-end for Ethereum DApps.&lt;/p&gt;

&lt;h2&gt;
  
  
  KEY FEATURES OF TRUFFLE
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Smart Contract Management Circle&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Truffle takes care of managing your contract artifacts so you don't have to Includes support for custom deployments, library linking and complex Ethereum applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automated Contract Testing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Another helpful feature of Truffle is that it supports automated contract testing. You can write automated tests for your contracts in both JavaScript and Solidity, and get your contracts developed quickly bringing your dapp development to the 21st century&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interactive Console&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Truffle uses an interactive console access to all your built contracts and all available Truffle commands to save time and talk to your contracts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Debugging contracts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Truffle Debugger is a command line tool integrated into the Truffle Framework which allows smart contract transactions to be debugged using the smart contract code and transaction artifacts.&lt;/p&gt;

&lt;h2&gt;
  
  
  DIFFERENCE BETWEEN HARDHAT AND TRUFFLE
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Hardhat&lt;/strong&gt; comes with an integrated local Ethereum network to run and deploy smart contract,.&lt;br&gt;
&lt;strong&gt;Truffle&lt;/strong&gt; doesn't have an integrated local network. You need Ganache,a tool to set up your own local Ethereum blockchain that you can use to deploy and test your smart contracts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hardhat&lt;/strong&gt; supports Typescript&lt;br&gt;
&lt;strong&gt;Truffle&lt;/strong&gt; does not support Typescript or does with robust configurations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hardhat&lt;/strong&gt; houses Plugins ecosystem with customizable features depending on project-specific needs making it much more flexible.&lt;br&gt;
&lt;strong&gt;Truffle&lt;/strong&gt; is less flexible because it does not support many plugins as it has its own fixed way of doing things.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hardhat&lt;/strong&gt; makes debugging solidity codes easier with the console.log command that displays log messages in the terminal.&lt;br&gt;
&lt;strong&gt;Truffle&lt;/strong&gt; we write our own events and deal with it to test our contracts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hardhat&lt;/strong&gt; gives stack traces which makes it possible to inspect what happened in your contract if you change it or where an application fails and how to solve this problem.&lt;br&gt;
&lt;strong&gt;Truffle&lt;/strong&gt; just gives the error message instead of actual stack traces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hardhat&lt;/strong&gt; uses the Ethers.js library to interact with smart contracts as default, whereas&lt;br&gt;
&lt;strong&gt;Truffle&lt;/strong&gt; uses the Web3.js library to interact with smart contracts as default.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#NOTE&lt;/strong&gt; Both can use both libraries interchangeably with some configurations.&lt;/p&gt;

&lt;h2&gt;
  
  
  SIMILARITIES BETWEEN HARDHAT AND TRUFFLE
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Hardhat and Truffle&lt;/strong&gt; do the same thing for you; it helps you to develop, test and deploy the smart contracts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hardhat and Truffle&lt;/strong&gt; provide Javascript and Solidity based development frameworks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hardhat and Truffle&lt;/strong&gt; use the Ethereum network to develop, test and deploy the smart contracts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hardhat and Truffle&lt;/strong&gt; have a massive community and resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  CONCLUSION
&lt;/h2&gt;

&lt;p&gt;That's it guys!&lt;/p&gt;

&lt;p&gt;I've tried to cover the basics of Hardhat and Truffle and lay out the differences and similarities between them.. It's up to you to choose which development environment you want to work with.&lt;/p&gt;

&lt;p&gt;I'm Sunington, you can connect with me on &lt;a href="https://twitter.com/sunington"&gt;Twitter&lt;/a&gt;. Expect more indepth research and resources on Web3, Smart Contracts, and Blockchain in my subsequent Blog posts.&lt;/p&gt;

&lt;p&gt;Until we meet again&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/sunington"&gt;#KeepSunning&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>7 Tools you need to know as a Blockchain Developer.</title>
      <dc:creator>Sunington</dc:creator>
      <pubDate>Sun, 29 May 2022 16:16:07 +0000</pubDate>
      <link>https://dev.to/sunington/7-web3-tools-you-need-to-know-as-a-web3-developer-43ke</link>
      <guid>https://dev.to/sunington/7-web3-tools-you-need-to-know-as-a-web3-developer-43ke</guid>
      <description>&lt;p&gt;&lt;strong&gt;1) SOLIDITY:&lt;/strong&gt; Solidity is the most used and popular language in blockchain development to write smart contracts with syntax from Javascript, C++ and Python.&lt;/p&gt;

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

&lt;p&gt;As at now, Solidity is the most preferred language for most Blockchain developers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2) REMIX IDE&lt;/strong&gt; - Remix is an open source, web based Integrated Development Environment to write and develop solidity smart contracts (Just like VScode editors)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JQFade-M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6f6n7e8cfy5a9573mf7y.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JQFade-M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6f6n7e8cfy5a9573mf7y.jpg" alt="Image description" width="318" height="159"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3) METAMASK&lt;/strong&gt; : Metamask is a software that allows user to access the Ethereum blockchain and host arrays of decentralised Applications.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;4) HARDHAT&lt;/strong&gt; : Hardhat is an Ethereum blockchain developement environment that helps compile, deploy, test and debug your smart contracts and DApps (Equivalant of Truffle)&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;5) WEB3.JS&lt;/strong&gt; : Web3.js is a collection of JS libraries that allows developers to create application that interacts with Ethereum blockchain. (with local or remote Ethereum nodes)&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;6) GANACHE&lt;/strong&gt; : Ganache allows you to create a private Ethereum blockchain for developers to run, test, and execute commands. It allows you to perform all action you would on main chain with no cost.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;7) SOLC (SOLIDITY COMPILER)&lt;/strong&gt; : Solc is a JS library and command-line tool that is used to compile solidity files from High-level solidty language to an Ethereum virtual machine bytecode.&lt;/p&gt;

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

&lt;p&gt;And that's a wrap! You know others tools that are not mentioned? please feel free to add in the comment section.&lt;/p&gt;

&lt;p&gt;Liked it? Follow &lt;a href="https://twitter.com/sunington"&gt;@sunington&lt;/a&gt; for more tips and resources on Web3 and Blockchain Development.&lt;/p&gt;

&lt;p&gt;We meet again next time,&lt;/p&gt;

&lt;p&gt;Until then, #KeepSunning!&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>web3</category>
      <category>smartcontract</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
