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"]);| Member | Type | Description |
|---|---|---|
definition | NetworkDefinition | the preset it was built from |
chain | Chain | the concrete viem chain (handy for building a walletClient) |
publicClient | PublicClient | a ready-to-read viem client |
chainId | number | the network id |
name | string | the network name (sent as chainName to the API) |
addresses | NetworkAddresses | the platform addresses |
rpcUrls | readonly 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. Itsnameis"demo"; that string is the identifier the API and relayer filter on.NETWORKS:{ DEMO }, withNetworkName = 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): CloudIdDataPrismClient
A lazy assembler: it builds each sub-client on first access.
new DataPrismClient(network: DataPrismNetwork, options?: DataPrismClientOptions)DataPrismClientOptions
| Field | Type | Role |
|---|---|---|
walletClient? | WalletClient | signs and pays network fees (required to write or sign) |
apiUrl? | string | URL of the DataPrism API (required when mode: "api") |
mode? | "wallet" | "api" | which execution layer to expose (default "wallet") |
execution? | ExecutionLayer | inject an already-built (for example custom) layer |
Getters & methods
| Member | Type | Needs an account |
|---|---|---|
network | DataPrismNetwork | no |
reader | NetworkReader | no |
execution | ExecutionLayer | yes |
signer | DataPrismSigner | yes |
prism(standard, cloudId?) | PrismManager | yes |
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();
