Skip to content

riteshkrkarn/simpleTransferDapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Simple Transfer Dapp ๐Ÿš€

Simple Transfer Dapp is a decentralized Ethereum application that demonstrates fundamental Web3 interactions. This DApp allows users to connect their MetaMask wallet and perform essential blockchain operations including deposits, transfers, balance checks, and withdrawals through a smart contract deployed on the Ethereum blockchain.

Built as a learning project to understand Web3 development fundamentals using modern technologies like React.js, Solidity, Hardhat, Tailwind CSS, and Ethers.js.

โš ๏ธ Learning Project Notice: This is my first Web3 application created for educational purposes and portfolio demonstration. While fully functional, there might be areas for optimization and improvement. Feedback and suggestions are welcome!


๐ŸŽฏ What This DApp Does

SimpleTransferDapp provides a user-friendly interface for interacting with the Ethereum blockchain through a custom smart contract. Users can:

  • Connect Wallet: Seamlessly connect MetaMask to interact with the DApp
  • View Balances: Check ETH balance of any valid Ethereum address
  • Deposit Funds: Add ETH to your account balance within the smart contract
  • Transfer ETH: Send ETH directly to other Ethereum addresses
  • Withdraw Funds: Retrieve your deposited ETH back to your wallet

๐Ÿ—๏ธ Architecture & Smart Contract

Smart Contract: SimpleTransfer.sol

The core smart contract provides four main functions:

// Deposit ETH into the contract
function deposit() external payable

// Transfer ETH to another address
function transfer(address payable recipient) public payable

// Withdraw ETH from your contract balance
function withdraw(uint amount) external

// Check balance of any address
function getBalance(address account) external view returns (uint256)

Key Features:

  • Maintains internal balance mapping for each user
  • Emits events for deposit and transfer operations
  • Implements safety checks and error handling
  • Uses call() for secure ETH transfers

๐Ÿ›  Tech Stack

Component Technology
Frontend Framework React.js with Vite
Styling Tailwind CSS
Smart Contracts Solidity ^0.8.0
Development Framework Hardhat
Blockchain Interaction Ethers.js
Wallet Integration MetaMask
Testing Network Hardhat Local Network

๐Ÿ“ธ Application Interface

SimpleTransferDapp Interface

Beautiful dark-themed UI with gradient background and glassmorphism effects

๐ŸŽจ UI Features Showcase

The application features a stunning modern interface with:

  • ๐ŸŒŒ Cosmic Background: Dynamic gradient with animated particle effects
  • ๐Ÿ’Ž Glassmorphism Design: Semi-transparent cards with backdrop blur effects
  • ๐Ÿ“ฑ Responsive Layout: Clean, centered design that works on all devices
  • ๐Ÿ”— Wallet Integration: Real-time display of connected account and balance
  • โšก Interactive Elements: Smooth hover effects and modern button styling

๐Ÿ–ฅ๏ธ Interface Components

  • Connected Account Display:

    • Shows truncated wallet address: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
    • Real-time ETH balance: 0 ETH
  • Deposit Section:

    • Clean input field with placeholder: "Deposit Amount"
    • Rounded button with hover effects: "Deposit"
  • Transfer Section:

    • Recipient address input: "Recipient Address"
    • Transfer amount input: "Transfer Amount"
    • Action button: "Transfer"
  • Withdraw Section:

    • Amount input field: "Withdraw Amount"
    • Withdrawal button: "Withdraw"
  • Design Elements:

    • Color Scheme: Deep purples and blues with cyan accents
    • Typography: Clean, modern font with excellent readability
    • Visual Effects: 3D wireframe mountains and floating particles
    • Card Design: Translucent panels with subtle borders and shadows

๐Ÿ“ Project Structure

simpleTransferDapp/
โ”œโ”€โ”€ ๐Ÿ“ contracts/
โ”‚   โ””โ”€โ”€ simpleTransfer.sol          # Smart contract
โ”œโ”€โ”€ ๐Ÿ“ ignition/
โ”‚   โ””โ”€โ”€ modules/                    # Deployment scripts
โ”œโ”€โ”€ ๐Ÿ“ src/                         # Frontend React application
โ”œโ”€โ”€ ๐Ÿ“ test/                        # Smart contract tests
โ”œโ”€โ”€ ๐Ÿ“ public/                      # Static assets
โ”œโ”€โ”€ ๐Ÿ“ artifacts/                   # Compiled contracts
โ”œโ”€โ”€ ๐Ÿ“ cache/                       # Hardhat cache
โ”œโ”€โ”€ ๐Ÿ“ node_modules/                # Dependencies
โ”œโ”€โ”€ .env                            # Environment variables
โ”œโ”€โ”€ hardhat.config.js               # Hardhat configuration
โ”œโ”€โ”€ package.json                    # Project dependencies
โ”œโ”€โ”€ vite.config.js                  # Vite configuration
โ””โ”€โ”€ README.md                       # This file

๐ŸŽฎ User Workflow

  1. Launch Application: Open the DApp in your browser
  2. Connect Wallet: Click connect to link your MetaMask wallet
  3. View Balance: See your current ETH balance displayed
  4. Deposit ETH: Enter amount and deposit funds into the contract
  5. Transfer ETH: Send ETH to any valid Ethereum address
  6. Check Balances: Query balance of any Ethereum address
  7. Withdraw Funds: Retrieve your deposited ETH back to your wallet

โš™๏ธ Installation & Setup

Prerequisites

Make sure the following are installed on your system:

  • Node.js (v18 or higher recommended)
  • npm or yarn
  • MetaMask browser extension
  • Infura account and project for RPC access (optional)

1. Clone the Repository

git clone https://github.com/riteshkrkarn/simpleTransferDapp.git
cd simpleTransferDapp

2. Install Dependencies

npm install
# or
yarn install

3. Environment Configuration

Create a .env file in the root directory:

VITE_INFURA_API_KEY=your_infura_api_key_here

Note: The Infura API key is optional since this project primarily runs on Hardhat local network.

4. Compile Smart Contracts

npx hardhat compile

5. Deploy Smart Contracts

Deploy to Local Hardhat Network

Start the local Hardhat network:

npx hardhat node

In a separate terminal, deploy the contract:

npx hardhat ignition deploy ./ignition/modules/simpleTransfer.js --network localhost

๐Ÿ“Œ Important: After deployment, note the contract address. You'll need to update your frontend configuration with this address.

You can find your deployment details in the ignition/deployments/ directory.

6. Start the Frontend

npm run dev
# or
yarn dev

The application will be available at http://localhost:5173


๐Ÿ”ง MetaMask Configuration

Adding Hardhat Local Network

  1. Open MetaMask
  2. Click on the network dropdown
  3. Select "Add Network" โ†’ "Add a network manually"
  4. Enter the following details:

Import Test Accounts

Hardhat provides test accounts with pre-funded ETH. Import any of the private keys shown when you run npx hardhat node into MetaMask for testing.


๐Ÿงช Testing

Run the smart contract tests:

npx hardhat test

๐Ÿš€ Smart Contract Functions

deposit()

  • Purpose: Deposit ETH into your contract balance
  • Parameters: None (ETH sent with transaction)
  • Events: Emits Deposit(address to, uint256 amount)

transfer(address payable recipient)

  • Purpose: Transfer ETH to another address
  • Parameters: recipient - Target Ethereum address
  • Requirements: Amount > 0, valid recipient address
  • Events: Emits Transfer(address from, address to, uint256 amount)

withdraw(uint amount)

  • Purpose: Withdraw ETH from your contract balance
  • Parameters: amount - Amount to withdraw in wei
  • Requirements: Sufficient balance
  • Security: Uses call() for safe ETH transfers

getBalance(address account)

  • Purpose: Check balance of any Ethereum address
  • Parameters: account - Address to check
  • Returns: Balance in wei
  • View Function: Read-only, no gas cost

๐Ÿ’ก Learning Outcomes

This project demonstrates:

  • Smart Contract Development: Writing secure Solidity contracts
  • Frontend Integration: Connecting React with Web3
  • Wallet Integration: MetaMask connection and interaction
  • Event Handling: Listening to contract events
  • Error Handling: Proper error management in DApps
  • Modern UI/UX: Responsive design with Tailwind CSS

๐Ÿ”ฎ Future Enhancements

Potential improvements for this learning project:

  • Add transaction history and receipts
  • Implement gas fee estimation
  • Add support for ERC-20 tokens
  • Deploy to testnets (Sepolia, Goerli)
  • Add comprehensive unit tests
  • Implement loading states and better UX
  • Add transaction confirmation modals

๐Ÿ™‹โ€โ™‚๏ธ Author

Ritesh Kumar Karn


๐Ÿ“ License

This project is licensed under the MIT License.
Feel free to use, modify, and distribute with attribution.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •