{"id":2232,"date":"2022-01-25T17:51:25","date_gmt":"2022-01-25T17:51:25","guid":{"rendered":"https:\/\/lvboard.infostore.in.ua\/?p=2232"},"modified":"2022-01-26T08:50:56","modified_gmt":"2022-01-26T08:50:56","slug":"how-to-build-an-ethereum-transaction-app-with-react-and-solidity-part-2","status":"publish","type":"post","link":"https:\/\/lvboard.infostore.in.ua\/?p=2232","title":{"rendered":"How to Build an Ethereum Transaction App with React and Solidity: Part 2"},"content":{"rendered":"\n<p>What you\u2019ll be building: see a live <a href=\"https:\/\/dalto-98c21.web.app\/\">demo<\/a> and Git Repo <a href=\"https:\/\/github.com\/Daltonic\/dalto\">Here<\/a>. Remember, the online demo uses the ropsten test network.<\/p>\n\n\n\n<!--more-->\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyo-01-il-0-as-68-ga-3-ga-3-d.jpg\" alt=\"Dalto Ethereum Transaction App\"\/><\/figure>\n\n\n\n<h2>#Introduction<\/h2>\n\n\n\n<p>Following part one of this tutorial, we will be building the frontend side of this project. If you haven\u2019t seen the <a href=\"https:\/\/hackernoon.com\/build-your-own-ethereum-transaction-app-with-react-and-solidity-part-1\">PART-ONE<\/a>, I recommend you do it for the sake of understanding this part-two.<\/p>\n\n\n\n<p>If you are ready, let\u2019s crush this app\u2026<\/p>\n\n\n\n<h2>#Project Setup<\/h2>\n\n\n\n<p>Make sure you already have <a href=\"https:\/\/nodejs.org\/en\/\">NodeJs<\/a> installed on your machine, if you don\u2019t, follow the link below to do that.<\/p>\n\n\n\n<p>Jump into your projects directory and create a new folder called \u201cdalto\u201d. You can name it whatever you want, but for the sake of uniformity, I suggest you flow with me on the namings.<\/p>\n\n\n\n<p>Within this <strong>dalto<\/strong> directory, create two more folders called <strong>client<\/strong> and <strong>smart_contract<\/strong>, our ethereum code will live in the smart_contract folder, while the react app will live in the client directory. Lastly, open this project in your code editor, I prefer <strong>VS Code<\/strong>. If you did all that correctly, your project structure should look like this.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyp-01-im-0-as-6-fy-2-b-6-k-47.jpg\" alt=\"Project Structure\"\/><\/figure>\n\n\n\n<p><strong>Project Structure<\/strong> The codes should be structured in the following way.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyq-01-in-0-as-67-c-2-dgrkz.jpg\" alt=\"Client Structure\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyr-01-io-0-as-6-c-863369-p.jpg\" alt=\"Smart_contract Structure\"\/><\/figure>\n\n\n\n<h2>#The Smart Contract Setup<\/h2>\n\n\n\n<p>Jump into the terminal, <strong>move (cd)<\/strong> into the <strong>smart_contract<\/strong> directory and run the command below.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init -y<\/code><\/pre>\n\n\n\n<p>This will create an <strong>npm<\/strong> file in the root of the <strong>smart_contract<\/strong> folder. To specify the packages to be used for building the smart contract, we will run the code snippet below.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn add @nomiclabs\/hardhat-ethers @nomiclabs\/hardhat-waffle chai ethereum-waffle ethers hardhat --dev\n# or\nnpm install -D @nomiclabs\/hardhat-ethers @nomiclabs\/hardhat-waffle chai ethereum-waffle ethers hardhat<\/code><\/pre>\n\n\n\n<p>Please note that these packages are listed only in the development environment. After the installation is done, you will have a result similar to mine.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyr-01-ip-0-as-622-ztc-0-qj.jpg\" alt=\"Smart_contract package.json\"\/><\/figure>\n\n\n\n<p>Now you need to run the code below to set up <strong>hardhat<\/strong> in the current <strong>smart_contract<\/strong> folder.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn hardhat\n# or\nnpm hardhat<\/code><\/pre>\n\n\n\n<p>You will be prompted with some questions, you should select the following options.<\/p>\n\n\n\n<ul><li>Create a basic sample project when asked what you want to do.<\/li><li>Specify the current directory when asked for the root folder, this option is prefilled on the terminal for you.<\/li><li>Enter <strong>&#8216;y&#8217;<\/strong> when asked if you want to add a <strong>.gitIgnore<\/strong> and hit enter on your keyboard.<\/li><\/ul>\n\n\n\n<p>Once you specify the above options properly, hardhat will automatically generate the project structure for you.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflys-01-iq-0-as-6-bx-87-a-2-no.jpg\" alt=\"Hardhat Project Creation\"\/><\/figure>\n\n\n\n<p><strong>Processing the Smart Contract<\/strong> Next, head on to the <strong>smart_contract<\/strong> directory &gt;&gt; <strong>contracts<\/strong> and rename the <strong>Greeter.sol<\/strong> file to <strong>Transactions.sol<\/strong>. Afterward, paste the codes below in it, save and move along with me.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract Transactions {\n    address private owner;\n    uint256 transactionCounts;\n    mapping (address =&gt; uint) balanceOf;\n\n    event Transfer(address indexed sender, address indexed receiver, uint256 amount, string remark, uint256 timestamp);\n\n    struct TransferStruct {\n        address sender;\n        address receiver;\n        uint256 amount;\n        string remark;\n        uint256 timestamp;\n    }\n    \n    TransferStruct&#91;] transactions;\n\n    constructor() {\n        owner = msg.sender;\n        balanceOf&#91;tx.origin] = msg.sender.balance;\n    }\n\n    function getOwner() public view returns (address) {\n        return owner;\n    }\n\n    function sendMoney(address payable receiver, uint256 amount, string memory remark) public returns(bool success) {\n        if (balanceOf&#91;owner] &lt; amount) return false;\n        balanceOf&#91;owner] -= amount;\n        balanceOf&#91;receiver] += amount;\n\n        transactionCounts += 1;\n        transactions.push(\n            TransferStruct(\n                owner,\n                receiver,\n                amount,\n                remark,\n                block.timestamp\n            )\n        );\n\n        emit Transfer(msg.sender, receiver, amount, remark, block.timestamp);\n        return true;\n    }\n\n    function getBalance(address addr) public view returns(uint) {\n        return balanceOf&#91;addr];\n    }\n\n    function getAllTransactions() public view returns(TransferStruct&#91;] memory) {\n        return transactions;\n    }\n\n    function getTransactionsCount() public view returns(uint256) {\n        return transactionCounts;\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>Setting up the Deployment Script<\/strong> Head to <strong>smart_contract<\/strong> directory &gt;&gt; <strong>scripts<\/strong> and renaming the <strong>sample-script.js<\/strong> file to <strong>deploy.js<\/strong>. Afterward, replace the codes below in it. The code snippet below specifies where our smart contract will live on the web.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const hre = require('hardhat')\nconst main = async () =&gt; {\n  const Transactions = await hre.ethers.getContractFactory('Transactions')\n  const transactions = await Transactions.deploy()\n  await transactions.deployed()\n  console.log('Transactions deployed to:', transactions.address)\n}\nconst runMain = async () =&gt; {\n  try {\n    await main()\n    process.exit(0)\n  } catch (error) {\n    console.error(error)\n    process.exit(1)\n  }\n}\nrunMain()<\/code><\/pre>\n\n\n\n<p>Fantastic work, at this time you should already have your Rinkeby test network funded and ready for use, if you haven\u2019t, please go back to the <a href=\"https:\/\/hackernoon.com\/build-your-own-ethereum-transaction-app-with-react-and-solidity-part-1\">PART-ONE<\/a> of this tutorial, you will find the instruction there.<\/p>\n\n\n\n<p>Now it&#8217;s time to know about <a href=\"https:\/\/alchemyapi.io\/\">alchemy<\/a>\u2026<\/p>\n\n\n\n<h2>#Deploying to Alchemy<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflys-01-ir-0-as-65-r-919-pkh.jpg\" alt=\"Alchemy Blockchain Development and Deployment\"\/><\/figure>\n\n\n\n<p>Currently, our smart contract can only run on our computer and outsiders can\u2019t connect to it. To make it accessible for everyone at no cost, we will use alchemy for that.<\/p>\n\n\n\n<p>Proceed by signing up with them, or <a href=\"https:\/\/auth.alchemyapi.io\/?redirectUrl=https%3A%2F%2Fdashboard.alchemyapi.io\">LOG IN<\/a> if you already have an account.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyt-01-is-0-as-6-c-4-y-9-e-22-e.jpg\" alt=\"Authentication Page\"\/><\/figure>\n\n\n\n<p>Once you are logged in, you will see the dashboard page which gives you access to create a new blockchain application.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyt-01-it-0-as-6-d-14-sch-3-r.jpg\" alt=\"Alchemy Dashboard\"\/><\/figure>\n\n\n\n<p><strong>Creating an Alchemy App<\/strong> Click on the <strong>CREATE APP button<\/strong> and fill in the details you want as seen in the image below, make sure to specify the <strong>Rinkeby test network<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyu-01-iu-0-as-6-h-019-f-0-x-3.jpg\" alt=\"Create New App Popup\"\/><\/figure>\n\n\n\n<p>After you have created the app, click on the <strong>app name<\/strong> or view the details button to see the app information.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyu-01-iv-0-as-63-kd-80-b-8-x.jpg\" alt=\"Created App\"\/><\/figure>\n\n\n\n<p>Click on the <strong>VIEW KEY button<\/strong> and copy the <strong>HTTP URL<\/strong> as seen in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyw-01-iw-0-as-63-omc-9-jgl.jpg\" alt=\"Created App Http Details\"\/><\/figure>\n\n\n\n<p>Fantastic, now follow the steps as seen in the images below to get your Rinkeby account. Please note, we are not using the regular account address but the private key to that account.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyx-01-ix-0-as-60-xw-37-ddw.jpg\" alt=\"Step One\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyx-01-iy-0-as-6-hibxa-0-gn.jpg\" alt=\"Step Two\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyy-01-iz-0-as-6-esknagfg.jpg\" alt=\"Step Three\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyy-01-j-00-as-6-akc-20-xwz.jpg\" alt=\"Step Four\"\/><\/figure>\n\n\n\n<p>Awesome, now go back to <strong>VS code<\/strong> &gt;&gt; <strong>smart_contract<\/strong> &gt;&gt; <strong>hardhat.config.js<\/strong> and replace its content with the codes below. Use your own <strong>URL<\/strong> in place of the existing one in the file.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>require('@nomiclabs\/hardhat-waffle')\nmodule.exports = {\n  solidity: '0.8.0',\n  networks: {\n    rinkeby: {\n      url: '&lt;YOUR_ALCHEMY_APP_URL_GOES_HERE&gt;',\n      accounts: &#91;\n        '&lt;YOUR_RINKEBY_ACCOUNT_PRIVATE_KEY_GOES_HERE&gt;',\n      ],\n    },\n  },\n}<\/code><\/pre>\n\n\n\n<p>If you had done all that correctly, we just need to do one more thing before we move on to the frontend part of this project. Let\u2019s deploy this smart contract to Alchemy, run the code below, make sure your terminal is in the <strong>smart_contract<\/strong> directory.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn hardhat run scripts\/deploy.js --network rinkeby\nor\nnpx hardhat run scripts\/deploy.js --network rinkeby<\/code><\/pre>\n\n\n\n<p>After the smart contract is deployed successfully to Alchemy, you will have the <strong>smart contract address<\/strong> which you can see highlighted in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyz-01-j-10-as-6-firabbil.jpg\" alt=\"Deployed Contract\"\/><\/figure>\n\n\n\n<p>Please copy and save that address, it will later be used in the <strong>client<\/strong> directory &gt;&gt; <strong>utils<\/strong> &gt;&gt; <strong>constants.js<\/strong> file.<\/p>\n\n\n\n<p>Congratulations, you just completed the smart contract deployment, now let\u2019s use it in our frontend application.<\/p>\n\n\n\n<h2>#The Frontend Setup<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyz-01-j-20-as-6893-jg-8-ds.jpg\" alt=\"Using Vite React on the Frontend\"\/><\/figure>\n\n\n\n<p>Open the terminal, <strong>cd<\/strong> into the <strong>client<\/strong> directory, and perform the following instructions. For the frontend, we will use <a href=\"https:\/\/vitejs.dev\/guide\/#scaffolding-your-first-vite-project\">Vite<\/a> to create our react application, Vite is an awesome toolset that makes the process of creating your frontend application simple.<\/p>\n\n\n\n<p>For this build, we will also use Yarn as our primary package manager, it&#8217;s just so much nicer at installing npm packages. Note, all yarn commands can easily be done with npm as well. You just need to make a small adjustment. Now let\u2019s install Vite if you have not.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn create vite\n# or\nnpm init vite@latest<\/code><\/pre>\n\n\n\n<p>You will be prompted to enter your project name, just use \u201c<strong>.\/<\/strong>\u201d. This will instruct Vite to download the codes into the current directory <strong>(client)<\/strong>. Next, you will be prompted for the project name, simply key in \u201c<strong>dalto<\/strong>\u201d and then select <strong>react<\/strong> from the list of frameworks available. See the image below for guidance.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflyz-01-j-30-as-624-pphwut.jpg\" alt=\"Vite Installation Guide\"\/><\/figure>\n\n\n\n<p>After the above executions are done on the terminal, run the command below to install the <strong>npm modules<\/strong> to be used in our project.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn install\n# or\nnpm install<\/code><\/pre>\n\n\n\n<h2>#Installing Project Dependencies<\/h2>\n\n\n\n<p>After the process is done on the terminal, again you now have to install the following packages which our application depends on.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn add @heroicons\/react ethers @faker-js\/faker identicon.js react-hooks-global-state\n# or\nnpm install @heroicons\/react ethers @faker-js\/faker identicon.js react-hooks-global-state<\/code><\/pre>\n\n\n\n<p>If you have installed those packages, you are amazing, let\u2019s proceed to install the <a href=\"https:\/\/tailwindcss.com\/docs\/installation\/using-postcss\">tailwind CSS<\/a> which our application also depends on.<\/p>\n\n\n\n<h2>#Installing Tailwind CSS<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflz-201-j-40-as-6-f-8-oa-68-ij.jpg\" alt=\"Tailwind CSS\"\/><\/figure>\n\n\n\n<p>Use the commands below to do that.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn add tailwindcss postcss autoprefixer --dev\nyarn tailwindcss init\n# or\nnpm install -D tailwindcss postcss autoprefixer\nnpx tailwindcss init<\/code><\/pre>\n\n\n\n<p>You should have two files at the root of the <strong>client<\/strong> folder. <strong>tailwind.config.js<\/strong> and <strong>postcss.config.js<\/strong>, but if you don\u2019t you can create them yourself.<\/p>\n\n\n\n<p>Next, replace the contents of the two files with the following codes.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># postcss.config.js\nconst tailwindcss = require('tailwindcss')\nmodule.exports = {\n  plugins: &#91;tailwindcss('.\/tailwind.config.js'), require('autoprefixer')],\n}\n\n\n# tailwind.config.js\nmodule.exports = {\n  content: &#91;\n    \".\/src\/**\/*.{js,jsx,ts,tsx}\",\n  ],\n  theme: {\n    extend: {},\n  },\n  plugins: &#91;],\n}<\/code><\/pre>\n\n\n\n<p>Now, replace the content of <strong>index.css<\/strong> file at the <strong>client<\/strong> directory &gt;&gt; <strong>src<\/strong> with the codes below.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@tailwind base;\n@tailwind components;\n@tailwind utilities;<\/code><\/pre>\n\n\n\n<p>Very well, let\u2019s test the app to see if everything is working right by running the code below.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Running the application\nyarn dev\n# or\nnpm run dev<\/code><\/pre>\n\n\n\n<p>If you did everything right, you should have the same result as mine.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflz-301-j-50-as-6-cvgqdtqg.jpg\" alt=\"App running\"\/><\/figure>\n\n\n\n<p>Epic work so far, let\u2019s start coding. We will proceed by coding up the components.<\/p>\n\n\n\n<h2>#Coding the Components<\/h2>\n\n\n\n<p>We have four components and we will begin with the Header component. Before we do that, go to the <strong>client<\/strong> directory &gt;&gt; <strong>src<\/strong> and create a folder called components. This is where all our components will reside.<\/p>\n\n\n\n<p><strong>Header Component<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflz-301-j-60-as-64-oi-674-dj.jpg\" alt=\"The Header Component\"\/><\/figure>\n\n\n\n<p>Create a component called <strong>Header.jsx<\/strong>. This component contains the <strong>send button<\/strong> which is used to launch the <strong>addTransactionCard<\/strong> modal for entering new transactions. See code block below.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import ethLogo from '..\/assets\/ethlogo.png'\nimport { setGlobalState } from '..\/store'\n\nconst Header = () =&gt; {\n  return (\n    &lt;header className=\"flex flex-row items-center justify-between drop-shadow-md py-2 px-5 bg-white\"&gt;\n      &lt;div className=\"flex flex-row justify-center items-center cursor-pointer\"&gt;\n        &lt;img\n          className=\"w-6 h-6 object-contain cursor-pointer\"\n          src={ethLogo}\n          alt=\"Etherium Logo\"\n        \/&gt;\n        &lt;span&gt;Dalto&lt;\/span&gt;\n      &lt;\/div&gt;\n      &lt;nav className=\"flex flex-row justify-center items-center list-none\"&gt;\n        &lt;li className=\"cursor-pointer mr-3 hover:text-blue-500\"&gt;Pricing&lt;\/li&gt;\n        &lt;li className=\"cursor-pointer mr-3 hover:text-blue-500\"&gt;Docs&lt;\/li&gt;\n        &lt;li className=\"cursor-pointer mr-3\"&gt;\n          &lt;button\n            onClick={() =&gt; setGlobalState('modal', 'scale-100')}\n            className=\"text-white bg-blue-500 py-2 px-5 rounded-xl drop-shadow-xl border border-transparent hover:bg-transparent hover:text-blue-500 hover:border hover:border-blue-500 focus:outline-none focus:ring\"\n          &gt;\n            Send\n          &lt;\/button&gt;\n        &lt;\/li&gt;\n      &lt;\/nav&gt;\n    &lt;\/header&gt;\n  )\n}\n\nexport default Header<\/code><\/pre>\n\n\n\n<p>Amazing, let\u2019s create the <strong>AddTransactionCard<\/strong> component.<\/p>\n\n\n\n<p><strong>AddTransactionCard Component<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflz-401-j-70-as-650-udclxb.jpg\" alt=\"Send Transaction Modal\"\/><\/figure>\n\n\n\n<p>Still on the components directory, create another component called <strong>AddTransactionCard.jsx<\/strong>, afterward, paste the codes below in it and save. We will use this modal component for creating new transactions. A user can launch it whenever the <strong>send button<\/strong> at the Header component is clicked on.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { useGlobalState, setGlobalState } from '..\/store'\nimport { useState } from 'react'\nimport { sendMoney } from '..\/shared\/Transaction'\n\nconst AddTransactionCard = () =&gt; {\n  const &#91;modal] = useGlobalState('modal')\n  const &#91;connectedAccount] = useGlobalState('connectedAccount')\n  const &#91;address, setAddress] = useState('')\n  const &#91;amount, setAmount] = useState('')\n  const &#91;remark, setRemark] = useState('')\n  const &#91;loading, setLoading] = useState(false)\n\n  const handleSubmit = () =&gt; {\n    if (!address || !amount || !remark) return\n    setLoading(true)\n\n    sendMoney({ connectedAccount, address, amount, remark })\n      .then(() =&gt; {\n        setGlobalState('transaction', { address, amount, remark })\n        setLoading(false)\n        setGlobalState('modal', '')\n        resetForm()\n      })\n      .catch((error) =&gt; {\n        setLoading(false)\n        console.log(error)\n      })\n  }\n\n  const resetForm = () =&gt; {\n    setAddress('')\n    setAmount('')\n    setRemark('')\n  }\n\n  return (\n    &lt;div\n      className={`fixed top-0 left-0 w-screen h-screen flex items-center justify-center bg-black bg-opacity-50 transform scale-0 transition-transform duration-300 ${modal}`}\n    &gt;\n      &lt;div className=\"bg-white rounded-xl w-1\/3 h-7\/12 p-6\"&gt;\n        &lt;div className=\"flex flex-col\"&gt;\n          &lt;div className=\"flex flex-row justify-between items-center\"&gt;\n            &lt;p className=\"font-semibold text-gray-800\"&gt;Add a step&lt;\/p&gt;\n            &lt;button\n              onClick={() =&gt; setGlobalState('modal', '')}\n              className=\"border-0 bg-transparent focus:outline-none\"\n            &gt;\n              &lt;svg\n                className=\"w-6 h-6\"\n                fill=\"none\"\n                stroke=\"currentColor\"\n                viewBox=\"0 0 24 24\"\n                xmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n              &gt;\n                &lt;path\n                  strokeLinecap=\"round\"\n                  strokeLinejoin=\"round\"\n                  strokeWidth=\"2\"\n                  d=\"M6 18L18 6M6 6l12 12\"\n                &gt;&lt;\/path&gt;\n              &lt;\/svg&gt;\n            &lt;\/button&gt;\n          &lt;\/div&gt;\n\n          &lt;div className=\"flex flex-row justify-between items-center bg-gray-100 rounded-xl p-3 mt-5\"&gt;\n            &lt;input\n              className=\"bg-transparent focus:outline-none w-full\"\n              type=\"text\"\n              name=\"address\"\n              placeholder=\"Address To\"\n              onChange={(e) =&gt; setAddress(e.target.value)}\n              value={address}\n            \/&gt;\n          &lt;\/div&gt;\n\n          &lt;div className=\"flex flex-row justify-between items-center bg-gray-100 rounded-xl p-3 mt-5\"&gt;\n            &lt;input\n              className=\"bg-transparent focus:outline-none w-full\"\n              type=\"number\"\n              step={0.0001}\n              name=\"amount\"\n              placeholder=\"Amount (Eth)\"\n              onChange={(e) =&gt; setAmount(e.target.value)}\n              value={amount}\n            \/&gt;\n          &lt;\/div&gt;\n\n          &lt;div className=\"flex flex-row justify-between items-center bg-gray-100 rounded-xl p-3 mt-5\"&gt;\n            &lt;input\n              className=\"bg-transparent focus:outline-none w-full\"\n              type=\"text\"\n              name=\"remark\"\n              placeholder=\"Remark\"\n              onChange={(e) =&gt; setRemark(e.target.value)}\n              value={remark}\n            \/&gt;\n          &lt;\/div&gt;\n\n          &lt;div className=\"flex flex-row justify-between items-centerrounded-xl mt-5\"&gt;\n            {!loading ? (\n              &lt;button\n                type=\"submit\"\n                onClick={handleSubmit}\n                className=\"flex flex-row justify-center items-center w-full text-white text-lg bg-blue-500 py-2 px-5 rounded-xl drop-shadow-xl border border-transparent hover:bg-transparent hover:text-blue-500 hover:border hover:border-blue-500 focus:outline-none focus:ring\"\n              &gt;\n                Send Money\n              &lt;\/button&gt;\n            ) : (\n              &lt;button\n                className=\"flex flex-row justify-center items-center w-full text-white text-lg bg-blue-300 py-2 px-5 rounded-xl drop-shadow-xl border border-transparent focus:outline-none focus:ring\"\n                disabled\n              &gt;\n                &lt;svg\n                  xmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n                  width=\"30px\"\n                  height=\"30px\"\n                  viewBox=\"0 0 100 100\"\n                  preserveAspectRatio=\"xMidYMid\"\n                &gt;\n                  &lt;path\n                    d=\"M10 50A40 40 0 0 0 90 50A40 42 0 0 1 10 50\"\n                    fill=\"white\"\n                    stroke=\"none\"\n                  &gt;\n                    &lt;animateTransform\n                      attributeName=\"transform\"\n                      type=\"rotate\"\n                      dur=\"1s\"\n                      repeatCount=\"indefinite\"\n                      keyTimes=\"0;1\"\n                      values=\"0 50 51;360 50 51\"\n                    &gt;&lt;\/animateTransform&gt;\n                  &lt;\/path&gt;\n                &lt;\/svg&gt;\n                Sending...\n              &lt;\/button&gt;\n            )}\n          &lt;\/div&gt;\n        &lt;\/div&gt;\n      &lt;\/div&gt;\n    &lt;\/div&gt;\n  )\n}\n\nexport default AddTransactionCard<\/code><\/pre>\n\n\n\n<p>Nice, let create the rest of the components.<\/p>\n\n\n\n<p><strong>Hero Component<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflz-401-j-80-as-62-qk-83-gsn.jpg\" alt=\"The Hero Component\"\/><\/figure>\n\n\n\n<p>Create another component with the name <strong>Hero.jsx<\/strong> in the components folder. This component contains the descriptions of what this application does. It has no special functionality but assists the beauty of our app design. Paste the codes below in it and save.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { LightningBoltIcon, ScaleIcon } from '@heroicons\/react\/outline'\n\nconst Hero = () =&gt; {\n  const features = &#91;\n    {\n      name: 'No hidden fees',\n      description:\n        'Sending money is free of charge, you have no need for a middle man or annoying taxes.',\n      icon: ScaleIcon,\n    },\n    {\n      name: 'Transfers are instant',\n      description:\n        'You do not have to wait for days anymore, you can get you money in seconds within any country in the world',\n      icon: LightningBoltIcon,\n    },\n  ]\n\n  return (\n    &lt;div className=\"py-12 bg-white\"&gt;\n      &lt;div className=\"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8\"&gt;\n        &lt;div className=\"lg:text-center\"&gt;\n          &lt;p className=\"mt-2 text-3xl leading-8 font-extrabold tracking-tight text-gray-900 sm:text-4xl\"&gt;\n            A better way to send money\n          &lt;\/p&gt;\n          &lt;p className=\"mt-4 max-w-2xl text-xl text-gray-500 lg:mx-auto\"&gt;\n            Explore the crypto world. Buy and sell cryptocurrencies easily on\n            Dalto.\n          &lt;\/p&gt;\n        &lt;\/div&gt;\n\n        &lt;div className=\"mt-10\"&gt;\n          &lt;dl className=\"space-y-10 md:space-y-0 md:grid md:grid-cols-2 md:gap-x-8 md:gap-y-10\"&gt;\n            {features.map((feature) =&gt; (\n              &lt;div key={feature.name} className=\"relative\"&gt;\n                &lt;dt&gt;\n                  &lt;div className=\"drop-shadow-xl absolute flex items-center justify-center h-12 w-12 rounded-md bg-blue-500 text-white\"&gt;\n                    &lt;feature.icon className=\"h-6 w-6\" aria-hidden=\"true\" \/&gt;\n                  &lt;\/div&gt;\n                  &lt;p className=\"ml-16 text-lg leading-6 font-medium text-gray-900\"&gt;\n                    {feature.name}\n                  &lt;\/p&gt;\n                &lt;\/dt&gt;\n                &lt;dd className=\"mt-2 ml-16 text-base text-gray-500\"&gt;\n                  {feature.description}\n                &lt;\/dd&gt;\n              &lt;\/div&gt;\n            ))}\n          &lt;\/dl&gt;\n        &lt;\/div&gt;\n      &lt;\/div&gt;\n    &lt;\/div&gt;\n  )\n}\n\nexport default Hero<\/code><\/pre>\n\n\n\n<p>Lastly, let\u2019s create the Tabular component.<\/p>\n\n\n\n<p><strong>Tabular Component<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/cdn.hackernoon.com\/images\/ckyifflz-501-j-90-as-675-jsfh-9-j.jpg\" alt=\"The Tabular Component\"\/><\/figure>\n\n\n\n<p>Create a component with the name <strong>Tabular.jsx<\/strong> in the components folder and paste the codes below in it. This component is responsible for rendering all the transactions recorded in our blockchain network. Observe the code below.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { useEffect, useState } from 'react'\nimport ethLogo from '..\/assets\/ethlogo.png'\nimport Identicon from 'identicon.js'\nimport faker from '@faker-js\/faker'\nimport { getAllTransactions } from '..\/shared\/Transaction'\nimport { useGlobalState } from '..\/store'\n\nconst Tabuler = () =&gt; {\n  const &#91;transactionsStore] = useGlobalState('transactions')\n  const &#91;transactionCount] = useGlobalState('transactionCount')\n  const &#91;transactions, setTransaction] = useState(&#91;])\n  const &#91;start, setStart] = useState(0)\n  const &#91;end, setEnd] = useState(6)\n\n  const makeImage = (address) =&gt; {\n    const data = new Identicon(address, 400).toString()\n    return `data:image\/png;base64,${data}`\n  }\n\n  const loadMoreTransactions = () =&gt; {\n    setTransaction((prevState) =&gt; &#91;\n      ...prevState,\n      ...transactionsStore.slice(start, end),\n    ])\n    setStart(end)\n    setEnd(end * 2)\n  }\n\n  const shortenAddress = (address) =&gt;\n    `${address.slice(0, 5)}...${address.slice(address.length - 4)}`\n\n  useEffect(() =&gt; {\n    getAllTransactions().then((data) =&gt; {\n      setTransaction(&#91;...data.slice(start, end)])\n      setStart(end)\n      setEnd(end * 2)\n    })\n  }, &#91;])\n\n  return (\n    &lt;&gt;\n      &lt;section className=\"antialiased rounded-xl text-gray-600 p-5\"&gt;\n        &lt;div className=\"flex flex-col justify-center h-full\"&gt;\n          &lt;div className=\"max-w-full mx-auto px-4 sm:px-6 lg:px-8 bg-white shadow-2xl rounded-xl\"&gt;\n            &lt;header className=\"px-5 py-4\"&gt;\n              &lt;h2 className=\"font-semibold text-gray-800 text-center\"&gt;\n                Total Transactions({transactionCount})\n              &lt;\/h2&gt;\n            &lt;\/header&gt;\n            &lt;div className=\"p-3\"&gt;\n              &lt;div className=\"overflow-x-auto\"&gt;\n                &lt;table className=\"table-auto w-full\"&gt;\n                  &lt;thead className=\"text-xs font-semibold uppercase text-gray-400 bg-gray-50\"&gt;\n                    &lt;tr&gt;\n                      &lt;th className=\"p-2 whitespace-nowrap\"&gt;\n                        &lt;div className=\"font-semibold text-left\"&gt;Name&lt;\/div&gt;\n                      &lt;\/th&gt;\n                      &lt;th className=\"p-2 whitespace-nowrap\"&gt;\n                        &lt;div className=\"font-semibold text-left\"&gt;Sender&lt;\/div&gt;\n                      &lt;\/th&gt;\n                      &lt;th className=\"p-2 whitespace-nowrap\"&gt;\n                        &lt;div className=\"font-semibold text-left\"&gt;Receiver&lt;\/div&gt;\n                      &lt;\/th&gt;\n                      &lt;th className=\"p-2 whitespace-nowrap\"&gt;\n                        &lt;div className=\"font-semibold text-left\"&gt;Amount&lt;\/div&gt;\n                      &lt;\/th&gt;\n                      &lt;th className=\"p-2 whitespace-nowrap\"&gt;\n                        &lt;div className=\"font-semibold text-left\"&gt;Timestamp&lt;\/div&gt;\n                      &lt;\/th&gt;\n                      &lt;th className=\"p-2 whitespace-nowrap\"&gt;\n                        &lt;div className=\"font-semibold text-center\"&gt;Remark&lt;\/div&gt;\n                      &lt;\/th&gt;\n                    &lt;\/tr&gt;\n                  &lt;\/thead&gt;\n                  &lt;tbody className=\"text-sm divide-y divide-gray-100\"&gt;\n                    {transactions.map((tx, index) =&gt; (\n                      &lt;tr key={index + 1}&gt;\n                        &lt;td className=\"p-2 whitespace-nowrap\"&gt;\n                          &lt;div className=\"flex items-center\"&gt;\n                            &lt;div className=\"w-10 h-10 flex-shrink-0 mr-2 sm:mr-3\"&gt;\n                              &lt;img\n                                className=\"rounded-full\"\n                                src={makeImage(tx.sender)}\n                                width=\"40\"\n                                height=\"40\"\n                                alt=\"Alex Shatov\"\n                              \/&gt;\n                            &lt;\/div&gt;\n                            &lt;div className=\"font-medium text-gray-800\"&gt;\n                              {faker.name.findName()}\n                            &lt;\/div&gt;\n                          &lt;\/div&gt;\n                        &lt;\/td&gt;\n                        &lt;td className=\"p-2 whitespace-nowrap\"&gt;\n                          &lt;div className=\"text-left\"&gt;\n                            &lt;a\n                              href={`https:\/\/ropsten.etherscan.io\/address\/${tx.sender}`}\n                              target=\"_blank\"\n                              rel=\"noreferrer\"\n                              className=\"hover:text-blue-500\"\n                            &gt;\n                              {shortenAddress(tx.sender)}\n                            &lt;\/a&gt;\n                          &lt;\/div&gt;\n                        &lt;\/td&gt;\n                        &lt;td className=\"p-2 whitespace-nowrap\"&gt;\n                          &lt;div className=\"text-left\"&gt;\n                            &lt;a\n                              href={`https:\/\/ropsten.etherscan.io\/address\/${tx.receiver}`}\n                              target=\"_blank\"\n                              rel=\"noreferrer\"\n                              className=\"hover:text-blue-500\"\n                            &gt;\n                              {shortenAddress(tx.receiver)}\n                            &lt;\/a&gt;\n                          &lt;\/div&gt;\n                        &lt;\/td&gt;\n                        &lt;td className=\"p-2 whitespace-nowrap\"&gt;\n                          &lt;div className=\"flex flex-row justify-center items-center text-left font-medium\"&gt;\n                            &lt;img\n                              className=\"w-3 h-3 object-contain cursor-pointer mr-1\"\n                              src={ethLogo}\n                              alt=\"Etherium Logo\"\n                            \/&gt;\n                            &lt;span className=\"text-green-500\"&gt;{tx.amount}&lt;\/span&gt;\n                          &lt;\/div&gt;\n                        &lt;\/td&gt;\n                        &lt;td className=\"p-2 whitespace-nowrap\"&gt;\n                          &lt;div className=\"text-sm text-center\"&gt;\n                            {tx.timestamp}\n                          &lt;\/div&gt;\n                        &lt;\/td&gt;\n                        &lt;td className=\"p-2 whitespace-nowrap\"&gt;\n                          &lt;div className=\"text-sm text-center\"&gt;{tx.remark}&lt;\/div&gt;\n                        &lt;\/td&gt;\n                      &lt;\/tr&gt;\n                    ))}\n                  &lt;\/tbody&gt;\n                &lt;\/table&gt;\n              &lt;\/div&gt;\n            &lt;\/div&gt;\n          &lt;\/div&gt;\n        &lt;\/div&gt;\n      &lt;\/section&gt;\n      &lt;div className=\"text-center mt-5 mb-10\"&gt;\n        &lt;button\n          onClick={loadMoreTransactions}\n          className=\"text-white bg-blue-500 py-2 px-5 rounded-xl drop-shadow-xl border border-transparent hover:bg-transparent hover:text-blue-500 hover:border hover:border-blue-500 focus:outline-none focus:ring\"\n        &gt;\n          Load more\n        &lt;\/button&gt;\n      &lt;\/div&gt;\n    &lt;\/&gt;\n  )\n}\n\nexport default Tabuler<\/code><\/pre>\n\n\n\n<p>All these components are unified by a single store of data using the <a href=\"https:\/\/www.npmjs.com\/package\/react-hooks-global-state\">react-hooks-global-state<\/a> npm package. Now let\u2019s bring together the above components into the <strong>App<\/strong> component.<\/p>\n\n\n\n<h2>#The App Component<\/h2>\n\n\n\n<p>The codes below get all the components united and working together.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { useEffect } from 'react'\nimport AddTransactionCard from '.\/components\/AddTransactionCard'\nimport Header from '.\/components\/Header'\nimport Hero from '.\/components\/Hero'\nimport Tabuler from '.\/components\/Tabuler'\nimport {\n  isWallectConnected,\n  checkIfTransactionExist,\n  connectWallet,\n} from '.\/shared\/Transaction'\nimport { useGlobalState } from '.\/store'\n\nconst App = () =&gt; {\n  const &#91;connectedAccount] = useGlobalState('connectedAccount')\n  useEffect(() =&gt; {\n    isWallectConnected()\n    checkIfTransactionExist()\n  }, &#91;])\n\n  return (\n    &lt;div className=\"flex flex-col min-h-screen\"&gt;\n      &lt;Header \/&gt;\n      &lt;Hero \/&gt;\n      {!connectedAccount ? (\n        &lt;div className=\"text-center mb-10\"&gt;\n          &lt;button\n            onClick={connectWallet}\n            className=\"text-white bg-blue-500 py-2 px-5 rounded-xl drop-shadow-xl border border-transparent hover:bg-transparent hover:text-blue-500 hover:border hover:border-blue-500 focus:outline-none focus:ring\"\n          &gt;\n            Connect Wallet\n          &lt;\/button&gt;\n        &lt;\/div&gt;\n      ) : (\n        &lt;&gt;\n          &lt;Tabuler \/&gt;\n          &lt;AddTransactionCard \/&gt;\n        &lt;\/&gt;\n      )}\n    &lt;\/div&gt;\n  )\n}\n\nexport default App<\/code><\/pre>\n\n\n\n<p>Cool, the above code joins all our components together, but what about the state manage? How is it coupled together? Let\u2019s look at the <strong>react-hooks-global-state<\/strong> store setup.<\/p>\n\n\n\n<h2>#The Data Store<\/h2>\n\n\n\n<p>Goto the <strong>client<\/strong> &gt;&gt; <strong>src<\/strong> directory and create a folder called store. Inside this store folder create a file called <strong>index.jsx<\/strong> and paste the codes below in it.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { createGlobalState } from 'react-hooks-global-state'\nconst { setGlobalState, useGlobalState } = createGlobalState({\n  modal: '',\n  connectedAccount: '',\n  transactions: &#91;],\n  transaction: {\n    address: '',\n    amount: '',\n    remark: '',\n  },\n  transactionCount: localStorage.getItem('transactionCount'),\n})\nexport { useGlobalState, setGlobalState }<\/code><\/pre>\n\n\n\n<p>Nice, this simple state management package takes away all the complexities of Redux or the Context API. This is where we store all our transactions and keep track of the connected account.<\/p>\n\n\n\n<p>If you\u2019ve gotten up to this point, you deserve a cup of coffee, let\u2019s work on the next part.<\/p>\n\n\n\n<h2>#The Application Utilities<\/h2>\n\n\n\n<p>Head to the <strong>client<\/strong> folder &gt;&gt; <strong>src<\/strong> directory and create a new folder called <strong>utils<\/strong>. Now, inside of this utils folder create two files called <strong>constants.js<\/strong> and <strong>Transactions.json<\/strong>. The <strong>JSON<\/strong> file contains the Application Binary Interface (<strong>ABI<\/strong>) which was generated by hardhat and the <strong>js<\/strong> file will prepare it for exports.<\/p>\n\n\n\n<p>The ABI is generated by hardhat after compilation, it describes our smart contract and prepares it in a way it can be understood by <strong>ethers.js<\/strong>.<\/p>\n\n\n\n<p>On the <strong>smart_contract<\/strong> directory goto &gt;&gt; <strong>artifacts<\/strong> &gt;&gt; <strong>contracts<\/strong> &gt;&gt; <strong>Transactions.sol<\/strong> &gt;&gt; <strong>Transactions.json<\/strong>. You will copy the entire codes in this file and paste them in <strong>client<\/strong> &gt;&gt; <strong>src<\/strong> &gt;&gt; <strong>utils<\/strong> &gt;&gt; <strong>Transactions.json<\/strong>.<\/p>\n\n\n\n<p>Next, paste the code below into the constants.js file.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import abi from '.\/Transactions.json'\nexport const contractAbi = abi.abi\nexport const contractAddress = '&lt;YOUR_DEPLOYED_SMART_CONTRACT_ADDRESS_GOES_HERE&gt;'<\/code><\/pre>\n\n\n\n<p>Awesome, I know this has been intense, but be cool, we are almost finishing up.<\/p>\n\n\n\n<h2>#The Smart Contract Resources<\/h2>\n\n\n\n<p>This file provides us with all the methods available in the <strong>Transactions.sol<\/strong> file. These methods will help us communicate with the blockchain app using the <strong>ethers.js<\/strong> library and the URL we copied from Alchemy.<\/p>\n\n\n\n<p>Create a folder named <strong>shared<\/strong> within <strong>client<\/strong> directory &gt;&gt; <strong>src.<\/strong> Create a file named <strong>Transaction.jsx<\/strong> and paste the codes below in it.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { ethers } from 'ethers'\nimport { setGlobalState } from '..\/store'\n\nimport { contractAbi, contractAddress } from '..\/utils\/constants'\n\nconst { ethereum } = window\n\nconst getEtheriumContract = () =&gt; {\n  const provider = new ethers.providers.Web3Provider(ethereum)\n  const signer = provider.getSigner()\n  const transactionContract = new ethers.Contract(\n    contractAddress,\n    contractAbi,\n    signer\n  )\n\n  return transactionContract\n}\n\nconst isWallectConnected = async () =&gt; {\n  try {\n    if (!ethereum) return alert('Please install Metamask')\n    const accounts = await ethereum.request({ method: 'eth_accounts' })\n\n    if (accounts.length) {\n      setGlobalState('connectedAccount', accounts&#91;0])\n    } else {\n      console.log('No accounts found.')\n    }\n  } catch (error) {\n    console.log(error)\n    throw new Error('No ethereum object.')\n  }\n}\n\nconst checkIfTransactionExist = async () =&gt; {\n  try {\n    const transactionContract = getEtheriumContract()\n    const transactionCount = await transactionContract.getTransactionsCount()\n\n    window.localStorage.setItem('transactionCount', transactionCount)\n  } catch (error) {\n    console.log(error)\n    throw new Error('No ethereum object.')\n  }\n}\n\nconst connectWallet = async () =&gt; {\n  try {\n    if (!ethereum) return alert('Please install Metamask')\n    const accounts = await ethereum.request({ method: 'eth_requestAccounts' })\n    setGlobalState('connectedAccount', accounts&#91;0])\n  } catch (error) {\n    console.log(error)\n    throw new Error('No ethereum object.')\n  }\n}\n\nconst sendMoney = async ({ connectedAccount, address, amount, remark }) =&gt; {\n  try {\n    if (!ethereum) return alert('Please install Metamask')\n    const transactionContract = getEtheriumContract()\n    const parsedAmount = ethers.utils.parseEther(amount)\n\n    await ethereum.request({\n      method: 'eth_sendTransaction',\n      params: &#91;\n        {\n          from: connectedAccount,\n          to: address,\n          gas: '0x5208',\n          value: parsedAmount._hex,\n        },\n      ],\n    })\n\n    const transactionHash = await transactionContract.sendMoney(\n      address,\n      parsedAmount,\n      remark\n    )\n    console.log(`Loading - ${transactionHash.hash}`)\n    await transactionHash.wait()\n    console.log(`Success - ${transactionHash.hash}`)\n\n    const transactionCount = await transactionContract.getTransactionsCount()\n    setGlobalState('transactionCount', transactionCount.toNumber())\n\n    window.location.reload()\n  } catch (error) {\n    console.log(error)\n    throw new Error('No ethereum object.')\n  }\n}\n\nconst getAllTransactions = async () =&gt; {\n  try {\n    if (!ethereum) return alert('Please install Metamask')\n    const transactionContract = getEtheriumContract()\n    const availableTransactions = await transactionContract.getAllTransactions()\n\n    const structuredTransactions = availableTransactions.map((tx) =&gt; ({\n      receiver: tx.receiver,\n      sender: tx.sender,\n      timestamp: new Date(tx.timestamp.toNumber() * 1000).toLocaleString(),\n      remark: tx.remark,\n      amount: parseInt(tx.amount._hex) \/ 10 ** 18,\n    })).reverse()\n    \n    setGlobalState('transactions', structuredTransactions)\n    return structuredTransactions\n  } catch (error) {\n    console.log(error)\n    throw new Error('No ethereum object.')\n  }\n}\n\nexport {\n  getEtheriumContract,\n  isWallectConnected,\n  checkIfTransactionExist,\n  connectWallet,\n  sendMoney,\n  getAllTransactions,\n}<\/code><\/pre>\n\n\n\n<p>If you are confused about what the above functions do, please consult the <a href=\"https:\/\/hackernoon.com\/build-your-own-ethereum-transaction-app-with-react-and-solidity-part-1\">PART-ONE<\/a> of this tutorial here.<\/p>\n\n\n\n<p>Download and place the following images in the <strong>client<\/strong> directory &gt;&gt; <strong>src<\/strong> &gt;&gt; <strong>assets<\/strong> and your done.<\/p>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/raw.githubusercontent.com\/Daltonic\/dalto\/main\/client\/src\/assets\/ethLogo.png\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/github.com\/Daltonic\/dalto\/blob\/main\/client\/src\/assets\/logo.png?raw=true\n<\/div><\/figure>\n\n\n\n<p>Great, you just crushed the entire application, its time to test it out, run the code below.NoneBashCSSCC#GoHTMLObjective-CJavaJavaScriptJSONPerlPHPPowershellPythonRubyRustSQLTypeScriptYAMLCopy<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn dev\n# or \nnpm run dev<\/code><\/pre>\n\n\n\n<h2>#Conclusion<\/h2>\n\n\n\n<p>Congratulations on completing a full-fledge decentralized application with react and solidity.<\/p>\n\n\n\n<p>Building a web3.0 app can be challenging, being that it demands a lot of skills and components, but it&#8217;s not impossible.<\/p>\n\n\n\n<p>Hopefully, the knowledge you gained from this tutorial has helped in some way. Please leave a handclap, or click on the like button to show some love.<\/p>\n\n\n\n<p>Thanks for coding along, see you in the <strong>next tutorial<\/strong>\u2026<\/p>\n\n\n\n<p><a href=\"https:\/\/hackernoon.com\/how-to-build-an-ethereum-transaction-app-with-react-and-solidity-part-2\">https:\/\/hackernoon.com\/how-to-build-an-ethereum-transaction-app-with-react-and-solidity-part-2<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What you\u2019ll be building: see a live demo and Git Repo Here. Remember, the online demo uses the ropsten test network.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[178],"tags":[174,65,176],"_links":{"self":[{"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/posts\/2232"}],"collection":[{"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2232"}],"version-history":[{"count":1,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/posts\/2232\/revisions"}],"predecessor-version":[{"id":2233,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/posts\/2232\/revisions\/2233"}],"wp:attachment":[{"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}