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"]);| 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 chain id |
name | string | the chain name (sent as chainName to the API) |
addresses | NetworkAddresses | the contract 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;
}The SDK references only
DataPrismCloudand theForwarder(plustoken/feeControllerfor context). It never touches the coreDataPrismcontract directly, even slot reads go throughDataPrismCloud'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 thechainNamethe API and relayer filter on.NETWORKS:{ DEMO }, withNetworkName = 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
| Field | Type | Role |
|---|---|---|
walletClient? | WalletClient | signs / pays gas (required to write or sign) |
apiUrl? | string | URL of dataprism-api (required when mode: "api") |
mode? | "wallet" | "api" | which execution layer to expose (default "wallet") |
execution? | ExecutionLayer | inject an already-built (e.g. custom) layer |
Getters & methods
| Member | Type | Needs a wallet |
|---|---|---|
network | DataPrismNetwork | - |
reader | NetworkReader | no |
execution | ExecutionLayer | yes |
signer | DataPrismSigner | yes |
prism(standard, cloudId?) | PrismManager | yes |
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();
