'Permission to only read Wallet Address

I just want to collect the user's Wallet Address. I think these permission are too much. I don't need to see balance or initiate transactions. Just read-wallet-address.

What is the easiest and clean way to get the wallet address? This is the code I am using:

const provider = new ethers.providers.Web3Provider(window.ethereum)
await provider.send("eth_requestAccounts", []);
signer = provider.getSigner()
const walletAddress = await signer.getAddress()

See wallet balance, activity and initiate transactions



Solution 1:[1]

This is currently the only option. There's no "read address but cannot request transactions" permission type. Your code is correct.

Docs: https://docs.metamask.io/guide/rpc-api.html#eth-requestaccounts

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Petr Hejda