我在 java 中使用 web3j 来获取交易的输入数据。我可以获得数据,但问题是如何解码这些数据。
Input data: "0x070ec83b000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000015118f200000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000.........."
String inputdata = null;
Optional<Transaction> tx = web3.ethGetTransactionByHash(txHash).send().getTransaction();
if (tx.isPresent()) {
inputdata = tx.get().getInput();
}
//DECODE
byte[] bytes = Hex.decodeHex(inputdata.substring(2).toCharArray());
System.out.println(new String(bytes, "UTF-8"));
当你执行代码时,你得到的是各种字符。