简体   繁体   中英

How to login ethereum account by privateKey via web3?

我创建了一个简单的以太坊网络并通过 web3js 连接,但我没有找到任何功能可以从 privateKey 中查找地址,我使用 web3.eth.accounts.privateKeyToAddress,但它创建了一个余额为 0 的新帐户,而此私钥的现有地址余额为 100

Please use web3.eth.accounts.privateKeyToAccount .

web3.eth.accounts.privateKeyToAccount('0x348ce564d427...');

> {
      address: '0xb8CE9ab6943e0eCED004cDe8e3bBed6568B2Fa01',
      privateKey: '0x348ce564d427...',
      signTransaction: function(tx){...},
      sign: function(data){...},
      encrypt: function(password){...}
  }

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