3

I'm using web3j in java to get the input data of a transaction. I can get the data, but the problem is how can I decode this data.

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"));

When you execute the code what you get is a variety of characters.

output

deHaar
  • 17,687
  • 10
  • 38
  • 51

1 Answers1

0

I'm not savvy with nodeJS but here's how to do it in python in case.

txn = web3.eth.get_transaction(txHash)                                  
txnInput = routerContract.decode_function_input(txn.input) 
print(txnInput)
BJonas88
  • 283
  • 4
  • 15