我正在用Java中的web3j来获取事务的输入数据。我可以获取数据,但是问题是如何解码该数据。
输入数据:“ 0x070ec83b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015118f200000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000000000000000000e000000
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"));
执行代码时,您得到的是各种各样的字符。