> For the complete documentation index, see [llms.txt](https://docs.humandataincome.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.humandataincome.com/datamask/for-developers/ipdw-interplanetary-data-wallet/examples.md).

# Examples

This section provides practical examples for developers looking to integrate IPDW into their applications. It covers the installation process, interface instantiation, and key-value data management within the IPDW. The examples also demonstrate how data can be synchronized automatically between devices using P2P communication, providing a hands-on guide to leveraging IPDW's full capabilities.

To get started with IPDW, you will need to follow these steps:

Install the package:

```bash
$ npm install ipdw
```

Instantiate ipdw with this interface:

```typescript
public static async Create(privateKey: string, storageProvider: StorageProvider, salt?: Buffer): PromiseThen access to "data", which is a sharded map where you can get and set in a key-value style.
```

The full example with auto synchronization between devices:

```typescript
import {IPDW, MemoryStorageProvider} from "ipdw";

// On device 1
(async function () {
    const privateKey = '0xb577c4367d79f1a7a0c8353f7937d601758d92c35df958781d72d70f9177e52f';
    const provider = await IPDWStorageProvider.Init(privateKey, new MemoryStorageProvider());
    const dataWallet = await DataWallet.Create(privateKey, provider);
    
    await dataWallet.set('test1', 'hello');

    const value1 = await dataWallet.get('test1');
    console.log('test1 value:', value1);
    // test1 value: hello

    // Run "device 2" and if reachable it will be discovered and synced
    const value2 = await dataWallet.get('test2');
    console.log('test2 value:', value2);
    // test2 value: world
})();

// On device 2
(async function () {
    const privateKey = '0xb577c4367d79f1a7a0c8353f7937d601758d92c35df958781d72d70f9177e52f';
    const provider = await IPDWStorageProvider.Init(privateKey, new MemoryStorageProvider());
    const dataWallet = await DataWallet.Create(privateKey, provider);
    
    await ipdw.data.set('test2', 'world');
})();
```


---

# 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.humandataincome.com/datamask/for-developers/ipdw-interplanetary-data-wallet/examples.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.
