-1

I am working on a dapp and I have implemented signing option using ether js but I want to also call a fucntion onclick a button to logout connected metamask wallet. Before I have used Moralis v1 logout fucntion but in this version there is no option to logout. How can i do this?

I am using Next.js, Ether js, and Moralis

1 Answer 1

1

Using ether.js you can manage login and logout using these functions:

async function login() { const ethers = require('ethers'); const provider = new ethers.providers.Web3Provider(window.ethereum); const signer = provider.getSigner(); const walletAddress = await signer.getAddress(); //get user address } async function logout() { const ethers = require('ethers'); const provider = new ethers.providers.Web3Provider(window.ethereum); const signer = provider.getSigner(); await signer.provider.send('wallet_requestPermissions', [ { eth_accounts: {} } ])} 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.