github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/concepts/stdlibs/events.md (about)

     1  ---
     2  id: events
     3  ---
     4  
     5  # Gno Events
     6  
     7  ## Overview
     8  
     9  Events in Gno are a fundamental aspect of interacting with and monitoring
    10  on-chain applications. They serve as a bridge between the on-chain environment 
    11  and off-chain services, making it simpler for developers, analytics tools, and 
    12  monitoring services to track and respond to activities happening in Gno.land.
    13  
    14  Gno events are pieces of data that log specific activities or changes occurring 
    15  within the state of an on-chain app. These activities are user-defined; they might
    16  be token transfers, changes in ownership, updates in user profiles, and more.
    17  Each event is recorded in the ABCI results of each block, ensuring that action 
    18  that happened is verifiable and accessible to off-chain services. 
    19  
    20  ## Emitting Events
    21  
    22  To emit an event, you can use the `Emit()` function from the `std` package 
    23  provided in the Gno standard library. The `Emit()` function takes in a string 
    24  representing the type of event, and an even number of arguments after representing
    25  `key:value` pairs. 
    26  
    27  Read more about events & `Emit()` in 
    28  [Effective Gno](../effective-gno.md#emit-gno-events-to-make-life-off-chain-easier),
    29  and the `Emit()` reference [here](../../reference/stdlibs/std/chain.md#emit).
    30  
    31  ## Data contained in a Gno Event
    32  
    33  An event contained in an ABCI response of a block will include the following
    34  data:
    35  
    36  ``` json
    37  {
    38      "@type": "/tm.gnoEvent", // TM2 type
    39      "type": "OwnershipChange", // Type/name of event defined in Gno
    40      "pkg_path": "gno.land/r/demo/example", // Path of the emitter
    41      "func": "ChangeOwner", // Gno function that emitted the event
    42      "attrs": [ // Slice of key:value pairs emitted
    43          {
    44              "key": "oldOwner",
    45              "value": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5"
    46          },
    47          {
    48              "key": "newOwner",
    49              "value": "g1zzqd6phlfx0a809vhmykg5c6m44ap9756s7cjj"
    50          }
    51      ]
    52  }
    53  ```
    54  
    55  You can fetch the ABCI response of a specific block by using the `/block_results` 
    56  RPC endpoint.
    57