> For the complete documentation index, see [llms.txt](https://docs.notcentralised.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.notcentralised.com/sdk/service-bus.md).

# Service Bus

The guide walks you through the process from importing necessary libraries to adding and retrieving event values.

Firstly, import the required libraries:

```typescript
import { NotVault, ServiceBus } from '@notcentralised/notvault-sdk';
```

### Instructions

1. **Instantiate the NotVault and ServiceBus classes:**

```typescript
const vault = new NotVault();
const servicebus = new ServiceBus(vault);
```

The `NotVault` instance is required to initialize the `ServiceBus` class, which manages events in the confidential service bus.

2. **Define the Key and Confidential Value:**

```typescript
const key = BigInt(1);
const confidentialValue = BigInt(2);
```

The `key` and `confidentialValue` are BigInt values. You may replace `1` and `2` with any integers of your choice.

3. **Add an event value:**

```typescript
await servicebus.setValue(key, confidentialValue);
```

You can add an event value to the confidential service bus by calling the `setValue()` method. It requires two parameters: the key and the confidential value.

4. **Get an event value:**

```typescript
const retrievedConfidentialValue : BigInt = await servicebus.getValue("... Wallet Address ...", key);
```

You can retrieve the event value from the confidential service bus using the `getValue()` method. It requires two parameters: the wallet address and the key. It will return the confidential value associated with the given key.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.notcentralised.com/sdk/service-bus.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
