1

This question already has an answer here:

The event logs can be obtain via getReceipt for specific transaction. However, the data is not friendly.

How can i parse those topics , data and the event name ?

the receipt of a specific transaction can be that

>eth.getTransactionReceipt("0xd177dfaa34ac9292d16b550515be05ab1e4b3cdd12f9857e8842fbfc8f8d6794")
{
  blockHash: "0x036ab39edba5a130f6fbb2354ddc1708894eb1e3a607567f58a400a2f09cac5b",
  blockNumber: 550864,
  contractAddress: null,
  cumulativeGasUsed: 35838,
  from: "0x8bae48f227d978d084b009b775222baaf61ed9fe",
  gasUsed: 35838,
  logs: [{
  address: "0xbf35faa9c265baf50c9cff8c389c363b05753275",
  blockHash: "0x036ab39edba5a130f6fbb2354ddc1708894eb1e3a607567f58a400a2f09cac5b",
  blockNumber: 550864,
  data: "0x0000000000000000000000008bae48f227d978d084b009b775222baaf61ed9feaf036571d10c371233bfad0aa6eb1d38671b893d819d5fba2be2df2854ad92c8",
  logIndex: 0,
  topics: ["0xe1c52dc63b719ade82e8bea94cc41a0d5d28e4aaf536adb5e9cccc9ff8c1aeda"],
  transactionHash: "0xd177dfaa34ac9292d16b550515be05ab1e4b3cdd12f9857e8842fbfc8f8d6794",
  transactionIndex: 0
  },     {
      address: "0xbf35faa9c265baf50c9cff8c389c363b05753275",
  blockHash: "0x036ab39edba5a130f6fbb2354ddc1708894eb1e3a607567f58a400a2f09cac5b",
  blockNumber: 550864,
  data: "0x0000000000000000000000008bae48f227d978d084b009b775222baaf61ed9feaf036571d10c371233bfad0aa6eb1d38671b893d819d5fba2be2df2854ad92c800000000000000000000000000000000000000000000000000000000000111110000000000000000000000009e9e3b33bc71aea932a956d0f9dd790d2b3dffa300000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000",
  logIndex: 1,
  topics: ["0xe7c957c06e9a662c1a6c77366179f5b702b97651dc28eee7d5bf1dff6e40bb4a"],
  transactionHash: "0xd177dfaa34ac9292d16b550515be05ab1e4b3cdd12f9857e8842fbfc8f8d6794",
  transactionIndex: 0
  }],
  root: "9dd86cc7eeed5996c1e66e91735017e0a35f6937c41faa98606d7fa98d739b1b",
  to: "0xbf35faa9c265baf50c9cff8c389c363b05753275",
  transactionHash: "0xd177dfaa34ac9292d16b550515be05ab1e4b3cdd12f9857e8842fbfc8f8d6794",
  transactionIndex: 0
 }

the topic field and data field is all in hex encode. It not friendly. How can i parse those hex string to get semantics value?

Besides, it is same to input field when an account sends a tx to contract. The input field like that

        input:"0x797af627af036571d10c371233bfad0aa6eb1d38671b893d819d5fba2be2df2854ad92c8"

the first 4 bytes is the signature of the function and the rest of the data is the parameters of function. How can i make it more semantic

marked as duplicate by niksmac, eth Aug 1 '16 at 7:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. – niksmac Aug 1 '16 at 6:19
  • @niksmac, I think the question is seeking for a general best practice to parse event results. I see the value in that – Roland Kofler Aug 1 '16 at 6:27
  • I think it returns JSON data. You can easily read them as desired. – Aniket Aug 1 '16 at 6:31
  • yes that would make sense so maybe niksmac is right – Roland Kofler Aug 1 '16 at 6:34
  • 1
    @RolandKofler of course you do. I was reading must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself – niksmac Aug 1 '16 at 6:34

Browse other questions tagged or ask your own question.