Estou com o mesmo problema, preciso de ajuda, o meu esta na rede FTM E DA MATIC e nao sei como resolver, não consigo fazer swap em nenhuma defi, de ambas as redes, se alguem puder me ajudar… preciso urgente… obrigado
no one ever replies, or at least says anything useful, not even in the git repo. just people pointing out the same problems over and over again and no news from metamask
function connect() {
ethereum
.request({ method: 'eth_requestAccounts' })
.then(handleAccountsChanged)
.catch((err) => {
if (err.code === 4001) {
// EIP-1193 userRejectedRequest error
// If this happens, the user rejected the connection request.
console.log('Please connect to MetaMask.');
} else {
console.error(err);
}
The Ethereum Provider API section on the MetaMask docs may help you:
Hi… Thank you, but this didn’t fix it. The problem is not that the user clicks repeatedly the button while waiting for a connection. The problem, is that if a user connected their wallet the first time, when they close the browser and then reopen it, the ethereum.seletedAddress is null, so of course the user has to click the login button again, but upon doing that, nothing happens because I get the error that a request is still pending, even if it isn’t as the user didn’t click any button during that session and the ethereum.selectedAddress is empty.