如何在metamask中自动切换帐户

问题描述

大家好,我有一个在线投票应用程序,该应用程序基于智能合约、ganache 和 web3.js 构建。在这个应用程序中,每个选举人都有一个来自 ganache 的地址。 I want when the elector goes to Vote he will give his privatekey and Metamask take this private key automatically without going to click on Metamask and import the address I need this automatically.

解决方法

设计上不可能。

Metamask JS API(实现以太坊提供商 API)不允许以编程方式导入帐户(或只读地址)。

有关详细信息,请参阅 https://docs.metamask.io/guide/#account-management