I'm trying to monitor events using web3.js, with the allEvents() method. Is there a way to get a unique identifier for the event that was called?

When calling watch, the things you get from the callback are:

  • address: String, 32 Bytes - address from which this log originated.
  • args: Object - The arguments coming from the event.
  • blockHash: String, 32 Bytes - hash of the block where this log was in. null when its pending.
  • blockNumber: Number - the block number where this log was in. null when its pending.
  • logIndex: Number - integer of the log index position in the block.
  • event: String - The event name.
  • removed: bool - indicate if the transaction this event was created from was removed from the blockchain (due to orphaned block) or never get to it (due to rejected transaction).
  • transactionIndex: Number - integer of the transactions index position log was created from.
  • transactionHash: String, 32 Bytes - hash of the transactions this log was created from.

Obviously, "event" is not sufficient as there can be multiple events with the same name but different signatures.


1 Answer 1


This is possible in beta by doing event.raw.topics[0] (solidity stores the signature in the first topic). Also, event.signature was added to beta 11. See this issue.


myContract.once('MyEvent', {
  filter: {myIndexedParam: [20,23], myOtherIndexedParam: '0x123456789...'}, // Using an array means OR: e.g. 20 or 23
  fromBlock: 0
}, function(error, event){ console.log(event); });

// event output example
> {
    raw: {
      data: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
      topics: ['0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385']
    signature: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',

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.