I use svelte to create Web3 app and got some error
1.I already added web3.js cdn on my index.html
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
2.this is my script on .svelte file to connect the Metamask Wallet
function connectWallet(){
if(window.ethereum){
window.web3 = new Web3(ethereum);
window.ethereum.enable();
metamaskConnected = window.ethereum.isConnected();
web3.eth.getAccounts(function(error, accounts) {
WalletAddress = accounts
console.log(error)
})
}
}
And when i open my website on the broser (Brave) for the first time i got this error
Unchecked runtime.lastError: Could not establish connection
and the script not working
Could you give me some suggestion, Thank you very much
I got the exact same issue on my dapp, I've to investigate more but it looks like it happpen on any Chromium browser and ONLY IF clicking the dapp url open the browser in the same time.
Pretty weird bug, probably a problem between the communication of Metamask and Chromium browsers