ETH + AVAX Proof Smart Contract Management Project

ยท

Introduction

This project demonstrates a Solidity smart contract named Assessment designed for managing Ether deposits, withdrawals, and transfers. It integrates error-handling techniques and connects to a React-based frontend for decentralized application (DApp) interactions.


Contract Overview

The Assessment contract enforces an onlyOwner modifier to restrict key operations (deposit, withdraw, transfer) to the contract owner. Key features:

Core Functions

FunctionDescription
deposit(uint256)Owner deposits Ether into the contract. Emits Deposit event.
withdraw(uint256)Owner withdraws Ether. Checks balance sufficiency. Emits Withdraw event.
transfer(address,uint256)Transfers Ether to a specified address. Emits Transfer event.
getBalance()Returns the contract's current Ether balance (read-only).

Events

๐Ÿ‘‰ Learn more about smart contract security best practices


Frontend Integration (React DApp)

The React interface enables users to:

  1. Connect MetaMask wallets.
  2. Deposit/withdraw Ether.
  3. Transfer funds via a user-friendly UI.

Key Components


Project Requirements

  1. GitHub Submission: Public repository with README.md detailing project purpose.
  2. Video Demonstration: 5-minute review of three contracts (optional for this project).
  3. Code Quality: MIT-licensed, modular Solidity code with error handling.

Usage Instructions

Local Development Setup

  1. Clone the repository and run:

    npm i
    npx hardhat node
    npx hardhat run --network localhost scripts/deploy.js
    npm run dev
  2. Access the DApp at http://localhost:3000.

MetaMask Configuration

๐Ÿ‘‰ Troubleshoot MetaMask connection issues


FAQ

How do I deposit Ether into the contract?

Call the deposit function via the DApp or directly through Etherscan, specifying the amount in Wei.

What happens if a non-owner tries to withdraw?

The onlyOwner modifier reverts the transaction with an error.

Can I test this without real ETH?

Yes! Deploy to a local Hardhat network or testnets like Goerli.


License

MIT License.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;