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!
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
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
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 |
Beautiful dark-themed UI with gradient background and glassmorphism effects
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
-
Connected Account Display:
- Shows truncated wallet address:
0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
- Real-time ETH balance:
0 ETH
- Shows truncated wallet address:
-
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
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
- Launch Application: Open the DApp in your browser
- Connect Wallet: Click connect to link your MetaMask wallet
- View Balance: See your current ETH balance displayed
- Deposit ETH: Enter amount and deposit funds into the contract
- Transfer ETH: Send ETH to any valid Ethereum address
- Check Balances: Query balance of any Ethereum address
- Withdraw Funds: Retrieve your deposited ETH back to your wallet
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)
git clone https://github.com/riteshkrkarn/simpleTransferDapp.git
cd simpleTransferDapp
npm install
# or
yarn install
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.
npx hardhat compile
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.
npm run dev
# or
yarn dev
The application will be available at http://localhost:5173
- Open MetaMask
- Click on the network dropdown
- Select "Add Network" โ "Add a network manually"
- Enter the following details:
- Network Name: Hardhat Local
- New RPC URL: http://127.0.0.1:8545
- Chain ID: 31337
- Currency Symbol: ETH
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.
Run the smart contract tests:
npx hardhat test
- Purpose: Deposit ETH into your contract balance
- Parameters: None (ETH sent with transaction)
- Events: Emits
Deposit(address to, uint256 amount)
- 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)
- Purpose: Withdraw ETH from your contract balance
- Parameters:
amount
- Amount to withdraw in wei - Requirements: Sufficient balance
- Security: Uses
call()
for safe ETH transfers
- Purpose: Check balance of any Ethereum address
- Parameters:
account
- Address to check - Returns: Balance in wei
- View Function: Read-only, no gas cost
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
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
Ritesh Kumar Karn
- GitHub: @riteshkrkarn
- Email: [email protected]
This project is licensed under the MIT License.
Feel free to use, modify, and distribute with attribution.