Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Network & Client

The SDK is built around two top-level objects: a network (which chain, which RPC, which contract addresses) and the client facade that hangs everything off it.

DataPrismNetwork

Encapsulates where you talk. It builds a viem PublicClient (with automatic fallback if you pass several RPC URLs) and a viem Chain.

new DataPrismNetwork(definition: NetworkDefinition, rpcUrls: string | string[])
const network = new DataPrismNetwork(DEMO, "https://rpc.example.com");
// or with fallback RPCs:
const network = new DataPrismNetwork(DEMO, ["https://rpc-a", "https://rpc-b"]);
MemberTypeDescription
definitionNetworkDefinitionthe preset it was built from
chainChainthe concrete viem chain (handy for building a walletClient)
publicClientPublicClienta ready-to-read viem client
chainIdnumberthe chain id
namestringthe chain name (sent as chainName to the API)
addressesNetworkAddressesthe contract addresses
rpcUrlsreadonly string[]the RPC URLs provided

NetworkDefinition & NetworkAddresses

interface NetworkAddresses {
  readonly dataPrismCloud: Address;
  readonly dataPrismCloudForwarder: Address;
  readonly token: Address;
  readonly feeController: Address;
}
 
interface NetworkDefinition {
  readonly chainId: number;
  readonly name: string;
  readonly addresses: NetworkAddresses;
}

The SDK references only DataPrismCloud and the Forwarder (plus token / feeController for context). It never touches the core DataPrism contract directly, even slot reads go through DataPrismCloud's read-through getters.

Presets

  • DEMO: chainId 11155111 (Sepolia), name: "demo", bundling the four protocol contract addresses. It is deliberately surfaced to integrators as "demo", not "sepolia", that string is the chainName the API and relayer filter on.
  • NETWORKS: { DEMO }, with NetworkName = keyof typeof NETWORKS.
import { DEMO, NETWORKS } from "@dataprism/sdk";

For a different chain, pass your own NetworkDefinition (custom chainId, name, and addresses). For the canonical deployed addresses, see Deployments.

computeCloudId

Derives a prism's cloudId offline, deterministically, the same formula the contract uses. This is what lets the API (gasless) path know a new prism's ID immediately, without waiting for the relayer.

computeCloudId(cloudAddress: Address, salt: Bytes32): CloudId
// = slice(keccak256(concat([cloudAddress, salt])), 0, 16)

DataPrismClient

A lazy assembler: it builds each sub-client on first access.

new DataPrismClient(network: DataPrismNetwork, options?: DataPrismClientOptions)

DataPrismClientOptions

FieldTypeRole
walletClient?WalletClientsigns / pays gas (required to write or sign)
apiUrl?stringURL of dataprism-api (required when mode: "api")
mode?"wallet" | "api"which execution layer to expose (default "wallet")
execution?ExecutionLayerinject an already-built (e.g. custom) layer

Getters & methods

MemberTypeNeeds a wallet
networkDataPrismNetwork-
readerNetworkReaderno
executionExecutionLayeryes
signerDataPrismSigneryes
prism(standard, cloudId?)PrismManageryes

Accessing .execution / .signer without a walletClient throws an explicit error; so does .execution in api mode without an apiUrl. .reader works with no wallet at all, useful for read-only integrations.

// read-only
const client = new DataPrismClient(network);
const tokens = await client.reader.getPrismTokens(cloudId);
 
// writes (wallet mode)
const client = new DataPrismClient(network, { walletClient });
await (await client.execution.writeData({ cloudId, dataId, payload })).wait();
Copyright © 2026 DataPrism.