# Emitting events

### Emitting events from go-plugins <a href="#emitting-events-from-go-plugins" id="emitting-events-from-go-plugins"></a>

The zeknd SDK gives a facility for the contracts to emit events that can be used for multiple purposes such as indexing. Currently, the zeknd SDK supports emitting events into a Redis sorted set.

#### #Configuring the zeknd SDK <a href="#configuring-the-loom-sdk" id="configuring-the-loom-sdk"></a>

By default, the zeknd SDK will only emit events to the log. To configure it to send the events to a Redis sorted set, add the following line to the zeknd`.yaml` config file:

```
EventDispatcherURI: "redis://localhost:6379"
```

This will start emitting events to the Redis server in a sorted set called zeknd`events`. Each event is added to the sorted set, with the score being the blockchain height.

#### #Emitting events <a href="#emitting-events" id="emitting-events"></a>

The code snippet below shows how to emit events from the contract:

```
    emitMsg := struct {
        Owner  string
        Method string
        Addr   []byte
    }{owner, "createacct", addr}
    emitMsgJSON, err := json.Marshal(emitMsg)
    if err != nil {
        log.Println("Error marshalling emit message")
    }
    ctx.Emit(emitMsgJSON)
```

#### #Subscribing to events <a href="#subscribing-to-events" id="subscribing-to-events"></a>

See this page for more information on subscribing to events


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.opzeknd.xyz/go-contract-sdk/emitting-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
