A Flutter web application that integrates with MetaMask for sending Ethereum transactions. Users can connect their MetaMask wallet, send transactions, and receive transaction hashes.
- π¦ MetaMask Integration: Seamless connection with MetaMask browser extension
- π° Wallet Connection: Connect and display wallet address with copy functionality
- π€ Send Transactions: Send ETH with optional data field
- π Transaction Tracking: Receive and display transaction hashes
- π± Responsive Design: Clean Material Design interface
- β‘ Real-time Updates: Listen for account and network changes
- Flutter SDK (3.22.2 or later)
- MetaMask browser extension
- Web browser with JavaScript enabled
-
Clone or download the project
cd wallet_app -
Install dependencies
flutter pub get
-
Run the application
flutter run -d web-server --web-port 8080 --web-hostname 0.0.0.0
-
Open in browser Navigate to
http://localhost:8080
- Ensure MetaMask extension is installed and unlocked
- Click "Connect MetaMask" button
- Approve the connection in MetaMask popup
- Your wallet address will be displayed
- Fill in the recipient address (0x...)
- Enter the amount in ETH (e.g., 0.001)
- Optionally add transaction data
- Click "Send Transaction"
- Confirm the transaction in MetaMask
- Transaction hash will be displayed upon success
User clicks "Send" β MetaMask opens β User confirms tx β Tx hash received
wallet_app/
βββ lib/
β βββ main.dart # Main application UI
β βββ services/
β βββ metamask_service.dart # MetaMask integration service
βββ web/
β βββ index.html # Web entry point
βββ pubspec.yaml # Dependencies
βββ README.md # This file
βββ TESTING_RESULTS.md # Testing documentation
web3dart: ^2.7.3- Ethereum blockchain interactionjs: ^0.6.7- JavaScript interop for MetaMaskhttp: ^1.1.0- HTTP clienturl_launcher: ^6.1.14- URL handling
isMetaMaskAvailable- Check if MetaMask is installedconnectWallet()- Connect to MetaMask walletgetCurrentAccount()- Get current connected accountsendTransaction()- Send Ethereum transactiongetChainId()- Get current network chain IDonAccountsChanged()- Listen for account changesonChainChanged()- Listen for network changes
// Check MetaMask availability
if (MetaMaskService.isMetaMaskAvailable) {
// Connect wallet
String? account = await MetaMaskService.connectWallet();
// Send transaction
String txHash = await MetaMaskService.sendTransaction(
to: '0x742d35Cc6634C0532925a3b8D4C9db96590b5',
value: '0x16345785D8A0000', // 0.1 ETH in Wei
);
}The app handles various error scenarios:
- MetaMask not installed
- User rejection of connection/transaction
- Network errors
- Invalid transaction parameters
- Never store private keys in the application
- All transactions are signed by MetaMask
- Validate all user inputs
- Use testnet for development and testing
See TESTING_RESULTS.md for detailed testing information.
- Install MetaMask extension
- Connect to test network (Sepolia recommended)
- Get test ETH from faucet
- Test wallet connection
- Test transaction sending
- Verify transaction hash reception
- Ensure MetaMask extension is installed
- Refresh the page
- Check browser console for errors
- Check account balance
- Verify recipient address format
- Ensure correct network is selected
- Check gas fees
- Unlock MetaMask wallet
- Check network connectivity
- Clear browser cache
flutter build webflutter test- Chrome (recommended)
- Firefox
- Safari
- Edge
This project is for educational and development purposes.
For issues and questions, please check the troubleshooting section or review the testing documentation.