BaseWallet is a comprehensive decentralized wallet application built on Base Layer 2 blockchain. It combines a secure Solidity smart contract with a modern React frontend, enabling users to send, receive, and manage ETH on Base Sepolia testnet and Base mainnet. The project features a 0.5% protocol fee mechanism that supports ongoing development while maintaining transparency and security through OpenZeppelin's battle-tested libraries.
- Secure Smart Contract: Built with OpenZeppelin's Ownable and Pausable patterns
- Protocol Fee System: 0.5% (50 BPS) fee on withdrawals to support ecosystem development
- Modern UI/UX: Sleek glass-morphism design with blue gradient theme
- Multi-Wallet Support: ConnectKit integration for MetaMask, WalletConnect, and more
- Base Network: Optimized for Base Sepolia (testnet) and Base Mainnet
- Real-time Balance: Live contract balance updates with manual refresh option
- Responsive Design: Mobile-first approach with PWA capabilities
- Security First: ReentrancyGuard, emergency recovery, and pausable operations
- BaseWallet
graph TB
subgraph "Frontend Layer"
A[React App] --> B[Wagmi/Viem]
B --> C[ConnectKit]
A --> D[UI Components]
D --> E[shadcn/ui]
end
subgraph "Blockchain Layer"
F[Base Sepolia/Mainnet]
G[SimpleBaseWallet Contract]
H[Treasury Address]
end
subgraph "User Interaction"
I[User Wallet]
I --> |Connect| C
C --> |Web3 Provider| B
B --> |RPC Calls| F
end
G --> |Deployed on| F
B --> |Read/Write| G
G --> |0.5% Fee| H
style A fill:#61dafb
style G fill:#627eea
style F fill:#0052FF
sequenceDiagram
participant U as User
participant F as Frontend
participant W as Wallet Provider
participant B as Base Network
participant C as SimpleBaseWallet
Note over U,C: Connection Flow
U->>F: Opens BaseWallet App
F->>W: Request Wallet Connection
W->>U: Approve Connection
W-->>F: Connected (Address)
F->>B: Fetch Contract Balance
B-->>F: Return Balance
F->>U: Display Dashboard
Note over U,C: Deposit Flow
U->>W: Send ETH to Contract
W->>C: Transfer ETH
C->>C: Emit Deposited Event
C-->>U: Transaction Confirmed
U->>F: Refresh Balance
F->>B: Query Balance
B-->>F: Updated Balance
Note over U,C: Withdrawal Flow
U->>F: Enter Recipient & Amount
F->>W: Request Transaction
W->>U: Confirm Transaction
U->>W: Approve
W->>C: Call sendEth(to, amount)
C->>C: Calculate Fee (0.5%)
C->>C: Send Amount to Recipient
C->>C: Send Fee to Treasury
C->>C: Emit Withdrawn Event
C-->>U: Transaction Success
F->>B: Refresh Balance
B-->>F: New Balance
graph LR
subgraph "SimpleBaseWallet Contract"
A[receive ETH] --> B{Balance Updated}
B --> C[Emit Deposited]
D[sendEth] --> E{Check Balance}
E --> |Sufficient| F[Calculate 0.5% Fee]
E --> |Insufficient| G[Revert]
F --> H[Transfer to Recipient]
H --> I[Transfer Fee to Treasury]
I --> J[Emit Withdrawn]
K[pause/unpause] --> L{Owner Only}
M[emergencyRecover] --> L
L --> |Authorized| N[Execute]
L --> |Unauthorized| O[Revert]
P[getBalance] --> Q[Return Contract Balance]
end
subgraph "Security Features"
R[ReentrancyGuard]
S[Ownable]
T[Pausable]
end
D -.-> R
K -.-> S
D -.-> T
style A fill:#90EE90
style D fill:#FFD700
style K fill:#FF6347
style P fill:#87CEEB
basedWallet/
├── solidityContract/ # 👉 Smart Contract Directory
│ ├── src/
│ │ └── SimpleBaseWallet.sol
│ ├── script/
│ │ └── DeploySimpleWallet.s.sol
│ ├── test/
│ │ └── SimpleBaseWallet.t.sol
│ ├── lib/
│ │ ├── forge-std/
│ │ └── openzeppelin-contracts/
│ ├── foundry.toml
│ ├── deploy-testnet.sh
│ └── deploy-mainnet.sh
├── src/ # Frontend Source
│ ├── components/
│ │ ├── ui/ # shadcn/ui components
│ │ └── WalletDashboard.tsx
│ ├── config/
│ │ └── wagmi.ts # Wagmi + ConnectKit config
│ ├── hooks/
│ ├── App.tsx
│ ├── main.tsx
│ └── index.css
├── assets/
│ └── wallet.png
├── public/
├── contract.ps1 # Contract deployment script
├── package.json
├── vite.config.ts
├── tsconfig.json
├── tailwind.config.ts
├── .gitignore
└── README.md
📌 Smart Contract Details: Navigate to
solidityContract/for comprehensive contract documentation, deployment guides, and testing instructions.
Before you begin, ensure you have the following installed:
- Node.js >= 18.x (Download)
- pnpm >= 8.x (or npm/yarn)
npm install -g pnpm
- Foundry (for smart contract development)
curl -L https://foundry.paradigm.xyz | bash foundryup - Git
- MetaMask or compatible Web3 wallet
git clone <your-repo-url>
cd basedWalletNavigate to the smart contract directory:
cd solidityContractInstall dependencies:
forge installBuild contracts:
forge buildRun tests:
forge test
forge test -vvv # Verbose outputReturn to root directory:
cd ..Install frontend dependencies:
pnpm installpnpm devThe app will be available at http://localhost:8080
pnpm buildpnpm previewpnpm lintcd solidityContract
./deploy-testnet.shOr manually:
forge script script/DeploySimpleWallet.s.sol:DeploySimpleWallet \
--rpc-url https://sepolia.base.org \
--broadcast \
--verify./deploy-mainnet.shOr manually:
forge script script/DeploySimpleWallet.s.sol:DeploySimpleWallet \
--rpc-url https://mainnet.base.org \
--broadcast \
--verify
⚠️ Important: Update the contract address insrc/config/wagmi.tsafter deployment.
The frontend can be deployed to any static hosting service:
Vercel:
vercelNetlify:
netlify deploy --prodBuild and deploy manually:
pnpm build
# Upload the 'dist' folder to your hosting service- Base Sepolia:
0xB0246478c73aAf9B4d730d1C6B6C2767C2D1Be5a - Base Mainnet: TBD
| Function | Description | Access |
|---|---|---|
receive() |
Accept ETH deposits | Public |
sendEth(to, amount) |
Send ETH with 0.5% fee | Owner |
getBalance() |
Get contract balance | Public |
pause() |
Pause contract operations | Owner |
unpause() |
Resume contract operations | Owner |
emergencyRecover(to) |
Emergency fund recovery | Owner |
Deposited(address from, uint256 amount)Withdrawn(address owner, address to, uint256 amountSent, uint256 fee)EmergencyRecovered(address to, uint256 amount)
- ✅ OpenZeppelin Ownable: Owner-only administrative functions
- ✅ ReentrancyGuard: Protection against reentrancy attacks
- ✅ Pausable: Emergency pause mechanism
- ✅ Event Logging: Complete transaction transparency
- ✅ Protocol Fee: Sustainable 0.5% withdrawal fee
| Technology | Version | Purpose |
|---|---|---|
| React | 19.2.3 | UI Framework |
| TypeScript | 5.8.3 | Type Safety |
| Vite | 5.4.19 | Build Tool |
| Wagmi | 3.1.3 | Ethereum React Hooks |
| Viem | 2.43.3 | Ethereum Utilities |
| ConnectKit | 1.9.1 | Wallet Connection UI |
| TanStack Query | 5.83.0 | Data Fetching |
| Tailwind CSS | 3.4.17 | Styling |
| shadcn/ui | Latest | UI Components |
| Radix UI | Latest | Headless UI Primitives |
Create a .env file in the solidityContract/ directory:
# RPC URLs
BASE_SEPOLIA_RPC=https://sepolia.base.org
BASE_MAINNET_RPC=https://mainnet.base.org
# Private Key (NEVER commit this!)
PRIVATE_KEY=your_private_key_here
# Block Explorer API Keys
BASESCAN_API_KEY=your_basescan_api_key
# Treasury Address
TREASURY_ADDRESS=0x...
⚠️ Security Warning: Never commit.envfiles or expose private keys!
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow the existing code style
- Write tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PR
- Use conventional commit messages
Found a bug? Have a suggestion? Please open an issue with:
- Clear description
- Steps to reproduce (for bugs)
- Expected vs actual behavior
- Screenshots (if applicable)
This project is licensed under the MIT License - see the LICENSE file for details.
- Base - Layer 2 blockchain platform
- OpenZeppelin - Secure smart contract libraries
- Foundry - Ethereum development toolchain
- Wagmi - React hooks for Ethereum
- ConnectKit - Beautiful wallet connection UI
- shadcn/ui - Beautifully designed components
- Documentation: Base Docs
- Foundry Book: Foundry Documentation
- Wagmi Docs: Wagmi Documentation
- Base Block Explorer: BaseScan
Built on Base Layer 2
Every transaction → 0.5% fee supports the builder
