async function onInit() { await window.ethereum.enable(); const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' }); const account = accounts[0]; console.log(account) window.ethereum.on('accountsChanged', function (accounts) { // Time to reload your interface with accounts[0]! console.log(accounts[0]) }); }
onInit();
const getBalance=async ()=>{ const address=await onInit(); const balance=await web3.eth.getBalance(address); console.log(balance); } getBalance(); This shows the error; Error: Provided address [object Promise] is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.