async function connectToMetaMask() { if (!isMetaMaskInstalled()) { alert('MetaMask is not installed. Please install it to continue.'); return; } try { const accounts = await ethereum.request({ method: 'eth_requestAccounts' }); return accounts[0]; // Assuming the user selects the first account. } catch (error) { console.error('Error connecting to MetaMask:', error); } } document.getElementById('metamaskLogin').addEventListener('click', async () => { const account = await connectToMetaMask(); if (account) { authenticateUser(account); } });