【发布时间】:2021-07-13 02:06:09
【问题描述】:
我有这个在 js 中工作,给我登录 Metamask 用户的地址,但我想使用 Nethereum 来做。有人可以告诉我与 Nethereum 的等价物吗?
var accounts = await web3.eth.getAccounts();
console.log(accounts)
【问题讨论】:
标签: blockchain ethereum web3 nethereum
我有这个在 js 中工作,给我登录 Metamask 用户的地址,但我想使用 Nethereum 来做。有人可以告诉我与 Nethereum 的等价物吗?
var accounts = await web3.eth.getAccounts();
console.log(accounts)
【问题讨论】:
标签: blockchain ethereum web3 nethereum
这是不可能的,因为 MetaMask 只能在 Web 前端 (JavaScript/TypeScript) 中访问,而 .NET 不能在 Web 浏览器中运行。
为了在服务器端安全地获取用户地址,您需要要求用户使用 MetaMask 对消息进行签名,然后从消息签名中提取地址。
【讨论】:
对于 Nethereum,目前我们没有任何直接支持它可以访问 Metamask,因此在 netherium 中您只能使用私钥或助记词访问帐户
像下面这样
var account = new Account(privateKey);
var publicAddressOfTheAboveAccount = account.Address;
如果您想通过 Nethereum.Metamask.Blazor 使用元掩码访问元掩码帐户实例,请查看以下链接
【讨论】: