简体   繁体   中英

Get user's wallet address in web3.js

I need to call an API that requires the user's wallet address. However, I can only get wallet's accounts by web3.eth.getAccounts() but not the wallet address.

I am using WalletConnect and was able to create web3 instance.

Thanks!

You need to use requestAccounts and ask the permission from the user to access their wallet addresses.

Due to privacy reasons, the website cannot do this by default.

Also, you need to set up your Web3 properly with the wallet in the order it to work. Because your question did not contain any example code or repeatable example, it is not possible to tell if you are doing it properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM