这是下面的代码片段:-
while (block_no >= 0) {
List<EthBlock.TransactionResult> txs = web3
.ethGetBlockByNumber(DefaultBlockParameter.valueOf(BigInteger.valueOf(block_no)), true).send()
.getBlock().getTransactions();
txs.forEach(tx -> {
int i = 0;
EthBlock.TransactionObject transaction = (EthBlock.TransactionObject) tx.get();
if ((transaction.getFrom().toLowerCase()).equals(address.toLowerCase())) {
// System.out.println("***************GETTING INSDIE OF IF LOOP***********");
ts[i] = new TransactionHistory();
ts[i].setFrom(transaction.getFrom());
ts[i].setTo(transaction.getTo());//not getting exact address except contract deployed address
ts[i].setBlockNumber("" + transaction.getBlockNumber());
ts[i].setGasPrice("" + transaction.getGasPrice());
ts[i].setNonce("" + transaction.getNonce());
history.add(ts[i]);
i++;
System.out.println("*******" + "\nValue Getting zero value" +
transaction.getvalue() + "\nBlockNumber: "
+ transaction.getBlockNumber() + "\n From: " +
transaction.getFrom() + "\n To:"
+ transaction.getTo() + "\n Nonce: " +
transaction.getNonce() + "\n BlockHash:"
+ transaction.getBlockHash() + "\n GasPrice:" +
transaction.getGasPrice());
//getting '0' instead of real value
System.out.println(transaction.getValue());
}
如何使用 java 和 web3js eth 交易对象获取交易价值和发件人地址?