开发者社区> 问答> 正文

使用web3j加载智以太坊能合约如何指定证书Credentials?

使用web3j加载智以太坊能合约如何指定证书Credentials?

展开
收起
景凌凯 2020-03-18 18:50:19 778 0
1 条回答
写回答
取消 提交回答
  • 有点尴尬唉 你要寻找的东西已经被吃掉啦!

    若要生成凭据,如果你有普通的公钥和私钥,则需要将它们转换为十六进制的表示形式,然后将它们传递给构造函数用于Credentials。

    String hexPrivateKey = String.format("%040x", new BigInteger(1, privateKey.getBytes())); String hexPublicKey = String.format("%040x", new BigInteger(1, publicKey.getBytes()));
    Credentials creds = Credentials.create(hexPrivateKey, hexPublicKey);

    其中privateKey和privateKey是包含你的私钥和公钥的字符串。

    2020-03-18 18:50:34
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Web应用系统性能优化 立即下载
高性能Web架构之缓存体系 立即下载
PWA:移动Web的现在与未来 立即下载