<?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: Luis Lucena</title>
    <description>The latest articles on DEV Community by Luis Lucena (@luislucena16).</description>
    <link>https://dev.to/luislucena16</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%2F809958%2Ffd056ba7-f48f-4fb4-9131-c0a72ac9a3d8.png</url>
      <title>DEV Community: Luis Lucena</title>
      <link>https://dev.to/luislucena16</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/luislucena16"/>
    <language>en</language>
    <item>
      <title>Solidity Complete Fundamentals Cheat Sheet</title>
      <dc:creator>Luis Lucena</dc:creator>
      <pubDate>Thu, 01 Sep 2022 21:57:41 +0000</pubDate>
      <link>https://dev.to/luislucena16/solidity-complete-fundamentals-cheat-sheet-26a6</link>
      <guid>https://dev.to/luislucena16/solidity-complete-fundamentals-cheat-sheet-26a6</guid>
      <description>&lt;ul&gt;
&lt;li&gt;What is Solidity?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is a contract-oriented high level language for implementing smart contracts. It was influenced by C++, JavaScript and Python and is designed to target the EVM.&lt;/p&gt;

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

&lt;p&gt;Contracts in solidity are similar to classes in object oriented language.&lt;br&gt;
A contract can be created using "new" keyword.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;contract L &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;function &lt;/span&gt;add&lt;span class="o"&gt;(&lt;/span&gt;unit_p, unit_q&lt;span class="o"&gt;)&lt;/span&gt; returns&lt;span class="o"&gt;(&lt;/span&gt;unit&lt;span class="o"&gt;){&lt;/span&gt;
return_p+_q&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
contract M&lt;span class="o"&gt;{&lt;/span&gt;
address p&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;function &lt;/span&gt;f&lt;span class="o"&gt;(&lt;/span&gt;unit_p&lt;span class="o"&gt;){&lt;/span&gt;
p &lt;span class="o"&gt;=&lt;/span&gt; new L&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Smart Contracts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is a computer protocol which is used to streamline the process of contracts by digitally enforcing, verifying and managing them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remix, Solium &amp;amp; Doxity
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Remix: It is a browser based IDE with integrated compiler and solidity run-time environment without server side components.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Solium: A linter to identity and fix style security issues in solidity.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Doxity: Used in solidity as a documentation generator.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Solograph &amp;amp; Assembly
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Solograph: Used to visualize solidity control flow and highlight potential security vulnerabilities.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Solidity Assembly: An assembly language which is used without solidity &amp;amp; inline assembly inside solidity source code.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gas &amp;amp; Block Gas Limit
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Gas: A measurement roughly equivalent to the computational steps.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Block Gas limit: It is used to control the amount of gas consumed during the transactions.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Solidity Compiler
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;        Contract Definition
                |
         Solidity Compiler
                |
      Byte code - Application Binary Interface &lt;span class="o"&gt;(&lt;/span&gt;ABI&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;ABI &amp;amp; WEI
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- ABI: A data encoding scheme called "Application Binary Interface" (ABI) is used in for working with smart contracts.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- WEI: The smallest denomination or base unit of Ether.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Global Variables
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- block.blockhash(uint numberOfBlock)returns(bytes32): hash function of the given block which works for the 256 most recent blocks excluding the current block.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- block.coinbase(address): shows miner's address of current block.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- block.numer(uint): number of current block.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- block.gaslimit(uint): gaslimit of the current block.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- block.timestamp(uint): timestamp of current block.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- msg.gas(uint): the gas that remains.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- msg.value(uint): the amount of WEI sent along with the message.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- msg.sender(address): address of the message sender(current call).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- msg.sig(bytes4): first four bytes of the call data.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- now (uint): timestamp for the current block..
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- tx.origin(address): the sender of the transaction(whole call chain).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Used to specify certain conditions under which the source files can or cannot run.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Example:
- pragma solidity ^0.8.15
       This code compiles with a compiler &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt;0.8.15
- A pseudocode example &lt;span class="k"&gt;for &lt;/span&gt;pragma syntax
       &lt;span class="s1"&gt;'pragma'&lt;/span&gt; Identifier&lt;span class="o"&gt;([&lt;/span&gt;^&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;+&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="s1"&gt;';'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Interface &lt;span class="k"&gt;in &lt;/span&gt;solidity are defined as contractsm but the &lt;span class="k"&gt;function &lt;/span&gt;bodies are omitted &lt;span class="k"&gt;for &lt;/span&gt;the functions.
Example:
pragma solidity ^0.22
interfaceToken
&lt;span class="o"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;function &lt;/span&gt;transfer&lt;span class="o"&gt;(&lt;/span&gt;address recipient, uint amount&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Data Types
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;- Boolean:
&lt;span class="nb"&gt;true &lt;/span&gt;or &lt;span class="nb"&gt;false
&lt;/span&gt;Logical:!&lt;span class="o"&gt;(&lt;/span&gt;Logical negation&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;AND&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;OR&lt;span class="o"&gt;)&lt;/span&gt;
Comparisons:&lt;span class="o"&gt;==(&lt;/span&gt;equality&lt;span class="o"&gt;)&lt;/span&gt;,!&lt;span class="o"&gt;=(&lt;/span&gt;inequality&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;- Integer: Unsigned Integer, and Signed integer Comparisons:&amp;lt;&lt;span class="o"&gt;=(&lt;/span&gt;Less than or equal to&lt;span class="o"&gt;)&lt;/span&gt;, &amp;lt;&lt;span class="o"&gt;(&lt;/span&gt;Less than&lt;span class="o"&gt;)&lt;/span&gt;,&lt;span class="o"&gt;==(&lt;/span&gt;equal to&lt;span class="o"&gt;)&lt;/span&gt;,!&lt;span class="o"&gt;=(&lt;/span&gt;Not equal to&lt;span class="o"&gt;)&lt;/span&gt;,&amp;gt;&lt;span class="o"&gt;=(&lt;/span&gt;Greater than or equal to&lt;span class="o"&gt;)&lt;/span&gt;,&amp;gt;&lt;span class="o"&gt;(&lt;/span&gt;Greater than&lt;span class="o"&gt;)&lt;/span&gt; Arithmetic Operators: + &lt;span class="o"&gt;(&lt;/span&gt;Addition&lt;span class="o"&gt;)&lt;/span&gt;, - &lt;span class="o"&gt;(&lt;/span&gt;Subtraction&lt;span class="o"&gt;)&lt;/span&gt;, Unary —, Unary +, &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;Multiplication&lt;span class="o"&gt;)&lt;/span&gt;, / &lt;span class="o"&gt;(&lt;/span&gt;Division&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="k"&gt;**&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;Exponential&lt;span class="o"&gt;)&lt;/span&gt;, &amp;lt;&amp;lt; &lt;span class="o"&gt;(&lt;/span&gt;Left &lt;span class="nb"&gt;shift&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="o"&gt;&amp;gt;&amp;gt;(&lt;/span&gt;Right &lt;span class="nb"&gt;shift&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Address: Holds an Ethereum address(20 byte value).
Operators: Comparisons: &amp;lt;=, &amp;lt;, ==, !=, &amp;gt;= and &amp;gt;
Balance:
- &amp;lt;address&amp;gt;.balance(uint256): balance of address in WEI
Transfer and send:
- &amp;lt;address&amp;gt;. transfer(uint256 amount): send given amount of Wei to Address, throws on failure.
- &amp;lt;addres&amp;gt;.send(uint256 amount)returns(bool): send given amount of Wei to Address, returns false on failure.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Global functions:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- keccak256(...)returns(bytes32)-computes the ethereum SHA-3 hash associated with the arguments.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- SHA256(..)returns(bytes32) — Computes the SHA-256 argument hash.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- mulmod( uint a, uint b, uint c)returns(uint): It computes (a*b)/c, if the multiplication gets executed using arbitrary precision, thus not wrapping around 2**256
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- addmod(uint p, unint q, uint m)returns(uint): Computes (p+q)/m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- ecrecover(bytes32 _hash, uint8 _v, bytes32 _r, bytes32 _s)
returns (address): recovers the address linked with the public key and if an error occurs, zero is returned.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- ripemd160(...)returns(bytes20): computes the RIPEMD-160
(tightly packed) argument hash.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- &amp;lt;address&amp;gt;.balance(uint256): Returns the balance of the specified address in WEI.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- &amp;lt;address&amp;gt;.send(uint256 amount)returns(bool): It sends the specified number of WEI to the address given, on failure it returns false as an output.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- &amp;lt;address&amp;gt;.transfer(uint256 amount): Sends specified number of WEI to the particular address, on failure throws.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Access Modifiers:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Public: Accessible from the current contract, inherited contracts externally.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Private: Accessible only form the current contract.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Internal: Accessible only from current contract and contracts inheriting from it.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- External: Can be accessed externally only.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Important Terms
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Voting: When the contract is quiet complex, it uses voting contract, it shows how delegated voting can be done so that vote counting is automatic and completely transparent at the same time.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Delegate call: It is a reusable library code that can be applied to a contracts storage in solidity.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Logs: A feature called logs is used in solidity to implement events.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- NPM: It is a convenient and portable way to install Solidity compiler.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Truffle: It is a test bed that will allow to easily test and compile the smart contract.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Inheritance: In solidity inheritance is more syntactic. In the final compilation the compiler copies the parent class members to create the byte-code of the derived contract with the copied members.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- This: This is a keyword that refers to the instance of the contract where the call is made.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- msg.sender: This function refers to the address where the contract is being called from.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Pure: It is a modifier which assures not to be read from or modified.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- View: In solidity, view is a function that promises to not modify the state of the smart contract.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Suicide: It is a alias for self destruct function, that is used to destroy the current contract.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Delete: Delete is used to delete all elements in an array.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Block.coinbase(address): It refers to the minter's address of the current block.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Address(contractVar).send(amount): If a built-in send function needs to be used, it can be accessed using this function.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Super: It is used to refer the contract that is higher by one level in the inheritance hierarchy.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Transaction Example&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I hope this can be of service to you ❤️
Any feedback is welcome :)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;tw: &lt;a href="https://twitter.com/_luisald"&gt;@_luisald&lt;/a&gt;&lt;br&gt;
website: &lt;a href="https://bio.link/luislucena"&gt;Luis Lucena&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>blockchain</category>
      <category>web3</category>
      <category>programming</category>
    </item>
    <item>
      <title>Hardhat bug fix with MetaMask due to chainId</title>
      <dc:creator>Luis Lucena</dc:creator>
      <pubDate>Sun, 10 Jul 2022 22:29:30 +0000</pubDate>
      <link>https://dev.to/luislucena16/hardhat-bug-fix-with-metamask-due-to-chainid-166o</link>
      <guid>https://dev.to/luislucena16/hardhat-bug-fix-with-metamask-due-to-chainid-166o</guid>
      <description>&lt;h2&gt;
  
  
  Fix
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This is a &lt;a href="https://hardhat.org/"&gt;Hardhat&lt;/a&gt; error that originates because &lt;a href="https://metamask.io/"&gt;MetaMask&lt;/a&gt; takes the default network and hardhat works with another network. Here is a sample of the &lt;a href="https://github.com/MetaMask/metamask-extension/issues/10290"&gt;error&lt;/a&gt; and how to fix it.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;h2&gt;
  
  
  Config your hardhat.config.js file
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Manually add the &lt;code&gt;chaindId:1337&lt;/code&gt; to avoid the conflict with MetaMask&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;e.g&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require("@nomicfoundation/hardhat-toolbox");
// The next line is part of the sample project, you don't need it in your
// project. It imports a Hardhat task definition, that can be used for
// testing the frontend.
require("./tasks/faucet");
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.9",
  networks: {
    hardhat: {
      chainId: 1337 // We set 1337 to make interacting with MetaMask simpler
    }
  }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Boot up local development blockchain
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx hardhat node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Connect development blockchain accounts to MetaMask
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Copy private key of the addresses and import to MetaMask&lt;br&gt;
Connect your MetaMask to hardhat blockchain, network 127.0.0.1:8545.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you have not added hardhat to the list of networks on your MetaMask, open up a browser, click the fox icon, then click the top center drop down button that lists all the available networks then click add networks. A form should pop up. For the "Network Name" field enter "Hardhat". For the "New RPC URL" field enter "&lt;a href="http://127.0.0.1:8545"&gt;http://127.0.0.1:8545&lt;/a&gt;". For the chain ID enter "1337". Then click save.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Migrate Smart Contracts
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx hardhat run src/contracts/scripts/deploy.js --network localhost
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Finally
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Once you have your test account on the hardhat node you will have 10000 ETH to deploy your contracts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy coding!❤️&lt;br&gt;
💫 contributions are appreciate..&lt;br&gt;
ETH address: luislucena.eth&lt;br&gt;
tw: &lt;a href="https://twitter.com/_luisald"&gt;_luisald&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>programming</category>
      <category>web3</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Web3 terms you should know</title>
      <dc:creator>Luis Lucena</dc:creator>
      <pubDate>Sat, 02 Jul 2022 05:55:35 +0000</pubDate>
      <link>https://dev.to/luislucena16/web3-terms-you-should-know-4hl2</link>
      <guid>https://dev.to/luislucena16/web3-terms-you-should-know-4hl2</guid>
      <description>&lt;p&gt;CEX: Centralized Exchange&lt;br&gt;
DEX: Decentralized Exchange&lt;br&gt;
DEFI: Decentralized finance&lt;br&gt;
CEFI: Centralized finance&lt;br&gt;
DAOS: Decentralized Autonomous Organization&lt;br&gt;
DApps: Decentralized Applications&lt;br&gt;
TVL: Total Value Locked&lt;br&gt;
PoW: Proof of Work&lt;br&gt;
PoS: Proof of Stake&lt;br&gt;
APY: Annual percentage yield&lt;br&gt;
IR: Interest Rate&lt;/p&gt;

&lt;p&gt;NFT: Non Fungible Token&lt;br&gt;
DYOR: Do your own research&lt;br&gt;
NFA: Not Financial Advice&lt;br&gt;
BTFD: Buy the fucking dip&lt;br&gt;
Wagmi: We are gonna make it&lt;br&gt;
KYC: Know Your Customer&lt;br&gt;
P2P: Peer To Peer&lt;br&gt;
FUD: fear, uncertainly, doubt&lt;br&gt;
FOMO: fear of missing out&lt;/p&gt;

&lt;p&gt;ATH: all time High&lt;br&gt;
ATL: all time Low&lt;br&gt;
TF: Time Frame&lt;br&gt;
HTF: higher time Frame&lt;br&gt;
LTF: lower time Frame&lt;br&gt;
ST: short term&lt;br&gt;
LT: long term&lt;br&gt;
IT: Intermediate Term&lt;br&gt;
SL: Stop Loss&lt;br&gt;
TL: Trend Line&lt;br&gt;
WR: Win Rate&lt;/p&gt;

&lt;p&gt;R/R: Risk/Reward&lt;br&gt;
BE: Break Even&lt;br&gt;
TP: Take Profit&lt;br&gt;
TA: Technical Analysis (or AT)&lt;/p&gt;

&lt;p&gt;FA: Fundamental Analysis (or AF)&lt;br&gt;
EW: Elliott Waves &lt;br&gt;
SMC: Smart money concept&lt;br&gt;
PA: Price Action&lt;/p&gt;

&lt;p&gt;VSA: Volume Spread Analysis&lt;br&gt;
PDH: Previous Day High &lt;br&gt;
PDL: Previous Day Low&lt;br&gt;
PWH: Previous Week High &lt;br&gt;
PWL: Previous Week Low &lt;br&gt;
PMH: Previous Month High&lt;br&gt;
PML: Previous Month Low &lt;br&gt;
EQH: Equal Highs &lt;br&gt;
EQL: Equal Lows &lt;br&gt;
HH: Higher High &lt;br&gt;
HL: Higher Low &lt;br&gt;
LH: Lower High&lt;br&gt;
LL: Lower Low&lt;/p&gt;

&lt;p&gt;HTF: Higher Time Frame&lt;br&gt;
RN: Round Numbers &lt;br&gt;
OSOK: One Shot One Kill&lt;br&gt;
BMS: Break in Market&lt;br&gt;
OB: Order Block&lt;br&gt;
BR: Breaker &lt;br&gt;
MB: Mitigation Block &lt;br&gt;
RB: Reclaimed Block-Rejection Block&lt;br&gt;
PB: Propulsion Block&lt;br&gt;
VB: Vacuum Block &lt;br&gt;
FVG: Fair Value Gap &lt;br&gt;
LV: Liquidity Void &lt;br&gt;
LP:Liquidity Pool &lt;/p&gt;

&lt;p&gt;CL: Candy Land &lt;br&gt;
CPR: Central Pivot Range&lt;br&gt;
BISI: Buy Side Imbalance Sell Side Inefficiency &lt;br&gt;
SIBI: Sell Side Imbalance Buy Side Inefficiency &lt;br&gt;
OF: Order Flow&lt;br&gt;
AD: Accumulation y/o Distribution&lt;br&gt;
AMD: Accumulation, Manipulation and Distribution&lt;br&gt;
OHLC: Open, High, Low and Close&lt;/p&gt;

&lt;p&gt;IRL: Internal Range Liquidity &lt;br&gt;
ERL: External Range Liquidity &lt;br&gt;
Fib: Fibonacci&lt;br&gt;
OTE: Optimal Trade Entry &lt;br&gt;
FV: Fair Value&lt;br&gt;
SMT: Smart Money Tool / Technique&lt;br&gt;
IOF: Institutional Order Flow &lt;br&gt;
TS: Trailing Stop&lt;br&gt;
KZ: Kill Zone&lt;br&gt;
AR: Automatic Rally&lt;br&gt;
ST: Secondary Test&lt;br&gt;
SC: Selling Climax&lt;/p&gt;

&lt;p&gt;BC: Buying Climax&lt;br&gt;
BUEC: Backup to the edge of the creek&lt;br&gt;
LPS: Last Point of Support&lt;br&gt;
TR: Trading Range&lt;br&gt;
JAC: Cross or Jump the creek&lt;br&gt;
SOS: Sign of Strength&lt;br&gt;
E/R: Effort versus Result&lt;br&gt;
PS: Preliminary Supply&lt;br&gt;
SOW: Sign of Weakness&lt;br&gt;
LPSY: Last Point Of Supply&lt;/p&gt;

&lt;p&gt;C/E: Law of Cause and Effect&lt;br&gt;
S/E: Law of Supply &amp;amp; Demand&lt;br&gt;
UTAD: Upthrust After Distribution&lt;br&gt;
UT: Upthrust&lt;/p&gt;

&lt;p&gt;✨ Let's learn the terms mostly mentioned on the web3!&lt;/p&gt;

&lt;p&gt;tw: &lt;a href="https://twitter.com/_luisald"&gt;_luisald&lt;/a&gt;&lt;br&gt;
website: &lt;a href="https://bio.link/luislucena"&gt;Luis Lucena&lt;/a&gt;&lt;br&gt;
contribution:&lt;br&gt;
ETH address: luislucena.eth&lt;/p&gt;

</description>
      <category>programming</category>
      <category>blockchain</category>
      <category>productivity</category>
      <category>web3</category>
    </item>
    <item>
      <title>Browser-Game with Solidity, JS, BSC, NodeJS, Hardhat , Chainlink</title>
      <dc:creator>Luis Lucena</dc:creator>
      <pubDate>Tue, 08 Feb 2022 01:19:03 +0000</pubDate>
      <link>https://dev.to/luislucena16/browser-game-with-solidity-js-bsc-nodejs-hardhat-chainlink-1pma</link>
      <guid>https://dev.to/luislucena16/browser-game-with-solidity-js-bsc-nodejs-hardhat-chainlink-1pma</guid>
      <description>&lt;h2&gt;
  
  
  The Crypto Purge 💸
&lt;/h2&gt;

&lt;p&gt;The most revolutionary crypto shooter-survival real-time NFT-based game on &lt;strong&gt;Binance Smart Chain.&lt;/strong&gt;&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Inspiration
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;The Crypto Purge&lt;/code&gt; is a crypto shooter-survival real-time NFT-based game inspired by &lt;a href="https://en.wikipedia.org/wiki/The_Purge"&gt;The Purge (an American dystopian action horror film).&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;p&gt;Players will have multiple modes to play the game, &lt;code&gt;single&lt;/code&gt; and &lt;code&gt;multiplayer&lt;/code&gt;. &lt;strong&gt;Single mode&lt;/strong&gt; includes killing zombies and social ranking with friends for earn prizes, the top scorers on the &lt;code&gt;leaderboard&lt;/code&gt; will split the prize pool grant. &lt;strong&gt;Multiplayer mode&lt;/strong&gt; allows players to contribute a certain amount of tokens to the prize pool before each game and the prize pool is split by &lt;code&gt;Smart Contracts&lt;/code&gt; and a &lt;code&gt;Server Side authority&lt;/code&gt; between the &lt;strong&gt;winners&lt;/strong&gt; of the game. The game allow users to mint custom skins with &lt;strong&gt;NFTs&lt;/strong&gt; to be used in the game (&lt;strong&gt;Chainlink VRF&lt;/strong&gt; and Oracles to assign provably rare traits). Player will differ in appearance and style, but they will have no effect on the game mode. All players will have an equal change of winning the game.&lt;/p&gt;

&lt;h2&gt;
  
  
  How we built it
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;The Crypto Purge&lt;/code&gt; has a crypto integrated backend that runs on &lt;strong&gt;Binance Smart Chain. Smart contracts&lt;/strong&gt; are responsible for prize pool redistribution and &lt;strong&gt;web3.js (Metamask, etc)&lt;/strong&gt; takes care of the wallet connection. We built the app using ReactJS, Phaser Framework, Hardhat with Chainlink Oracles for smart contracts development and NodeJS with Express Framework using Socket.io for real-time connections.&lt;/p&gt;

&lt;h2&gt;
  
  
  Challenges we ran into
&lt;/h2&gt;

&lt;p&gt;Creating a &lt;strong&gt;decentralized real-time&lt;/strong&gt; game that requires a back-end connection using &lt;code&gt;WebSockets&lt;/code&gt; is the most challenging part of the project, additionally because &lt;strong&gt;"don’t trust the player. Always assume the worst – that players will try to cheat"&lt;/strong&gt;, so it requires an &lt;code&gt;authority server&lt;/code&gt; to create a &lt;strong&gt;cheat-proof&lt;/strong&gt; architecture as cheating players tends to drive the players away from the game, therefore the core problems are &lt;code&gt;human nature&lt;/code&gt; and &lt;code&gt;physics&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Developing an &lt;code&gt;authoritative server architecture&lt;/code&gt; introduce a whole new class of challenges; &lt;code&gt;Client-Side Prediction&lt;/code&gt;, &lt;code&gt;Server Reconciliation&lt;/code&gt;, &lt;code&gt;Entity Interpolation&lt;/code&gt;, &lt;code&gt;Lag Compensation&lt;/code&gt; dealing with networks and scaling the system itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Accomplishments that we're proud of
&lt;/h2&gt;

&lt;p&gt;We're proud to have created the real-time connection of the game, creating the smart contracts of the platform and the base architecture of the project; &lt;strong&gt;front-end, back-end&lt;/strong&gt; and the smart contracts development using &lt;strong&gt;Hardhat&lt;/strong&gt; with &lt;strong&gt;Chainlink Oracles&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we learned
&lt;/h2&gt;

&lt;p&gt;We learned about &lt;code&gt;Blockchain&lt;/code&gt;, &lt;code&gt;Smart Contracts&lt;/code&gt;, &lt;code&gt;NFTs&lt;/code&gt;, &lt;code&gt;Chainlink Oracles&lt;/code&gt;, &lt;code&gt;2D Games&lt;/code&gt; with &lt;code&gt;WebGL/Canvas&lt;/code&gt; using Frameworks like &lt;code&gt;PhaserJS&lt;/code&gt;, &lt;code&gt;Physics&lt;/code&gt;, &lt;code&gt;Real-time&lt;/code&gt; connections with &lt;code&gt;WebSockets&lt;/code&gt;, &lt;code&gt;Crypto wallets&lt;/code&gt; and much more!&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next for The Crypto Purge
&lt;/h2&gt;

&lt;p&gt;Allow gamers to edit their profile.&lt;br&gt;
Open Marketplace to buy and mint custom skins.&lt;br&gt;
Allow gamers to mint weapons and other assets.&lt;br&gt;
Allow gamers to have an inventory.&lt;br&gt;
Add a better configuration for the monorepo and create a Docker image with the configuration to run the project anywhere.&lt;br&gt;
Use Microservices strategy for complex calculations and horizontal scaling, To infinity and beyond!&lt;br&gt;
Share the end results and inspire others with Open Source contributions.&lt;/p&gt;

&lt;p&gt;Built With&lt;br&gt;
&lt;code&gt;alchemyapi&lt;/code&gt;,&lt;code&gt;blockchain&lt;/code&gt;,&lt;code&gt;canvas&lt;/code&gt;,&lt;code&gt;chainlink&lt;/code&gt;,&lt;code&gt;css3&lt;/code&gt;,&lt;code&gt;ethers&lt;/code&gt;,&lt;code&gt;express.js&lt;/code&gt;,&lt;code&gt;github&lt;/code&gt;,&lt;code&gt;hardhat&lt;/code&gt;,&lt;code&gt;heroku&lt;/code&gt;,&lt;code&gt;html5&lt;/code&gt;,&lt;code&gt;javascript&lt;/code&gt;,&lt;code&gt;phaser.js&lt;/code&gt;,&lt;code&gt;react&lt;/code&gt;,&lt;code&gt;socket.io&lt;/code&gt;,&lt;code&gt;solidity&lt;/code&gt;,&lt;code&gt;web3&lt;/code&gt;,&lt;code&gt;webgl&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/proyecto26/TheCryptoPurge"&gt;GitHub repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Made with ❤️ by &lt;a href="https://bio.link/luislucena"&gt;Luis Lucena&lt;/a&gt; and &lt;a href="https://bio.link/jdnichollsc"&gt;J.D Nicholls&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Twitter: &lt;a href="https://twitter.com/_luisald"&gt;Luis Lucena&lt;/a&gt; and &lt;a href="https://twitter.com/jdnichollsc"&gt;J.D Nicholls&lt;/a&gt; &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>blockchain</category>
      <category>gamedev</category>
      <category>web3</category>
    </item>
    <item>
      <title>What are MetaMask "Accounts" or "Sub-Accounts"? And why are they not as private as they are supposed to be?</title>
      <dc:creator>Luis Lucena</dc:creator>
      <pubDate>Mon, 07 Feb 2022 00:15:34 +0000</pubDate>
      <link>https://dev.to/luislucena16/what-are-metamask-accounts-or-sub-accounts-and-why-are-they-not-as-private-as-they-are-supposed-to-be-2c58</link>
      <guid>https://dev.to/luislucena16/what-are-metamask-accounts-or-sub-accounts-and-why-are-they-not-as-private-as-they-are-supposed-to-be-2c58</guid>
      <description>&lt;p&gt;When a wallet is created in Metamask, the famous seed phrase (or seed phrase) is generated, which are 12 words that must be stored securely. This seed phrase is generated by the BIP39 standard (BIP = Bitcoin Improvement Proposals). They come from a list of 2048 words.&lt;/p&gt;

&lt;p&gt;Each of these words corresponds to a number, so the 12 words are actually equivalent to 12 numbers, which it is important that they are in order.&lt;/p&gt;

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

&lt;p&gt;Based on the 12 numbers (seed integer) and using the SHA256 hash function, a private key is generated. Then the public key corresponding to the private key is derived using the ECDSA (Elliptic Curve Signature Algorithm).&lt;/p&gt;

&lt;p&gt;Finally, the previously derived public key is hashed with the keccak256 hash function and from the resulting hash the last 20 bytes are taken, a 0x is added in front and this results in your Ethereum address.&lt;/p&gt;

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

&lt;p&gt;Let's say to sum it up, the flow goes something like this:&lt;br&gt;
Seed phrase &amp;gt; Seed integer &amp;gt; SHA256 &amp;gt; Private Key &amp;gt; ECDSA &amp;gt; Public Key &amp;gt; keccak256 &amp;gt; Last 20 bytes + 0x &amp;gt; Your Ethereum address🤓&lt;/p&gt;

&lt;p&gt;Then the password with which you configure MetaMask is used to encrypt the private key on the device (browser or cell phone). This is why it is VERY important not to set a basic password, because if the key store file is stolen, they will be able to crack it easily and empty your wallet&lt;/p&gt;

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

&lt;p&gt;So far it's all very nice and quite simple. This address created is your "Default account" or the first account or address you see created in MetaMask as soon as you generate it or import the seed phrase.&lt;/p&gt;

&lt;p&gt;Then let's remember that MetaMask allows us to create N "Accounts" or "sub accounts" or "address". These accounts are all controlled by the same seed phrase but each one has its own address and therefore its own public key and private key.&lt;/p&gt;

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

&lt;p&gt;To create these sub-accounts, MetaMask takes the private key of Account 1, hashes it, and from this hash function comes Account 2. It then hashes Account 2 to generate Account 3 and so on N times. Each account is the resulting hash of the previous account.&lt;/p&gt;

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

&lt;p&gt;As each Account has its own address and therefore its own public and private key (and they were generated by hashing each one from the previous one), the different addresses or accounts cannot "IN PRINCIPLE" be linked by someone who does not know the private key&lt;/p&gt;

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

&lt;p&gt;This means that although I control N address, nobody could know that they are all controlled by the same wallet, so this is supposed to be a mechanism that gives some privacy, since I can have different wallets for each thing and nobody knows that they are all mine.&lt;/p&gt;

&lt;p&gt;Before we go on, let's remember: each wallet has 1 seed phrase and with this seed phrase controls N amount of address which each one has its own private key and its own public key.&lt;/p&gt;

&lt;p&gt;All very nice and very secure at cryptographic level, BUT (there is always a but) the system has a flaw (flaw for us who want privacy, feature for those who want to investigate us Woman detective)&lt;/p&gt;

&lt;p&gt;Every time we install MetaMask, the app defines an API TOKEN (an identifier) that the app is going to use to connect to the Ethereum node you use (Infura by default) to bring the balance data and do the balanceOf() and to relay the transaction.&lt;/p&gt;

&lt;p&gt;So if you have address A, address B and address C, the RPC node you use sees that the transactions going out of the 3 addresses all use the same API TOKEN (also called API KEY) and therefore knows that all 3 belong to the same wallet.&lt;/p&gt;

&lt;p&gt;In addition to this, the nodes can save the IP (by default it is a data that is discarded, but not all do it clearly), but this is something that is quite well known so many assume that by changing the IP via VPN every time you go to operate with another address you were ok.&lt;/p&gt;

&lt;p&gt;What can we do about it? Every time we are going to make a new transfer from a different address we have to uninstall Metamask and reinstall it, so the API key is reset. Besides changing our IP obviously, with a VPN.&lt;/p&gt;

&lt;p&gt;The other solution is to have our own node and interact from our wallet directly with it, this way we make sure that the node we operate against is not storing any of this data that can link the addresses.&lt;/p&gt;

&lt;p&gt;Many will think it's too convoluted, but this is one of the mechanisms used by companies doing on-chain analysis to identify everything from funds originating from hacks to following traces of individuals and organizations seeking privacy.&lt;/p&gt;

&lt;p&gt;It does not come to the point of the thread but since we are, another mechanism is to track via cookies and browser extensions, which are the addresses we are looking for in browsers, thus linking the addresses and "inferring" that they are of the same owner&lt;/p&gt;

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

&lt;p&gt;Sources:&lt;br&gt;
&lt;a href="https://t.co/ZBSBWI2Psk" rel="noopener noreferrer"&gt;https://t.co/ZBSBWI2Psk&lt;/a&gt;&lt;br&gt;
&lt;a href="https://t.co/oBZTY6TJyJ" rel="noopener noreferrer"&gt;https://t.co/oBZTY6TJyJ&lt;/a&gt;&lt;br&gt;
&lt;a href="https://t.co/wLhQPXYvlj" rel="noopener noreferrer"&gt;https://t.co/wLhQPXYvlj&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you found it interesting, ideas and criticisms are welcome❤️❤️&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>security</category>
      <category>web3</category>
      <category>algorithms</category>
    </item>
  </channel>
</rss>
