如何在Java文件中创建以太坊帐户和通过web3j查询账目情况?

在web3j的文档中,我没有看到创建帐户和的web3j查询账目任何内容,我想知道这是否可行?

问题回答:

其实挺简单的,ethGetBalance方法将返回任何给定帐户的余额。你可以参考下面的例子:

// connect to node
Web3j web3 = Web3j.build(new HttpService());  // defaults to http://localhost:8545/

// send asynchronous requests to get balance
EthGetBalance ethGetBalance = web3
  .ethGetBalance("0xAccountAddress", DefaultBlockParameterName.LATEST)
  .sendAsync()
  .get();

BigInteger wei = ethGetBalance.getBalance();

原文《以太坊常见问题和错误》中的:
http://cw.hubwiz.com/card/c/ethereum-FAQ/1/1/14/

另外推荐几个很受欢迎全网稀缺的互动教程:

  • web3j,主要是针对java和android程序员围绕web3j库进行区块链以太坊开发的讲解。
  • python以太坊,主要是针对python围绕web3.py进行区块链以太坊应用开发的讲解。
  • php以太坊,主要是介绍使用php进行智能合约开发交互,进行账号创建、交易、转账、代币开发以及过滤器和事件等内容。
  • 以太坊开发,主要是介绍使用node.js、mongodb、区块链、ipfs实现去中心化电商DApp实战,适合进阶。
  • 以太坊教程,主要介绍智能合约与dapp应用开发,适合入门。

猜你喜欢

转载自blog.csdn.net/mongo_node/article/details/81094513