9

I have put some events in my contracts like this

event TokenTransfer(address indexed sender,address indexed receiver,uint32 indexed num_tokens);
event ExceptionEvent(uint16 indexed retcode,address indexed userAddress,string context);

In my nodejs script I am doing something like this

iouContractInstance.TokenTransfer({},{fromBlock: 0, toBlock: 'latest'}).watch(function(blockWatchError, blockWatchResult){
    console.log("Looking out for Tokentransfer data");
    console.log("TokenTranfer Error:"+blockWatchError);
    if(!blockWatchError){
        console.log("The event data result is:"+blockWatchResult);
    }
});

iouContractInstance.ExceptionEvent({},{fromBlock:0,toBlock:'latest'}).watch(function(blockWatchError, blockWatchResult){
    console.log("Looking out for ExceptionEvent event data");
    console.log("ExceptionEvent Error:"+blockWatchError);
    if(!blockWatchError){
        console.log("The event data result is:"+blockWatchResult);
    }
});

On my node js console I get something like this

Looking out for Tokentransfer data
TokenTranfer Error:Error: Can only serialize integers
Looking out for ExceptionEvent event data
ExceptionEvent Error:Error: Can only serialize integers
Looking out for Tokentransfer data

Can somebody tell what am doing wrong? My environment is: Blockchain:hydrachain Solidity:solc 0.2.0-1 Ubuntu 14:04

  • This might well be a bug in pyethereum, on which hydrachain is based. Can you verify if your event code does work with go-ethereum? – Joris Bontje Jan 29 '16 at 2:46
  • Bump, any news on this @codestruggle? – Joël Feb 17 '16 at 3:57
  • @Joel Hello Actually have'nt got time to concentrate on this right now though. I have a few pressing things to take care but as soon as I get time will look into this one. – codestruggle Feb 17 '16 at 14:12
  • I don't think it's hydrachain, i use geth and I saw this occasionally. Unfortunately I can't remember how I fixed it. Recompile? Not sure ,string context type maybe isn't something web3.js deals with correctly? – Paul S Mar 13 '16 at 4:57
  • I'm starting to think this might be pythereum. I saw this when I was using one of the testRPC implemenations I think. I can't repro on geth. – Paul S Mar 15 '16 at 16:26
2
+50

There's a workaround documented here:

https://gitter.im/ethereum/web3.js/archives/2016/01/09

Change the fromBlock: 0 to fromBlock: 'latest' according to that chat.

AFAICT nobody has identified a root cause.

Also In my code I use all the contract.allEvents API and don't have a problem. might try event dispatching your own particular events from that, or just parsing them from the txreceipt rather than using the event system at all. I keep running into issues with the event system, so other than the allEvents to monitor a contract for debugging and analytics I don't use events at all.

  • Thanks a lot for your answer. I will try to implement and see. – codestruggle Apr 13 '16 at 10:54
0

AFAIK the blockWatchResult variable will contains an object with many properties; in the .args property you should find your events parameters: .args['sender'], .args['receiver']...

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.