Nodes

如何使用 JS 在伺服器端生成乙太坊錢包和密鑰?

  • June 29, 2018

任何人都知道,如何在伺服器端(node.js)生成乙太錢包。服務需要它,為新客戶創建新錢包。也許像bitcoinJS-lib但對於乙太坊?但是我自己找不到,請幫忙:)

使用 web3js 庫,這是你在 nodejs 伺服器端的操作方法

//generate private key    
privateKey = web3.eth.accounts.create().privateKey.substr(2)

//generates pubKey from privateKey, encrypts it and store in keystore folder.
web3.eth.personal.importRawKey(privateKey, pin)
   .then((result) => {

   //store pub address.
   publicAddr = web3.utils.toChecksumAddress(result)
})

你去吧。

引用自:https://ethereum.stackexchange.com/questions/52338