5
votes

I am using MetaMask for sending transactions to contract in my DApp. I need help in How to Disconnect MetaMask account from my DApp when the user clicks on logout button.

Front-end: ReactJS

Back-end: Web3js, Solidity (Ethereum)

4

4 Answers

0
votes

The user can disconnect MetaMask account using the account disconnect button within the MetaMask itself. Also any page refresh or reload automatically disconnects MetaMask.

0
votes

I don't know if you still have the issue, but inside of an async function you can call clearCachedProvider. The web3Modal variable is cast to my instansiation of web3, e.g. const web3Modal = new Web3Modal...:

await web3Modal.clearCachedProvider()
-1
votes

as per documentation we can use onboard.walletReset() and it returns undefined and its doesn't disconnect from wallet.from frontend we needs to make the state emp The below is the clear understanding lins from documentations // user wants to log out of session and the wallet state needs to be reset... onboard.walletReset() // this method is synchronous and returns undefined

-1
votes

as attached on EIP-1193, web3.js currently still working for connections and events only, such as disconnect events, network changes and wallet account changes only.