Node.js script
This example goes end to end in one file: connect to your project, upload a file to your own bucket, read the index back from the network, and download the file again. Everything below runs on the Demo network with test tokens.
Before you start
Create a project in the dashboard (Your first project) with at least one storage provider, then open the project's SDK tab and copy:
- the Project ID (
cloudId), - the Secret key (click Reveal, then copy),
- the encryption settings shown next to them (curve and algorithm).
You also need an account private key with a little Demo network currency to pay fees for the write, plus a short-lived token for your storage signing service. Keep all runtime secrets in environment variables, never in source control.
Setup
mkdir dataprism-demo && cd dataprism-demo
pnpm init && pnpm add @dataprism/sdk viemConnect
import { DataPrismClient } from "@dataprism/sdk";
import { DataPrismNetwork, DEMO } from "@dataprism/sdk/network";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
const RPC_URL = "https://ethereum-sepolia-rpc.publicnode.com";
const network = new DataPrismNetwork(DEMO, RPC_URL);
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const walletClient = createWalletClient({
account,
chain: network.chain,
transport: http(RPC_URL),
});
const client = new DataPrismClient(network, { walletClient });Configure project access
import { DataPrismKey } from "@dataprism/sdk/crypto";
import { CloudStandard } from "@dataprism/sdk/standard";
const cloudId = process.env.PROJECT_ID as `0x${string}`; // Project ID (cloudId)
const key = DataPrismKey.fromSecret(
process.env.SECRET_KEY as `0x${string}`, // Secret key
{ curve: "secp256k1", algorithm: "aes-256-gcm" }, // as shown in the SDK tab
);
const std = new CloudStandard(key);That is the whole integration handshake: the Project ID says which prism to talk to, and the Secret key decrypts what is inside.
Upload and download a file
import { FilePipeline } from "@dataprism/sdk/files";
import { initProviders, signedUrlRegistry } from "@dataprism/sdk/storage";
// The project contains only bucket metadata and customer-controlled signer URLs.
// The signer token is supplied at runtime and is never written to the project.
const storageSignerToken = process.env.STORAGE_SIGNER_TOKEN;
if (!storageSignerToken) throw new Error("STORAGE_SIGNER_TOKEN is required");
const view = std.reader(client.reader, cloudId);
const storage = initProviders(
await view.providers(),
signedUrlRegistry({
getSignerHeaders: () => ({
authorization: `Bearer ${storageSignerToken}`,
}),
}),
);
const pipeline = new FilePipeline({
providers: storage,
standard: std,
execution: client.execution,
cloudId,
});
const bytes = new TextEncoder().encode("hello dataprism");
await pipeline.upload("hello.txt", bytes, {
chunkSize: 65_536,
dataShards: 1,
parityShards: 0,
});
const index = await view.file("hello.txt");
const restored = await pipeline.download(index);
console.log(new TextDecoder().decode(restored)); // hello dataprismThe file that landed in your bucket is a set of encrypted, hash-named shards. Without your Secret key, it is noise.
Where to go next
- With several providers configured, raise
dataShardsandparityShardsto spread shards and tolerate provider outages. - Prisms can also be created entirely from code, without the dashboard, via
PrismManager. - The complete, runnable version of this script lives in the repository under
examples/node-esm, including a delegated variant that writes through the DataPrism API without paying network fees itself.

