A production-grade Flutter mobile dApp for DeFi staking, built with Clean Architecture, BLoC, WalletConnect, and web3dart.
- Clean Architecture (
presentation,domain,data) with inward dependencies. - Wallet connection flow via WalletConnect (MetaMask and Trust Wallet deep links).
- ERC-20 token balance + pending rewards retrieval from EVM network.
- Staking, unstaking, and claiming rewards with contract function calls.
- Transaction status handling (
pending,success,failed) and explorer links. - Dark fintech UI, loading skeletons, localized strings, and robust error handling.
- Flutter (null-safe)
flutter_blocfor state managementdiofor networking / RPC health verificationweb3dartfor contract reads and ABI encodingwalletconnect_flutter_v2for wallet session + signing requestsget_itfor dependency injection
lib/
core/
constants/
di/
error/
logging/
network/
services/
data/
datasources/
models/
repositories/
domain/
entities/
repositories/
usecases/
presentation/
bloc/
pages/
widgets/
l10n/
- User taps Connect Wallet.
- App creates WalletConnect session and opens available wallet app.
- Session returns selected account (
eip155namespace). - Read-only calls fetch token balance and pending rewards.
- Write calls (
stake,unstake,claimRewards) are ABI-encoded and sent via wallet. - UI displays transaction hash and links to explorer.
Update runtime constants in:
lib/core/constants/app_constants.dart
Required values:
wcProjectIdchainId,rpcUrl,explorerBaseUrlstakingContractAddresstokenContractAddresstokenDecimals
Default network is Sepolia. Replace with your target chain parameters for production.
Mock staking ABI is located at:
assets/abi/mock_staking_abi.json
Functions currently used:
pendingRewards(address user)stake(uint256 amount)unstake(uint256 amount)claimRewards()
- Flutter SDK
>=3.4.0 - Android Studio / Xcode toolchain
- A real wallet app for testing WalletConnect on device
flutter pub getflutter run- Mutation calls are guarded to prevent overlapping transactions.
- Repository layer maps exceptions into domain
Failureobjects. - Stale refresh responses are ignored in BLoC using request id tracking.
- Logging is centralized in
AppLogger.
- If wallet does not open, install MetaMask or Trust Wallet on the test device.
- On Android emulator, WalletConnect deep linking may fail if no supported wallet exists.
- Ensure your RPC endpoint is reachable and chain id matches wallet network.
This project is licensed under the MIT License. See LICENSE for details.