How durgesh2001/servicecrypto works
Project type and purpose
• This is a full-stack decentralized application (dApp) built on Ethereum.
• Purpose: collect user feedback (“memos”) on services, store them immutably on-chain, and require a small ETH payment per feedback.
File structure
• Top level:
• contracts/ (Solidity smart contracts)
• scripts/ (deployment scripts using Hardhat + Ethers.js)
• client/ (React frontend)
• hardhat.config.js, package.json (project configuration)
• client/src/components: Buy.js (payment & feedback UI) and Memos.js (display feedback)
• client/src/contract/serviceCrypto.json: compiled contract ABI & address artifacts
• scripts/deploy.js and scripts/finaldeploy.js: scripts to deploy smart contract to local or test network
• No traditional database – blockchain serves as both ledger and storage.
README for additional insights
• Uses Hardhat framework for contract compilation, testing, and deployment
• npx hardhat nod spins up a local Ethereum node
• React app calls smart contract functions via Ethers.js
a. Main components
• React Frontend (Browser)
• Ethers.js Service Layer (in React)
• Ethereum Provider / Wallet (e.g., MetaMask)
• Smart Contract (ServiceCrypto) on Ethereum (local or testnet)
• Hardhat Development Network & Deployment Scripts
• External Ethereum Network (optional: testnet or mainnet)
b. Relationships & data flow
1. User interacts with React UI → enters feedback + ETH payment
2. React’s Ethers.js library connects to Ethereum Provider (MetaMask)
3. Transaction signed and sent to Smart Contract on the blockchain
4. Smart Contract stores memo on-chain and emits events
5. React listens to events or fetches memos via read calls
6. Deployment Scripts (deploy.js/finaldeploy.js) compile & deploy contract via Hardhat → update serviceCrypto.json
c. Architectural patterns & principles
• Separation of concerns: UI vs. on-chain logic vs. deployment
• Stateless frontend; blockchain as single source of truth
• Use of event-driven updates (smart contract events → UI refresh)
d. Key technologies
• Frontend: React.js, HTML/CSS, Ethers.js
• Smart Contracts: Solidity, Hardhat
• Deployment: Node.js scripts, Hardhat plugin
• Ethereum Provider: MetaMask or Hardhat node
• Layer 1 (User & Browser): React components (Buy & Memos)
• Layer 2 (Client Service): Ethers.js / Web3 provider adapter
• Layer 3 (Wallet): MetaMask or Hardhat signer
• Layer 4 (Blockchain Network): Hardhat local node or public testnet
• Layer 5 (Smart Contract): ServiceCrypto.sol with functions buyService() & getMemos()
• Layer 6 (Deployment): scripts/deploy.js → serviceCrypto.json
Final advice
• Every interaction path (read vs. write)
• Config files (hardhat.config.js) and artifacts (serviceCrypto.json)