@chillwhales/lsp31
v0.1.2
Published
LSP31 Multi-Storage URI standard — encode, decode, and resolve multi-backend content references
Downloads
36
Readme
@chillwhales/lsp31
LSP31 Multi-Storage URI — encode, decode, and resolve multi-backend content references for redundant storage on LUKSO Universal Profiles.
Install
pnpm add @chillwhales/lsp31Peer dependency: This package requires
viem^2.0.0pnpm add viem
Usage
import {
encodeLsp31Uri,
parseLsp31Uri,
computeContentHash,
} from "@chillwhales/lsp31";
// Define storage entries (minimum 2 backends for redundancy)
const entries = [
{ backend: "ipfs" as const, cid: "QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG" },
{ backend: "arweave" as const, id: "abcdef1234567890abcdef1234567890abcdef123456" },
];
// Encode with a verification hash of the content bytes
const contentBytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
const hash = computeContentHash(contentBytes);
const encoded = encodeLsp31Uri(entries, hash);
// encoded is a hex string ready for setData()
// Later, parse the on-chain value back into structured entries
const { verificationData, entries: decoded } = parseLsp31Uri(encoded);
console.log(decoded[0].backend); // "ipfs"Spec: See
LSP-31-MultiStorageURI.mdin the repository for the full specification.
API
Types are exported and available in your editor via TypeScript IntelliSense.
