是否可以使用Web3或任何其他方式获取MetAmask帐户名称?

发布于 2025-02-02 04:04:55 字数 70 浏览 1 评论 0原文

我已经尝试在MetAmask文档中搜索,但是我没有找到有关帐户信息的任何信息,所以是否有API或可以使用Web3获取帐户名称?

I've tried to search in Metamask doc, but I did not find anything about the account info, so is there any API or can I use Web3 to get the account name?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

擦肩而过的背影 2025-02-09 04:04:55

MetAmask不会在其API上共享帐户名。如果用户明确确认此操作,则只有当前选择的地址和网络。

MetaMask does not share the account name over its API. Only the currently selected address and network, if the user explicitly confirms this action.

农村范ル 2025-02-09 04:04:55

您无法将用户设置为特定钱包中的别名,但是您可以尝试获取 ens domain name ,如果它存在,正如ENS现在支持反向分辨率的那样,如文档中所述:

VIEM解决方案:

import { publicClient } from './client';

const ensName = await publicClient.getEnsName({
    address: '0x225f137127d9067788314bc7fcc1f36746a3c3b5',
});

WAGMI解决方案:

import { useEnsName } from 'wagmi';

const { data: ensName, chainId } = useEnsName({
    address: '0x225f137127d9067788314bc7fcc1f36746a3c3b5',
});

两个示例均应解析为luc.eth

You cannot get the aliases users set in specific wallets, but you can try to get the ENS domain name, if it exists, as ENS now supports reverse resolution, as explained in the docs:

Viem solution:

import { publicClient } from './client';

const ensName = await publicClient.getEnsName({
    address: '0x225f137127d9067788314bc7fcc1f36746a3c3b5',
});

Wagmi solution:

import { useEnsName } from 'wagmi';

const { data: ensName, chainId } = useEnsName({
    address: '0x225f137127d9067788314bc7fcc1f36746a3c3b5',
});

Both examples should resolve to luc.eth.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文