简体   繁体   中英

How do I do the equivalent of web3.eth.getAccounts() for Nethereum?

I have this working in js to give me the address of the logged-in Metamask user, but I would like to do it using Nethereum. Could someone tell me the equivalent to this with Nethereum?

var accounts = await web3.eth.getAccounts(); console.log(accounts)

for Nethereum right now we dont have any direct support that it can access Metamask, so in netherium you can only access account using private key or seed phrase

Like this below

 var account = new Account(privateKey);
 var publicAddressOfTheAboveAccount = account.Address;

Check the below link if you want to use metamask using Nethereum.Metamask.Blazor to access metamask account instance

checkthislink

This is impossible, because MetaMask is accessible only in the web frontend (JavaScript/TypeScript) and .NET does not run within a web browser.

To get the user address on the server side securely, you need to ask user to sign a message with MetaMask and then extract the address from the message signature.

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