Skip to content

Commit 6b1f5f6

Browse files
committed
docs(lit-client): update getIpfsId doc to include support for binary input types
1 parent aedfa59 commit 6b1f5f6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

docs/sdk/sdk-reference/lit-client/functions/getIpfsId.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ import { getIpfsId } from '@lit-protocol/lit-client/ipfs';
1414

1515
const cid = await getIpfsId('console.log("hello lit")');
1616
// cid === 'Qm...'
17+
18+
const bytes = new TextEncoder().encode('console.log("hello lit")');
19+
const sameCid = await getIpfsId(bytes);
20+
// sameCid === cid
1721
```
1822

1923
## Parameters
2024

2125
| Name | Type | Description |
2226
| ---- | ---- | ----------- |
23-
| input | `string` | Source content to hash. Mirrors the v7 helper contract by accepting plain strings. |
27+
| input | `string \| Uint8Array \| ArrayBuffer \| ArrayBufferView` | Source content to hash. Strings are UTF-8 encoded automatically; buffers and typed views are accepted directly. |
2428

2529
## Returns
2630

@@ -29,4 +33,4 @@ const cid = await getIpfsId('console.log("hello lit")');
2933
## Notes
3034

3135
- The helper delegates to the same hashing routine used in v7 (`typestub-ipfs-only-hash`) and can be imported without pulling the entire Lit Client into your bundle.
32-
- If you need to hash binary data, convert it to a string representation (for example, base64) before passing it to `getIpfsId`.
36+
- Binary payloads do not need to be stringified first—pass any `Uint8Array`, `ArrayBuffer`, or typed view directly and the helper will normalize it before hashing.

0 commit comments

Comments
 (0)