0

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)
TylerH
  • 20,799
  • 66
  • 75
  • 101
Tye Beach
  • 21
  • 3

2 Answers2

0

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.

Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
  • Hello Mikko, Can you please say what do you mean by "extract the address" ? is the public address or private key you are taking?. If you meant public address can i sign transaction with the public address in backend? – Md. Nahiduzzaman Rose Jun 24 '21 at 06:08
  • You can only know the address the user is using. You can not o anything with that address, because that's the whole point of a blockchain. – Mikko Ohtamaa Jun 24 '21 at 07:55
  • Or.... blockchain eliminates the ability of middlemen to do actions on behalf of them without their explicit permission. – Mikko Ohtamaa Jun 24 '21 at 08:13
-1

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