I am trying to convert transaction logs in text (human readable format) tried 2 methods

1. using web3.toAscii(receipt.logs[0].topics[0])

2.Using coder.js according to this answer

While using 2nd method I get error :

Cannot find module 'file:///C:/Users/user1/node_modules/web3/lib/solidity/coder.js'

Path where my coder.js file resides C:/Users/user1/node_modules/web3/lib/solidity/coder.js

Is there any other way to parse the transaction log and get the data in human readable format.

code used to access coder.js

var SolidityCoder = require('file:///C:/Users/user1/node_modules/web3/lib/solidity/coder.js');

also tried

var SolidityCoder = require('C:\\Users\\user1\\node_modules\\web3\\lib\\solidity\\coder.js');
  • Are you getting this error in a browser? If yes, can you please share the code where you refer coder.js? Commented Jun 6, 2017 at 14:14
  • @Omkar I have updated the question as of you asked Commented Jun 7, 2017 at 6:46

1 Answer 1


Using web3.toAscii

That function is not what you're looking for, at least not for topics[0] of a log entry. The first entry in the "topics" array is the signature of what type of log entry it is. So it's a hash, and won't resolve to anything useful just converting it to ASCII.

If you already have the ABI of a contract, which includes the definition of the Events it uses, then you can calculate the hash that the log entry uses:

let events = [
    type: 'event',
    name: 'HelloWorld',
    anonymous: false,
    inputs: [{"indexed":false,"name":"call_address","type":"address"}]
  // List out all the events you care about

function getEventSignature(eventAbi) {
  var signature = eventAbi.name + '(' + eventAbi.inputs.map(function(input) { return input.type; }).join(',') + ')';
  var hash = web3.sha3(signature);
  return {
    signature: signature,
    hash: hash,
    abi: eventAbi

var topicMap = {};
events.map(eventAbi => {
  var signature = getEventSignature(eventAbi);
  topicMap[signature.hash] = signature;

If you only have the log's topic[0] value, you cannot go backwards from that to figure out the Event's name, since it is a hash (which by its definition is only one-way).

That other question references the coder.js library as a way to parse the data of the log entry, which is different than its topics.

  • this will return the event method signature, I actually want to parse the log entries created for transactions Commented Jun 7, 2017 at 6:42
  • 1
    The event signature is the first item in all log entries. So that's the first step in parsing those entries. Once you know what type of log entry it is, you can then parse the rest of it knowing which values that type of event emits. Commented Jul 20, 2018 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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