Ich habe einige Ereignisse so in meine Verträge aufgenommen
event TokenTransfer(address indexed sender,address indexed receiver,uint32 indexed num_tokens);
event ExceptionEvent(uint16 indexed retcode,address indexed userAddress,string context);
In meinem nodejs-Skript mache ich so etwas
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);
}
});
Auf meiner node js-Konsole bekomme ich so etwas
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
Kann jemand sagen, was ich falsch mache? Meine Umgebung ist: Blockchain:hydrachain Solidity:solc 0.2.0-1 Ubuntu 14:04
Es gibt eine Problemumgehung, die hier dokumentiert ist:
https://gitter.im/ethereum/web3.js/archives/2016/01/09
Ändern Sie das fromBlock: 0
in fromBlock: 'latest'
entsprechend diesem Chat.
AFAICT niemand hat eine Grundursache identifiziert.
Auch in meinem Code verwende ich die gesamte contract.allEvents
API und habe kein Problem. Sie können versuchen, Ihre eigenen speziellen Ereignisse von dort aus zu senden oder sie einfach aus dem txreceipt zu analysieren, anstatt das Ereignissystem überhaupt zu verwenden. Ich stoße immer wieder auf Probleme mit dem Ereignissystem, daher verwende ich außer allEvents zur Überwachung eines Vertrags für Debugging und Analyse überhaupt keine Ereignisse.
AFAIK die Variable blockWatchResult enthält ein Objekt mit vielen Eigenschaften; In der Eigenschaft .args sollten Sie Ihre Ereignisparameter finden: .args['sender'], .args['receiver']...
JB
Joël
Codekampf
Paul S
,string context
der Typ vielleicht etwas ist, mit dem web3.js nicht richtig umgeht?Paul S
Paul S