java基於web3j建立錢包
阿新 • • 發佈:2018-12-12
1.建立一個eth錢包
Bip39Wallet wallet;
try {
wallet = WalletUtils.generateBip39Wallet(walletPwd, new File(EthUtil.KEYSTOREPATH));
} catch (Exception e) {
throw new Exception(“建立以太坊錢包失敗”);
}
2.keyStore檔名
String keyStoreKey = wallet.getFilename();
3.生成12個單詞的助記詞
String memorizingWords = wallet.getMnemonic();
4.通過錢包密碼與助記詞獲得錢包地址、公鑰及私鑰資訊
Credentials credentials = WalletUtils.loadBip39Credentials(walletPwd,
wallet.getMnemonic());
錢包地址 :credentials.getAddress();
公鑰16進位制字串表示:
String publicKey = credentials.getEcKeyPair().getPublicKey().toString(16);
私鑰16進位制字串表示:
String privateKey = credentials.getEcKeyPair().getPrivateKey().toString(16);