Codebase is Under Update
A hierarchical deterministic (HD) wallet implementation with passkey authentication, supporting Ethereum and ERC20 tokens on the Sepolia network.
- Features
- Project Structure
- Prerequisites
- Installation
- Configuration
- Running the Project
- API Documentation
- Frontend Documentation
- BIP32 Hierarchical Deterministic Wallet implementation
- BIP39 Mnemonic code generation
- Passkey authentication for enhanced security
- Multiple account derivation
- ETH and ERC20 token support
- Sepolia testnet integration
- Modern React frontend with shadcn/ui components
hd-wallet/
├── backend/
│ ├── src/
│ │ ├── main.rs # API server implementation
│ │ ├── wallet.rs # Core wallet implementation
│ │ └── erc20_abi.json # ERC20 contract ABI
│ ├── Cargo.toml
│ └── .env
├── frontend/
│ ├── src/
│ │ ├── app/
│ │ │ └── page.tsx # Main page component
│ │ ├── components/
│ │ │ └── WalletDashboard.tsx
│ │ └── lib/
│ ├── package.json
│ └── .env.local
└── README.md
- Rust 1.70 or higher
- Node.js 18 or higher
- npm or yarn
- An Infura account for Sepolia testnet access
- Clone the repository:
git clone
cd hd-wallet- Install backend dependencies:
cd backend
cargo build- Install frontend dependencies:
cd frontend
npm install- Backend Configuration (.env):
RUST_LOG=debug
SERVER_PORT=8080
INFURA_PROJECT_ID=your_infura_project_id
INFURA_PROJECT_SECRET=your_infura_project_secret- Frontend Configuration (.env.local):
NEXT_PUBLIC_API_URL=http://localhost:8080
NEXT_PUBLIC_INFURA_PROJECT_ID=your_infura_project_id- Start the backend server:
cd backend
cargo run- Start the frontend development server:
cd frontend
npm run devThe application will be available at http://localhost:3000
Creates a new HD wallet with passkey authentication.
Request body:
{
"passkey": "string"
}Derives a new account from the HD wallet.
Sends ETH or ERC20 tokens.
Request body:
{
"from_index": 0,
"to": "0x...",
"amount": "1.0",
"token_address": "0x..." // optional, for ERC20 transfers
}Retrieves all account balances.
WalletDashboard: Main component handling wallet functionality- Tabs:
- Accounts: Displays derived accounts and balances
- Send: Interface for sending transactions
-
Wallet Creation:
- Click "Create Wallet" button
- Complete passkey registration
- Wallet is created and stored securely
-
Account Management:
- View all derived accounts
- Add new accounts
- View ETH and token balances
-
Sending Transactions:
- Select source account
- Choose token (ETH or ERC20)
- Enter recipient address
- Specify amount
- Confirm transaction
The project uses:
- Tailwind CSS for utility-first styling
- shadcn/ui for component library
- Lucide icons for iconography
-
Passkey Authentication:
- Uses WebAuthn standard
- Keys never leave the user's device
- Resistant to phishing attacks
-
Private Key Security:
- Private keys are derived on-demand
- Never stored in plaintext
- Protected by hardware security when available
-
Transaction Security:
- All transactions require explicit user confirmation
- Support for hardware wallet integration (future feature)
-
Code Style:
- Follow Rust formatting guidelines
- Use ESLint for TypeScript/React code
- Document all public functions and types
-
Testing:
- Write unit tests for all Rust functions
- Include integration tests for API endpoints
- Test frontend components with React Testing Library
-
Pull Requests:
- Include detailed description
- Add tests for new features
- Update documentation as needed
Common issues and solutions:
-
Connection Issues:
- Verify Infura API credentials
- Check network connectivity
- Ensure correct network (Sepolia) is selected
-
Transaction Failures:
- Verify sufficient balance
- Check gas price and limits
- Confirm network congestion
-
Passkey Issues:
- Ensure browser supports WebAuthn
- Check device compatibility
- Verify correct origin settings
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License.