Storage Program Operations
Warning: Storage Programs are still being developed; this documentation is a preview and might not work correctly.This guide explains how each Storage Program operation fits into an end-to-end workflow. For method signatures, payload schemas, and error codes, rely on the API Reference. For concrete implementation patterns, see the Storage Program Cookbook.
Operation Overview
| Operation | Transaction? | Who Can Execute | Typical Use |
|---|---|---|---|
create | ✅ Yes | Any deployer | Provision a new storage namespace with optional data |
write | ✅ Yes | Deployer + allowed addresses | Merge updates into existing data |
read | ❌ No (RPC) | According to access mode | Fetch storage content or metadata |
updateAccessControl | ✅ Yes | Deployer only | Change access mode and/or allowlist |
delete | ✅ Yes | Deployer only | Remove a storage program and its data |
Create
Goal: Materialise a deterministicstor- address on-chain and (optionally) seed initial state.
Workflow
- Derive the address client-side (reuse salts if you need different versions).
- Validate payload size (
<128KB) and nesting before submitting a transaction. - Submit
createwith the desired access mode and optionalallowedAddresses. - Wait for consensus confirmation if the caller depends on the program immediately.
- Restricted mode must include at least one allowlisted address.
- Decide whether to encrypt sensitive fields up front; the network stores JSON as-is.
Write
Goal: Merge new key/value pairs or nested data into the existing JSON document. Workflow- Fetch current state if you need to apply deltas (reads are free).
- Construct a payload that only includes the keys you intend to update.
- Submit a
writetransaction; consensus will merge it with the existing document. - Optionally re-read to confirm the write and update caches or UI state.
- Combined data size after merge must remain under 128KB.
- Callers must satisfy access control (deployer or allowlisted address).
- Consider optimistic UI updates paired with a rollback path for failures.
Read
Goal: Retrieve storage variables or metadata over RPC with no transaction cost. Workflow- Use
read(address)for the full document orread(address, key)for scoped lookups. - Cache aggressively—responses include
metadata.lastModifiedso you can detect changes. - Parallelise reads across addresses using
Promise.allwhen fetching many programs.
- Ensure the caller has read permission under the current access mode.
- Treat responses as eventually consistent; pair with webhooks/polling if you need freshness.
Update Access Control
Goal: Switch access modes or adjust the allowlist for restricted programs. Workflow- Read
metadatato confirm deployer address and current configuration. - Build the desired change:
accessControl: "private" | "public" | "restricted" | "deployer-only"allowedAddresses: string[](complete list, not patches)
- Submit the
updateAccessControltransaction. - Notify affected clients (e.g., flush caches, inform collaborators).
- Only the deployer may call this method.
- Restricted mode requires a non-empty allowlist.
- When opening data (restricted → public), review contents to avoid leaking secrets.
Delete
Goal: Remove an entire Storage Program, including variables and metadata. Workflow- Confirm that no downstream systems rely on the existing data (deletion is irreversible).
- Submit a
deletetransaction from the deployer address. - Update any application indexes or caches that referenced the storage address.
- Only the deployer can delete.
- Communicate the removal to collaborators or users to prevent dangling references.