Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PRIVATE_KEY=011d4ba8e7b549ee9cd718df4c25abed
RPC_URL_SEPOLIA=https://eth-mainnet.g.alchemy.com/v2/MBGDHRRT3_qjtqKzM2DZk
RPC_URL_FUJI=https://avax-fuji.g.alchemy.com/v2/MBGDHRRT3_qjtqKzM2DZk
ETHERSCAN_KEY=WCU9BD1WA1835GAU9VBTGSPA2DGEPQHYSF
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Remove committed secrets immediately.

Lines 1-4 contain what look like live credentials (private key, Alchemy RPC keys, Etherscan key). Committing real secrets is a critical security breach—these values must be purged from git history, rotated/invalidated with the providers, and replaced with placeholders pulled from a secure secret store (env vars, vault, CI secrets, etc.). Please revert this file from the PR and ensure regenerated keys are never checked in again.

🧰 Tools
🪛 dotenv-linter (3.3.0)

[warning] 3-3: [UnorderedKey] The RPC_URL_FUJI key should go before the RPC_URL_SEPOLIA key

(UnorderedKey)


[warning] 4-4: [EndingBlankLine] No blank line at the end of the file

(EndingBlankLine)


[warning] 4-4: [UnorderedKey] The ETHERSCAN_KEY key should go before the PRIVATE_KEY key

(UnorderedKey)

🤖 Prompt for AI Agents
In .env around lines 1 to 4 there are committed secrets (private key, Alchemy
RPC keys, Etherscan key); remove this file from the PR and replace the values
with non-sensitive placeholders, purge the secrets from git history (use git
filter-repo or BFG to remove these values from all commits), add .env to
.gitignore and ensure CI/secret manager usage is documented, immediately
rotate/invalidate the exposed keys with the providers and create new credentials
stored in a secrets store (env vars in CI, Vault, or Secrets Manager), and
verify the repo contains no remaining secrets before pushing.

6 changes: 0 additions & 6 deletions blockchain/.env.example

This file was deleted.

4 changes: 0 additions & 4 deletions client/.env.example

This file was deleted.

249 changes: 249 additions & 0 deletions client/WALLET_FEATURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
# Wallet Management Feature

## 📋 Overview

A comprehensive Wallet Management page has been implemented for the Agora-Blockchain voting platform. This feature allows users to view, manage, and interact with their connected Web3 wallets.

## ✨ Features Implemented

### 1. **Wallet Connection & Display**
- Real-time wallet connection status
- Display of connected wallet address with copy-to-clipboard functionality
- Wallet connector identification (MetaMask, WalletConnect, Coinbase Wallet, etc.)
- ENS name and avatar support

### 2. **Balance Overview**
- Native token balance display (ETH, AVAX, etc.)
- Real-time balance updates using wagmi hooks
- Network-specific balance information
- Token decimals and full balance details

### 3. **Network Management**
- Visual network selector with supported chains:
- Sepolia Testnet (Ethereum)
- Avalanche Fuji Testnet
- One-click network switching
- Clear indication of active network
- Warning for unsupported networks

### 4. **Wallet Information**
- ENS identity display with avatar
- Wallet type and address format verification
- Connection status indicators
- Security information about the connected wallet

### 5. **Voting History**
- Placeholder for voting transaction history
- Ready for integration with blockchain voting records
- Statistics summary (total votes, elections participated, networks used)
- Transaction hash links to block explorers

### 6. **Security Tips**
- Expandable security tips section
- Best practices for wallet security
- Warnings about phishing and scams
- Guidelines for safe Web3 interactions

### 7. **User Experience**
- Beautiful gradient UI with Tailwind CSS
- Smooth animations using Framer Motion
- Responsive design (mobile, tablet, desktop)
- Toast notifications for user actions
- Loading states and skeleton screens

## 🏗️ Architecture

### File Structure
```
client/app/
├── wallet/
│ └── page.tsx # Main wallet management page
└── components/
└── Wallet/
├── WalletInfo.tsx # Wallet details and ENS info
├── BalanceCard.tsx # Token balance display
├── NetworkSelector.tsx # Network switching UI
├── VotingHistory.tsx # Voting transaction history
└── SecurityTips.tsx # Security guidelines
```

### Technology Stack
- **Next.js 14** - App Router
- **wagmi** - React Hooks for Ethereum
- **RainbowKit** - Wallet connection UI
- **viem** - Ethereum library
- **Framer Motion** - Animations
- **Heroicons** - Icons
- **Tailwind CSS** - Styling
- **react-hot-toast** - Notifications

## 🎨 UI Components

### WalletInfo
Displays detailed wallet information including:
- ENS avatar and name
- Wallet type and status
- Address format verification
- Security information

### BalanceCard
Shows comprehensive balance information:
- Native token balance with 4 decimal precision
- Network-specific token symbols
- Gradient backgrounds based on network
- Full balance and decimals

### NetworkSelector
Provides network switching functionality:
- Grid layout of supported networks
- Visual indication of active network
- One-click network switching
- Warning for unsupported networks

### VotingHistory
Tracks user's voting participation:
- List of voting transactions
- Election names and timestamps
- Transaction hash links
- Statistics summary

### SecurityTips
Educational component for security:
- Expandable accordion design
- Key security guidelines
- Warning about phishing
- Platform-specific safety notes

## 🔗 Integration Points

### wagmi Hooks Used
- `useAccount()` - Current wallet account info
- `useBalance()` - Token balance
- `useEnsName()` - ENS name resolution
- `useEnsAvatar()` - ENS avatar
- `useChainId()` - Current network ID
- `useSwitchChain()` - Network switching
- `useDisconnect()` - Wallet disconnection

### RainbowKit Integration
- ConnectButton for wallet connection
- Automatic wallet provider detection
- Support for multiple wallet types

## 🚀 Usage

### Accessing the Wallet Page
1. Navigate to `/wallet` route
2. Or click "Wallet" in the navigation menu

### Wallet Connection
If not connected:
1. Click the "Connect Wallet" button
2. Select your preferred wallet provider
3. Approve the connection

If connected:
1. View wallet details, balance, and history
2. Switch networks as needed
3. Disconnect when finished

### Network Switching
1. Scroll to the "Network Selection" section
2. Click on the desired network card
3. Approve the network switch in your wallet

## 🔧 Future Enhancements

### Planned Features
1. **Voting History Integration**
- Fetch actual voting records from blockchain
- Filter by date, network, or election
- Export voting history

2. **Multi-Wallet Support**
- Connect multiple wallets simultaneously
- Set default wallet for transactions
- Switch between connected wallets

3. **Token Management**
- Display ERC-20 token balances
- Token transfer functionality
- Token approval management

4. **Transaction History**
- Complete transaction history
- Filter and search capabilities
- CSV export functionality

5. **Advanced Security**
- Wallet health checks
- Connection permissions audit
- Security score indicators

6. **Analytics Dashboard**
- Voting participation metrics
- Network usage statistics
- Gas fee analytics

## 📝 Code Examples

### Using Wallet Info in Other Components
```tsx
import { useAccount, useBalance } from 'wagmi';

function MyComponent() {
const { address, isConnected } = useAccount();
const { data: balance } = useBalance({ address });

return (
<div>
{isConnected && (
<p>Balance: {balance?.formatted} {balance?.symbol}</p>
)}
</div>
);
}
```

### Network Switching
```tsx
import { useSwitchChain } from 'wagmi';
import { sepolia } from 'wagmi/chains';

function SwitchNetwork() {
const { switchChain } = useSwitchChain();

const handleSwitch = () => {
switchChain({ chainId: sepolia.id });
};

return <button onClick={handleSwitch}>Switch to Sepolia</button>;
}
```

## 🐛 Known Issues

1. **Voting History**: Currently uses mock data - needs integration with blockchain indexer or backend API
2. **ENS Resolution**: May be slow on some networks - consider caching
3. **Balance Updates**: Real-time updates depend on RPC endpoint reliability

## 🤝 Contributing

When extending this feature:
1. Follow the existing component structure
2. Use wagmi hooks for blockchain interactions
3. Maintain responsive design patterns
4. Add loading states for async operations
5. Include error handling with user-friendly messages

## 📄 License

This feature is part of the Agora-Blockchain project and follows the same license.

## 👥 Credits

Developed as part of the GSOC contribution to Agora-Blockchain.

---

For more information, see the main project README or visit the [documentation](../README.md).
2 changes: 2 additions & 0 deletions client/app/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import {
HomeIcon,
XMarkIcon,
Bars3Icon,
WalletIcon,
} from "@heroicons/react/24/outline";
import Web3Connect from "../Helper/Web3Connect";
import Image from "next/image";

const menuItems = [
{ name: "Home", href: "/", icon: HomeIcon },
{ name: "Create", href: "/create", icon: PlusCircleIcon },
{ name: "Wallet", href: "/wallet", icon: WalletIcon },
{ name: "Profile", href: "/profile", icon: UserIcon },
];

Expand Down
Loading