Skip to main content

Overview

getIpfsId is an optional helper exported via @lit-protocol/lit-client/ipfs. It produces CIDv0 IPFS identifiers identical to the Lit SDK v7 utility while remaining fully tree-shakeable from the main client bundle.

Usage

import { getIpfsId } from '@lit-protocol/lit-client/ipfs';

const cid = await getIpfsId('console.log("hello lit")');
// cid === 'Qm...'

const bytes = new TextEncoder().encode('console.log("hello lit")');
const sameCid = await getIpfsId(bytes);
// sameCid === cid

Parameters

NameTypeDescription
inputstring | Uint8Array | ArrayBuffer | ArrayBufferViewSource content to hash. Strings are UTF-8 encoded automatically; buffers and typed views are accepted directly.

Returns

// A CIDv0 string beginning with Qm
Promise<Qm${string}>

Notes

  • 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.
  • 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.