SDK Overview
@dataprism/sdk is the client-side core of DataPrism, in TypeScript, embeddable anywhere
(browser, Node backend, or a script). It exposes a single API for three jobs:
- Drive the blockchain: create prisms, read/write slots, whether or not the user pays gas.
- Encrypt / decrypt: keys derived from a wallet signature, never stored.
- Store files: chunking, encryption, content addressing, and managed object storage.
It is ESM, strict TypeScript, and pulls in no heavy cloud SDK. Dependencies: viem (peer,
≥ 2.0), @noble/curves, @noble/ciphers, @noble/hashes.
Install
npm install @dataprism/sdk viemQuick start
import { DataPrismClient, DataPrismNetwork, DEMO } from "@dataprism/sdk";
const network = new DataPrismNetwork(DEMO, "https://rpc.example.com");
// wallet mode (default) - the user pays gas
const client = new DataPrismClient(network, { walletClient });
// api mode - the relayer fronts the gas (reimbursed in DPC)
const client = new DataPrismClient(network, { walletClient, apiUrl, mode: "api" });
// read-only - no wallet
const client = new DataPrismClient(network);The entry point is DataPrismClient, a lazy facade that builds its sub-clients on first
access:
| Getter | Type | Needs a wallet |
|---|---|---|
reader | NetworkReader | no |
execution | ExecutionLayer | yes |
signer | DataPrismSigner | yes |
prism(std, cloudId?) | PrismManager | yes |
Layered architecture
YOUR APPLICATION
│
┌───────────────────▼───────────────────────────────────────┐
│ STANDARD CloudStandard / CloudReader - prism slots │ standard/
├────────────────────────────────────────────────────────────┤
│ CRYPTO DataPrismKey - keys + seal/open │ crypto/
├────────────────────────────────────────────────────────────┤
│ FILES FilePipeline + ReedSolomon │ files/
│ STORAGE StorageProvider (Managed, Memory) │ storage/
├────────────────────────────────────────────────────────────┤
│ EXECUTION ExecutionLayer (wallet | api) - writes │ execution/
│ READING NetworkReader SIGNING DataPrismSigner │ network/, signing/
├────────────────────────────────────────────────────────────┤
│ NETWORK DataPrismNetwork (chainId, RPC, addresses) │ network/
└────────────────────────────────────────────────────────────┘
│
DataPrismCloud.sol · DataPrismCloudForwarder.sol (on-chain)
│
DataPrism-managed object storage ← encrypted file shardsGolden rule: each layer only knows the one directly beneath it.
Importable modules (subpaths)
The SDK is published wagmi/viem-style: everything is re-exported from the root
@dataprism/sdk, and each module is also importable on its own subpath.
import { DataPrismClient } from "@dataprism/sdk"; // facade
import { DataPrismNetwork, DEMO } from "@dataprism/sdk/network";
import { walletExecution } from "@dataprism/sdk/execution";
import { DataPrismSigner } from "@dataprism/sdk/signing";
import { ApiWriter } from "@dataprism/sdk/api";
import { DataPrismKey } from "@dataprism/sdk/crypto";
import { CloudStandard, CloudReader } from "@dataprism/sdk/standard";
import { PrismManager } from "@dataprism/sdk/prism";
import { ManagedStorageProvider } from "@dataprism/sdk/storage";
import { FilePipeline } from "@dataprism/sdk/files";
import { DataPrismCloudAbi } from "@dataprism/sdk/abi";| Subpath | Role | Main exports | Docs |
|---|---|---|---|
/network | the "where" (chain, RPC, addresses) + low-level reads/writes | DataPrismNetwork, DEMO, NetworkReader, NetworkWriter, computeCloudId | Network & Client, Reading |
/execution | unified write layer | ExecutionLayer, BaseExecutionLayer, WalletExecution, ApiExecution | Execution Layer |
/signing | EIP-712 signatures | DataPrismSigner, hashBytes32Array, hashPayloadsArray | Execution Layer |
/api | dataprism-api REST client | ApiWriter, extractCloudId | Execution Layer |
/crypto | prism keys + encryption | DataPrismKey, seal, open | Cryptography |
/standard | prism slots (codec + decrypting reads) | CloudStandard, CloudReader, SLOT_IDS | Cloud Standard |
/prism | high-level prism lifecycle | PrismManager | Cloud Standard |
/storage | storage connectors | StorageProvider, ManagedStorageProvider, MemoryProvider | Storage Providers |
/files | file pipeline | FilePipeline, ReedSolomon, FastCDCChunker, convergentSeal | File Pipeline |
/abi | contract ABIs | DataPrismCloudAbi, DataPrismCloudForwarderAbi | - |
End-to-end at a glance
// 1. key derived from a wallet signature (message derived from the cloudId; add `:${password}` for extra security)
const sig = await walletClient.signMessage({ message: `dataprism:key:${cloudId}` });
const key = DataPrismKey.fromSignature(sig, { curve: "secp256k1", algorithm: "aes-256-gcm" });
const std = new CloudStandard(key);
// 2. create a prism + initialize its 4 reserved slots
const manager = client.prism(std);
const { cloudId } = await manager.create({ fundAmount, salt, metadata, providers });
// 3. upload a file to managed storage, index written on-chain
const storage = [new ManagedStorageProvider({
apiUrl: "https://api.dataprism.co",
projectId: cloudId,
getAccessToken,
})];
const pipeline = new FilePipeline({ providers: storage, standard: std,
execution: client.execution, cloudId });
await pipeline.upload("report.pdf", bytes, { chunkSize: 65536, dataShards: 1, parityShards: 0 });
// 4. read it back
const view = std.reader(client.reader, cloudId);
const index = await view.file("report.pdf");
const bytes = await pipeline.download(index);Each step is detailed in the pages that follow.

