I tried multiple methods but I still can't access the data that is passed to the event in the code. Let's say I have the following contract with an event:

contract EtherBay { event NewEvent(address addr, uint intValue, bytes32 name); function withdraw() returns (bool) { NewEvent({ addr: 0, intValue: 10, name: 'someString'}); } }

Then in the js file I am using web3 to catch thrown event. Here is the code: web3.eth.filter("NewEvent") .watch(function(error, result) { console.log(result) });

The app enters the filer above but I am not sure of how to retrieve the data I passed when fired event (addr, intValue, name). I followed multiple tutorials online but none of them worked. I also tried to access the transaction by transactionHash but I could just retrieve intValue and name. Moreover, when I try to convert name to Ascii I get some weird characters along with the name itself. The version of solidity is 0.4.18.

  • Please post how you tried to access the data and how it failed
    – gisdev_p
    Nov 20, 2017 at 17:25
  • And please post the string that returns weird character when converting to Ascii
    – gisdev_p
    Nov 20, 2017 at 17:27
  • @gisdev_p Sorry, didn't think about that. I tried to access the data using getTransaction method from web3. Here is what I did: inputHex = web3.eth.getTransaction(transactionHash).input. As I understood input is exactly what I am looking for. Then I tried to decode the input using web3.toAscii method: web3.toAscii(inputHex). The result of the last command is equal to: '{±àCoke\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000'. As you can see, name=Coke.
    – David_Zizu
    Nov 20, 2017 at 18:15

1 Answer 1


The contract syntax is wrong, it shouldn't even compile.

contract EtherBay {
    event NewEvent(address addr, uint intValue, bytes32 name);

    function withdraw() returns (bool) {
enter preformatted text here
        NewEvent({ addr: 0, intValue: 10, name: 'someString'}); // This is incorrect.

You should be firing the event like this:

NewEvent(0x0...., 10, "someString");
  • I already tried that and it gives me an error if I fire the event like that.
    – David_Zizu
    Nov 20, 2017 at 20:41
  • Actually, I just tried that and it seems to be working. Not sure why I previously had an error. However, I am still having a hard time decoding the input. I also take the transactionHash, then look up this transaction and decode the input. The result is still the same: '{±àCoke\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000'.
    – David_Zizu
    Nov 20, 2017 at 20:50

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.