This repository contains a decentralized application (DApp) built with React that interacts with a smart contract deployed on the Ethereum blockchain. The project demonstrates how to integrate a frontend React application with a smart contract using Web3.js or Ethers.js.
- Smart Contract Deployment: Solidity smart contract for basic functionalities.
- React Integration: Connect and interact with the smart contract using a React frontend.
- Web3/Ethers Integration: Utilize Web3.js or Ethers.js for blockchain interactions.
- Metamask Authentication: Allow users to connect and authenticate with their Metamask wallet.
- State Management: Efficient state management using React hooks and context.
- User Interface: Clean and responsive UI for interacting with the smart contract.
- Transaction Handling: Display and handle blockchain transactions and events.
- Solidity: For writing the smart contract.
- React: For building the user interface.
- Web3.js/Ethers.js: For blockchain interaction.
- Metamask: For user authentication.
- Bootstrap/Material-UI: For styling the application.
To get a local copy up and running, follow these simple steps.
- Node.js and npm installed
- Truffle or Hardhat for smart contract development
- Ganache for local Ethereum blockchain (optional)
- Metamask browser extension
git clone repo-url
npm install
Download Ganache Ethereum app: https://archive.trufflesuite.com/ganache/ Download MetaMask: https://metamask.io/download/
- After installation and opening the GUI choose "New Workspace" button.
- Write your workspace name and press "Add project".
- Navigate to the dapp folder and choose truffle-config file.
- Press "start" button to add the truffle project to the Ganache.
Network name: Ganache New RPC URL: HTTP://127.0.0.1:7545 ChainID: 1337 Currency symbol: ETH
-
Press save and switch to ganache
-
Add account and import ganache private key to your wallet to get fake ETH.
Using Truffle:
npx truffle compile
npx truffle migrate
npm start
- Open your browser and navigate to http://localhost:3000.
- Connect your Metamask wallet.
- Interact with the deployed smart contract using the provided UI.
- contracts/: Solidity smart contract files.
- src/: React application source files.
- pages/: React pages.
- services/: React services.
- layout/: Layout of project.
- middleware/: middleware of project.
- App.js: Main React component.
- index.js: Entry point for the React app.