我正在开发一个 dapp,我已经使用 ether js 实现了签名选项,但我还想在单击按钮时调用一个函数来注销连接的元掩码钱包。之前我使用过 Moralis v1 注销功能,但在这个版本中没有注销选项。我该怎么做?
我正在使用 Next.js、Ether js 和 Moralis
使用 ether.js,您可以使用以下功能管理登录和注销:
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: {}
}
])}