> For the complete documentation index, see [llms.txt](https://developer.opzeknd.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.opzeknd.xyz/go-contract-sdk/emitting-events.md). Agents can also search and read this documentation through its [MCP server](https://developer.opzeknd.xyz/~gitbook/mcp).

# 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
