1

Here's an example from solidity docs:

[SOLIDITY]

contract ClientReceipt {
    event Deposit(
        address indexed _from,
        bytes32 indexed _id,
        uint _value
    );

    function deposit(bytes32 _id) {
        Deposit(msg.sender, _id, msg.value);
    }
}

[JAVASCRIPT]

var ClientReceipt = web3.eth.contract(abi);
var clientReceipt = ClientReceipt.at(address);

var event = clientReceipt.Deposit();

event.watch(function(error, result){
    if (!error)
        console.log(result);
});

Now I'm getting a log every time somebody invokes a deposit function. It all works and I don't have any questions about that. What I can't understand is how an example from web3 api docs would work with the code above:

var event = myContractInstance.MyEvent({valueA: 23} [, additionalFilterObject])    
event.watch(function(error, result){
  if (!error)
    console.log(result);
});

My questions:

What does the property name value1 represents? Is it the name of an indexed argument? What will I get in my console if I pass {_value: 100} as the first argument? Will I get in my console an event object only when someone triggers the event with the parameter named _value and the value 100?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.