Skip to content

Conversation

@alokdangre
Copy link
Collaborator

πŸ”Œ Add "Connect Wallet" Functionality Using MetaMask

βœ… Summary

This PR introduces a "Connect Wallet" button to the home screen, allowing users to connect their MetaMask wallet and display their wallet address.


πŸ›  Changes Made

  • Imported ethers and BrowserProvider from ethers.js.
  • Implemented connectWallet function which:
    • Checks for the presence of window.ethereum.
    • Requests wallet access using eth_requestAccounts.
    • Retrieves the user's wallet address using getSigner().
    • Stores the connected address in a React state variable (walletAddress).
  • Added a Connect Wallet button inside the IonToolbar:
    • Displays "Connect Wallet" if not connected.
    • Displays a shortened wallet address (e.g., Connected: 0x123...abcd) once connected.
    • Alerts user if MetaMask is not installed or if the connection fails.

πŸ‘¨β€πŸ’» Code Location

  • Home.tsx: Main logic for connecting wallet and rendering the button.

πŸ’‘ Notes

  • Only MetaMask is supported via window.ethereum.
  • Wallet connection state is not persisted across page reloads (can be enhanced in future).
  • This prepares the foundation for future Web3 or blockchain integrations.

πŸ“· Screenshot Preview (Optional)

Screenshot 2025-06-24 120249

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant