@chillwhales/lsp29
v0.1.3
Published
LSP29 Encrypted Assets standard — schemas, types, constants, and encode/decode utilities for encrypted content on Universal Profiles
Readme
@chillwhales/lsp29
LSP29 Encrypted Assets — schemas, types, constants, and encode/decode utilities for storing and retrieving encrypted content on Universal Profiles.
Install
pnpm add @chillwhales/lsp29Peer dependency: This package requires
viem^2.0.0pnpm add viem
Usage
import {
computeLsp29MapKey,
computeLsp29ArrayIndexKey,
decodeLsp29Metadata,
} from "@chillwhales/lsp29";
// Compute the ERC725Y data key that maps a content ID to its array index
const mapKey = computeLsp29MapKey("premium-content");
// Use with getData() to look up the array index for this content
// Compute the array element key for a specific index
const elementKey = computeLsp29ArrayIndexKey(0);
// Use with getData() to retrieve the VerifiableURI at this index
// Decode and validate LSP29 metadata JSON (e.g. fetched from IPFS)
const jsonString = await fetch("ipfs://QmMetadata.../lsp29.json").then((r) => r.text());
const metadata = decodeLsp29Metadata(jsonString);
console.log(metadata.LSP29EncryptedAsset.title);
console.log(metadata.LSP29EncryptedAsset.encryption.provider);Spec: See
LSP-29-EncryptedAssets.mdin the repository for the full specification.
API
Types are exported and available in your editor via TypeScript IntelliSense.
