{"id":897,"date":"2025-06-23T02:15:37","date_gmt":"2025-06-23T02:15:37","guid":{"rendered":"https:\/\/eolais.cloud\/?p=897"},"modified":"2025-06-23T02:41:09","modified_gmt":"2025-06-23T02:41:09","slug":"frontend-for-apartment-rental-dapp-react-web3-js","status":"publish","type":"post","link":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/","title":{"rendered":"Frontend for Apartment Rental DApp (React + Web3.js)"},"content":{"rendered":"\n<p>This frontend connects to the\u00a0<strong>ApartmentRental<\/strong>\u00a0smart contract, allowing landlords and tenants to interact with the lease agreement.<\/p>\n\n\n<p>Read this first:\u00a0<a href=\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/smart-contract-for-apartment-rental-payments-solidity\/\">Smart Contract for Apartment Rental &amp; Payments (Solidity)<\/a><\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1. Setup the Project<\/strong><\/h2>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">npx create-react-app apartment-rental-dapp\ncd apartment-rental-dapp\nnpm install web3 @metamask\/detect-provider @chakra-ui\/react ethers<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. Key Components<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Connect Wallet<\/strong>&nbsp;(MetaMask)<\/li>\n\n\n\n<li><strong>Landlord Dashboard<\/strong>&nbsp;(Create lease, refund deposit)<\/li>\n\n\n\n<li><strong>Tenant Dashboard<\/strong>&nbsp;(Pay rent, terminate lease)<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. Full Frontend Code<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><code>App.js<\/code>&nbsp;(Main Component)<\/strong><\/h3>\n\n\n\n<p>jsx<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { useState, useEffect } from 'react';\nimport { ChakraProvider, Button, Box, Heading, Input, Text, VStack, HStack, Alert, AlertIcon } from '@chakra-ui\/react';\nimport Web3 from 'web3';\nimport ApartmentRentalABI from '.\/ApartmentRentalABI.json'; \/\/ Import ABI\n\nfunction App() {\n  const [web3, setWeb3] = useState(null);\n  const [account, setAccount] = useState('');\n  const [contract, setContract] = useState(null);\n  const [isLandlord, setIsLandlord] = useState(false);\n  const [isTenant, setIsTenant] = useState(false);\n  const [leaseDetails, setLeaseDetails] = useState(null);\n\n  \/\/ Contract Address (Replace with your deployed address)\n  const CONTRACT_ADDRESS = \"0x123...YourContractAddress\";\n\n  \/\/ Initialize Web3 and Contract\n  useEffect(() =&gt; {\n    const initWeb3 = async () =&gt; {\n      if (window.ethereum) {\n        const web3Instance = new Web3(window.ethereum);\n        setWeb3(web3Instance);\n        \n        const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });\n        setAccount(accounts[0]);\n        \n        const contractInstance = new web3Instance.eth.Contract(\n          ApartmentRentalABI,\n          CONTRACT_ADDRESS\n        );\n        setContract(contractInstance);\n\n        \/\/ Check if user is landlord or tenant\n        const landlord = await contractInstance.methods.landlord().call();\n        setIsLandlord(accounts[0].toLowerCase() === landlord.toLowerCase());\n\n        const tenant = await contractInstance.methods.tenant().call();\n        setIsTenant(accounts[0].toLowerCase() === tenant.toLowerCase());\n\n        \/\/ Load lease details\n        if (tenant !== \"0x0000000000000000000000000000000000000000\") {\n          const details = {\n            rentAmount: await contractInstance.methods.rentAmount().call(),\n            securityDeposit: await contractInstance.methods.securityDeposit().call(),\n            leaseStart: await contractInstance.methods.leaseStart().call(),\n            leaseEnd: await contractInstance.methods.leaseEnd().call(),\n            isActive: await contractInstance.methods.isLeaseActive().call(),\n          };\n          setLeaseDetails(details);\n        }\n      } else {\n        alert(\"Please install MetaMask!\");\n      }\n    };\n    initWeb3();\n  }, []);\n\n  \/\/ Sign Lease (Tenant)\n  const signLease = async () =&gt; {\n    const value = Web3.utils.toWei(\n      (leaseDetails.rentAmount + leaseDetails.securityDeposit).toString(), \n      'ether'\n    );\n    await contract.methods.signLease().send({ from: account, value });\n    alert(\"Lease signed successfully!\");\n  };\n\n  \/\/ Pay Rent (ETH)\n  const payRent = async (month) =&gt; {\n    const value = Web3.utils.toWei(leaseDetails.rentAmount.toString(), 'ether');\n    await contract.methods.payRent(month).send({ from: account, value });\n    alert(`Rent for month ${month} paid!`);\n  };\n\n  \/\/ Refund Deposit (Landlord)\n  const refundDeposit = async (deductions) =&gt; {\n    await contract.methods.refundDeposit(deductions).send({ from: account });\n    alert(\"Deposit refunded!\");\n  };\n\n  \/\/ Terminate Lease\n  const terminateLease = async () =&gt; {\n    await contract.methods.terminateLease().send({ from: account });\n    alert(\"Lease terminated!\");\n  };\n\n  return (\n    &lt;ChakraProvider&gt;\n      &lt;Box p={8}&gt;\n        &lt;Heading mb={6}&gt;\ud83c\udfe0 Decentralized Apartment Rental&lt;\/Heading&gt;\n        \n        {!account ? (\n          &lt;Button onClick={() =&gt; window.ethereum.request({ method: 'eth_requestAccounts' })}&gt;\n            Connect MetaMask\n          &lt;\/Button&gt;\n        ) : (\n          &lt;VStack spacing={6} align=\"start\"&gt;\n            &lt;Text&gt;Connected as: {account}&lt;\/Text&gt;\n            \n            {isLandlord &amp;&amp; (\n              &lt;Box borderWidth=\"1px\" p={4} borderRadius=\"md\"&gt;\n                &lt;Heading size=\"md\"&gt;\ud83d\udc54 Landlord Dashboard&lt;\/Heading&gt;\n                {leaseDetails &amp;&amp; leaseDetails.isActive ? (\n                  &lt;Button mt={2} onClick={() =&gt; terminateLease()}&gt;\n                    Terminate Lease (Penalty: 1 Month Rent)\n                  &lt;\/Button&gt;\n                ) : (\n                  &lt;Button mt={2} onClick={() =&gt; refundDeposit(0)}&gt;\n                    Refund Deposit\n                  &lt;\/Button&gt;\n                )}\n              &lt;\/Box&gt;\n            )}\n\n            {isTenant &amp;&amp; leaseDetails &amp;&amp; (\n              &lt;Box borderWidth=\"1px\" p={4} borderRadius=\"md\"&gt;\n                &lt;Heading size=\"md\"&gt;\ud83d\udc64 Tenant Dashboard&lt;\/Heading&gt;\n                &lt;Text&gt;Rent: {Web3.utils.fromWei(leaseDetails.rentAmount, 'ether')} ETH\/month&lt;\/Text&gt;\n                &lt;Text&gt;Lease End: {new Date(leaseDetails.leaseEnd * 1000).toLocaleDateString()}&lt;\/Text&gt;\n                \n                &lt;Button mt={2} onClick={() =&gt; payRent(1)}&gt;Pay Rent (ETH)&lt;\/Button&gt;\n                &lt;Button mt={2} onClick={() =&gt; terminateLease()}&gt;Terminate Lease (Lose Deposit)&lt;\/Button&gt;\n              &lt;\/Box&gt;\n            )}\n\n            {!isLandlord &amp;&amp; !isTenant &amp;&amp; (\n              &lt;Alert status=\"info\"&gt;\n                &lt;AlertIcon \/&gt;\n                You are not the landlord or tenant for this lease.\n              &lt;\/Alert&gt;\n            )}\n          &lt;\/VStack&gt;\n        )}\n      &lt;\/Box&gt;\n    &lt;\/ChakraProvider&gt;\n  );\n}\n\nexport default App;<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>4. Contract ABI (<code>ApartmentRentalABI.json<\/code>)<\/strong><\/h2>\n\n\n\n<p>Paste the ABI from Remix\/your compiled contract:<\/p>\n\n\n\n<p>json<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[\n  {\n    \"inputs\": [\n      {\"internalType\": \"uint256\",\"name\": \"_rentAmount\",\"type\": \"uint256\"},\n      {\"internalType\": \"uint256\",\"name\": \"_securityDeposit\",\"type\": \"uint256\"},\n      {\"internalType\": \"uint256\",\"name\": \"_leaseDurationMonths\",\"type\": \"uint256\"}\n    ],\n    \"stateMutability\": \"nonpayable\",\n    \"type\": \"constructor\"\n  },\n  \/\/ ... (Include ALL ABI functions from your contract)\n]<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>5. Key Features<\/strong><\/h2>\n\n\n\n<p>\u2705&nbsp;<strong>MetaMask Wallet Integration<\/strong><br>\u2705&nbsp;<strong>Landlord &amp; Tenant Views<\/strong><br>\u2705&nbsp;<strong>ETH Payments<\/strong>&nbsp;(Easy to add USDT with&nbsp;<code>payRentERC20<\/code>)<br>\u2705&nbsp;<strong>Responsive UI with Chakra UI<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>6. How to Run<\/strong><\/h2>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">npm start<\/pre>\n\n\n\n<p>Open&nbsp;<a href=\"http:\/\/localhost:3000\/\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/localhost:3000<\/a>&nbsp;and connect MetaMask.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This frontend connects to the\u00a0ApartmentRental\u00a0smart contract, allowing landlords and tenants to interact with the lease agreement. Read this first:\u00a0Smart Contract for Apartment Rental &amp; Payments (Solidity) 1. Setup the Project bash npx create-react-app apartment-rental-dapp cd apartment-rental-dapp npm install web3 @metamask\/detect-provider @chakra-ui\/react ethers 2. Key Components 3. Full Frontend Code App.js&nbsp;(Main Component) jsx import { useState, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":898,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":""},"categories":[27],"tags":[29,19,28],"class_list":["post-897","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-solidity-programming","tag-frontend","tag-programming","tag-solidity","entry","has-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.3.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Frontend for Apartment Rental DApp (React + Web3.js) - Future Knowledge<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Frontend for Apartment Rental DApp (React + Web3.js) - Future Knowledge\" \/>\n<meta property=\"og:description\" content=\"This frontend connects to the\u00a0ApartmentRental\u00a0smart contract, allowing landlords and tenants to interact with the lease agreement. Read this first:\u00a0Smart Contract for Apartment Rental &amp; Payments (Solidity) 1. Setup the Project bash npx create-react-app apartment-rental-dapp cd apartment-rental-dapp npm install web3 @metamask\/detect-provider @chakra-ui\/react ethers 2. Key Components 3. Full Frontend Code App.js&nbsp;(Main Component) jsx import { useState, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/\" \/>\n<meta property=\"og:site_name\" content=\"Future Knowledge\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-23T02:15:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-23T02:41:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/programmer-on-mac.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1472\" \/>\n\t<meta property=\"og:image:height\" content=\"832\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/eolais.cloud\/#\/schema\/person\/33c4c6a8180d2be14d8a664a8addb9d1\"},\"headline\":\"Frontend for Apartment Rental DApp (React + Web3.js)\",\"datePublished\":\"2025-06-23T02:15:37+00:00\",\"dateModified\":\"2025-06-23T02:41:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/\"},\"wordCount\":118,\"publisher\":{\"@id\":\"https:\/\/eolais.cloud\/#organization\"},\"image\":{\"@id\":\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/programmer-on-mac.jpg\",\"keywords\":[\"FrontEnd\",\"Programming\",\"Solidity\"],\"articleSection\":[\"Solidity Programming\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/\",\"url\":\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/\",\"name\":\"Frontend for Apartment Rental DApp (React + Web3.js) - Future Knowledge\",\"isPartOf\":{\"@id\":\"https:\/\/eolais.cloud\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/programmer-on-mac.jpg\",\"datePublished\":\"2025-06-23T02:15:37+00:00\",\"dateModified\":\"2025-06-23T02:41:09+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#primaryimage\",\"url\":\"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/programmer-on-mac.jpg\",\"contentUrl\":\"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/programmer-on-mac.jpg\",\"width\":1472,\"height\":832},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/eolais.cloud\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Frontend for Apartment Rental DApp (React + Web3.js)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/eolais.cloud\/#website\",\"url\":\"https:\/\/eolais.cloud\/\",\"name\":\"Future Knowledge\",\"description\":\"Future Knowledge\",\"publisher\":{\"@id\":\"https:\/\/eolais.cloud\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/eolais.cloud\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/eolais.cloud\/#organization\",\"name\":\"Future Knowledge\",\"url\":\"https:\/\/eolais.cloud\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/eolais.cloud\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/Untitled-design.png\",\"contentUrl\":\"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/Untitled-design.png\",\"width\":1472,\"height\":832,\"caption\":\"Future Knowledge\"},\"image\":{\"@id\":\"https:\/\/eolais.cloud\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/eolais.cloud\/#\/schema\/person\/33c4c6a8180d2be14d8a664a8addb9d1\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/eolais.cloud\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/87f974e7730934d5b3fc85bd20956cdb4b3182c2ecccfa67c47e7d9345fe48a4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/87f974e7730934d5b3fc85bd20956cdb4b3182c2ecccfa67c47e7d9345fe48a4?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/eolais.cloud\"],\"url\":\"https:\/\/eolais.cloud\/index.php\/author\/admin_idjqjwfo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Frontend for Apartment Rental DApp (React + Web3.js) - Future Knowledge","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/","og_locale":"en_US","og_type":"article","og_title":"Frontend for Apartment Rental DApp (React + Web3.js) - Future Knowledge","og_description":"This frontend connects to the\u00a0ApartmentRental\u00a0smart contract, allowing landlords and tenants to interact with the lease agreement. Read this first:\u00a0Smart Contract for Apartment Rental &amp; Payments (Solidity) 1. Setup the Project bash npx create-react-app apartment-rental-dapp cd apartment-rental-dapp npm install web3 @metamask\/detect-provider @chakra-ui\/react ethers 2. Key Components 3. Full Frontend Code App.js&nbsp;(Main Component) jsx import { useState, [&hellip;]","og_url":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/","og_site_name":"Future Knowledge","article_published_time":"2025-06-23T02:15:37+00:00","article_modified_time":"2025-06-23T02:41:09+00:00","og_image":[{"width":1472,"height":832,"url":"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/programmer-on-mac.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#article","isPartOf":{"@id":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/"},"author":{"name":"admin","@id":"https:\/\/eolais.cloud\/#\/schema\/person\/33c4c6a8180d2be14d8a664a8addb9d1"},"headline":"Frontend for Apartment Rental DApp (React + Web3.js)","datePublished":"2025-06-23T02:15:37+00:00","dateModified":"2025-06-23T02:41:09+00:00","mainEntityOfPage":{"@id":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/"},"wordCount":118,"publisher":{"@id":"https:\/\/eolais.cloud\/#organization"},"image":{"@id":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#primaryimage"},"thumbnailUrl":"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/programmer-on-mac.jpg","keywords":["FrontEnd","Programming","Solidity"],"articleSection":["Solidity Programming"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/","url":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/","name":"Frontend for Apartment Rental DApp (React + Web3.js) - Future Knowledge","isPartOf":{"@id":"https:\/\/eolais.cloud\/#website"},"primaryImageOfPage":{"@id":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#primaryimage"},"image":{"@id":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#primaryimage"},"thumbnailUrl":"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/programmer-on-mac.jpg","datePublished":"2025-06-23T02:15:37+00:00","dateModified":"2025-06-23T02:41:09+00:00","breadcrumb":{"@id":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#primaryimage","url":"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/programmer-on-mac.jpg","contentUrl":"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/programmer-on-mac.jpg","width":1472,"height":832},{"@type":"BreadcrumbList","@id":"https:\/\/eolais.cloud\/index.php\/2025\/06\/23\/frontend-for-apartment-rental-dapp-react-web3-js\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/eolais.cloud\/"},{"@type":"ListItem","position":2,"name":"Frontend for Apartment Rental DApp (React + Web3.js)"}]},{"@type":"WebSite","@id":"https:\/\/eolais.cloud\/#website","url":"https:\/\/eolais.cloud\/","name":"Future Knowledge","description":"Future Knowledge","publisher":{"@id":"https:\/\/eolais.cloud\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/eolais.cloud\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/eolais.cloud\/#organization","name":"Future Knowledge","url":"https:\/\/eolais.cloud\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/eolais.cloud\/#\/schema\/logo\/image\/","url":"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/Untitled-design.png","contentUrl":"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/Untitled-design.png","width":1472,"height":832,"caption":"Future Knowledge"},"image":{"@id":"https:\/\/eolais.cloud\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/eolais.cloud\/#\/schema\/person\/33c4c6a8180d2be14d8a664a8addb9d1","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/eolais.cloud\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/87f974e7730934d5b3fc85bd20956cdb4b3182c2ecccfa67c47e7d9345fe48a4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/87f974e7730934d5b3fc85bd20956cdb4b3182c2ecccfa67c47e7d9345fe48a4?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/eolais.cloud"],"url":"https:\/\/eolais.cloud\/index.php\/author\/admin_idjqjwfo\/"}]}},"jetpack_featured_media_url":"https:\/\/eolais.cloud\/wp-content\/uploads\/2025\/06\/programmer-on-mac.jpg","_links":{"self":[{"href":"https:\/\/eolais.cloud\/index.php\/wp-json\/wp\/v2\/posts\/897","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eolais.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eolais.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eolais.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eolais.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=897"}],"version-history":[{"count":2,"href":"https:\/\/eolais.cloud\/index.php\/wp-json\/wp\/v2\/posts\/897\/revisions"}],"predecessor-version":[{"id":903,"href":"https:\/\/eolais.cloud\/index.php\/wp-json\/wp\/v2\/posts\/897\/revisions\/903"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/eolais.cloud\/index.php\/wp-json\/wp\/v2\/media\/898"}],"wp:attachment":[{"href":"https:\/\/eolais.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eolais.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eolais.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}