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

Client & networks

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

DataPrismNetwork

Encapsulates where you talk. The current network implementation is EVM-based, so 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 network id
namestringthe network name (sent as chainName to the API)
addressesNetworkAddressesthe platform 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;
}

Presets

  • DEMO: the demo environment, bundling the platform addresses for the test network. Its name is "demo"; that string is the identifier the API and relayer filter on.
  • NETWORKS: { DEMO }, with NetworkName = keyof typeof NETWORKS.
import { DEMO, NETWORKS } from "@dataprism/sdk";

For another environment, pass your own NetworkDefinition with its id, name, and addresses.

computeCloudId

Derives a prism's cloudId offline, deterministically, with the same formula the platform uses. This is what lets the delegated (fee-free) path know a new prism's ID immediately, without waiting for the relayer.

computeCloudId(cloudAddress: Address, salt: Bytes32): CloudId

DataPrismClient

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

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

DataPrismClientOptions

FieldTypeRole
walletClient?WalletClientsigns and pays network fees (required to write or sign)
apiUrl?stringURL of the DataPrism API (required when mode: "api")
mode?"wallet" | "api"which execution layer to expose (default "wallet")
execution?ExecutionLayerinject an already-built (for example custom) layer

Getters & methods

MemberTypeNeeds an account
networkDataPrismNetworkno
readerNetworkReaderno
executionExecutionLayeryes
signerDataPrismSigneryes
prism(standard, cloudId?)PrismManageryes

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

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