# Usage

Once initialized, the HatsDetailsClient can be used for reading and storing data from/to IPFS, in a predetermined format.&#x20;

## Store

Use the the following function in order to store/pin data to IPFS.&#x20;

The data is expected to be compatible with the provided schema, otherwise an error will be thrown. If data was successfully pinned, its CID (content identifier). This can then be used for reading the data back from IPFS.

```typescript
const cid = await hatsDetailsClient.pin({
    type: "1.0",
    data: {
        name: "Hat",
        description: "This is a hat",
    },
});
```

## Read

Read data from IPFS.

```typescript
const data = await hatsDetailsClientDefaultSchema.get(
    "QmcSopxmw5rMEEEU8NmGGQ2mbHJ293CGEiQ4r4w4jEECVy"
);
```

The returned data has the following type:

```typescript
{
    parsedData: z.infer<T> | null;
    rawData: unknown | null;
    error: { message: string } | null;
}
```

* If data was successfully fetched and is compatible with the client's schema, then the parsed data will be in the `parsedData` field, while the `rawData` and `error` fields will be `null`.
* If data was successfully fetched but is not compatible with the client's schema, then the data will be in the `rawData` field, while the `data` and `error` fields will be `null`.
* If an error occurred, then the `data` and `rawData` fields will be `null`, and the `error` field will contain an object with a `message` field.


---

# 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://docs.hatsprotocol.xyz/for-developers/v1-sdk/hat-details/usage.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.
