Reading assignment - Solidity Events


#81

1. How are events declared?
event EventName ( ... );

2. How can we emit events?
emit EventName( ... );

3. How and where do we listen for events?
Applications can a) subscribe and b) listen to events via the RPC (Remote Procedural Call) interface of an Ethereum client.


#82

1. How are events declared?
Events are defined by the “event” keyword and can be fired within a function body.

2. How can we emit events?
To emit an event (invoke it inside a function body) we use the “emit” keyword followed by the eventname.

3. How and where do we listen for events?
Inside the contract we define what functions have to invoke what event. Outside the contract (in the
programming language of the app you want to implement using the contract) you can watch for those
events.

First we define the event:
var <eventname> = <variable used for contract>.<eventname inside contract>()

Then we can watch for the event:

<eventname>.watch(function(error, result){
     if (!error)  
        <do actions if no errors occurred>;
    else
       <do actions if errors occurred>;
});

#83
  1. Events are declared with “event eventName { };”

  2. Declared events are emitted via “emit eventName (parameters);”

  3. Applications can subscribe and listen to these events through the RPC interface of an Ethereum client. The code is “event.watch(){};”


#84
  1. How are events declared?
    With the event keyword in smart contract.
  2. How can we emit events?
    An event is emitted within a function by calling the event functions.
  3. How and where do we listen for events?
    Event is used to interact with dapp fron end. Events can be used in the front end code for interactions.

#85
  1. How are events declared? Use the keyword event followed by the name of the event, enclose its contents with parentheses, and end with a semi-colon. Entries inside of the event are separated by comma.
  2. How can we emit events? Use the emit keyword, followed by the name of the event and the arguments (if any) in parentheses.
  3. How and where do we listen for events? Applications can subscribe and listen to events through the remote procedure call (RPC) interface of an Ethereum client.

#86
  1. How are events declared?
    event EventName(arguments);

  2. How can we emit events?
    EventName(arguments);

  3. How and where do we listen for events?
    Though a callback in Javascript API, in the user interface of the dapp, we can listen to these events.


#87

1.How are events declared?

event EventNameHandle( Indexed returned Object -up to 2- , Object -additional- , Function -optional-);

2. How can we emit events?

emit EventNameHandle(Object, Object)

3. How and where do we listen for events ?
EventNameHandle.watch


#88
  1. How are events declared?
  • event NameOfEvent(
    // Arguments
    );
  1. How can we emit events?
  • NameOfEvent(
    // Arguments
    );
  1. How and where do we listen for events?
  • We can listen for events by introducing a JavaScript callback, in which case we would listen to the event on the front end of an application // PLEASE CORRECT IF THIS IS NOT ACCURATE

#89
  1. event Deposit(param1, param2, …); <= with the keyword event followed by the event name
  2. By using emit keyword followed by the event name like below.
function aFunction() {
  emit Deposit();
}
  1. We listen to the events outside the contracts because they exist as logs, using web3 libraries.