I have an event in the contract , and upon the event fires I could able to see by a java listener as below

public void onTransactionExecuted(TransactionExecutionSummary summary) {
  List<LogInfo> listLogs= summary.getLogs();// This gives you list of log info
 // now Iterate and print the details

upon printing the loginfo object I get something like LogInfo{address=cd5805d60bbf9afe69a394c2bda10f6dae2c39af, topics=[37637aa70af5cd14eda4054cc4323408c237c26de60d49064db916e476c29e2e 67fad3bfa1e0321bd021ca805ce14876e50acac8ca8532eda8cbf924da565160 ], data=000000000000000000000000cd2a3d9f938e13cd947ec05abc7fe734df8dd826}.

I know it is some sort of abi encoded or serialized, but I want to decode what are the information I have in the logs.


In order to parse the information in the LogInfo you will need the contract ABI. Once you have the ABI it's easy to parse :

public void onTransactionExecuted(TransactionExecutionSummary summary) {
  String abi = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"amount\",\"type\":\"uint128\"}],\"name\":\"Transfer\",\"type\":\"event\"}]\n";
  for (LogInfo logInfo : summary.getLogs()) {
    CallTransaction.Contract contract = new CallTransaction.Contract(abi);
    CallTransaction.Invocation invocation = contract.parseEvent(logInfo);

An example of the tests that are used here is in the DecodeLogTest unit test


I'm working on this exact same issue with the 'input' field of Ethereum transactions. The closest I've come to figuring this out is in Gavin Wood's Yellow Paper (http://gavwood.com/paper.pdf) under Appendix 2; Recursive Length Prefixing. I think this is the formatting used, and in some cases it does work for the 'input' field of transactions on the chain, but I'm not sure about events. I "looks" similar.

  • Thomas, I actually could able to see the data in the topics section, which is Keccak encoded , I used emn178.github.io/online-tools/keccak_256.html to see if my data indexed and the hash matches. But appearntly this is one way. Given the hash I can't find the string Jun 20 '16 at 14:46
  • It's definitely one way. Jun 20 '16 at 15:33

May be the development guys realized this and started an issue, a feature which would solve it.

However I did find the following.

If arrays (including string and bytes) are used as indexed arguments, the sha3-hash of it is stored as topic instead.

However there is Hash Test: How to produce hash output which mentions it uses Keccak and not the final SHA3. So the value in the topics above explains what was logged.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.