Skip to content

Commit 92589a6

Browse files
author
tcsenpai
committed
removed overlapping
1 parent fd43d35 commit 92589a6

3 files changed

Lines changed: 77 additions & 927 deletions

File tree

sdk/storage-programs/README.md

Lines changed: 6 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,11 @@ A Storage Program is a deterministic storage container that allows you to:
2626

2727
## Key Features
2828

29-
### 🔐 Flexible Access Control
30-
31-
Choose from four access control modes:
32-
33-
- **Private**: Only the deployer can read and write
34-
- **Public**: Anyone can read, only deployer can write (perfect for public announcements)
35-
- **Restricted**: Only deployer and whitelisted addresses can access
36-
- **Deployer-Only**: Explicit deployer-only mode
37-
38-
### 📦 Generous Storage Limits
39-
40-
- **128KB per Storage Program**: Store substantial amounts of structured data
41-
- **64 levels of nesting**: Deep object hierarchies supported
42-
- **256 character keys**: Descriptive key names
43-
44-
### 🎯 Deterministic Addressing
45-
46-
Storage Program addresses are derived from:
47-
```
48-
address = stor-{SHA256(deployerAddress + programName + salt)}
49-
```
50-
51-
This means you can:
52-
- Generate addresses client-side before creating programs
53-
- Share addresses with users before deployment
54-
- Create predictable, human-readable program names
55-
56-
### ⚡ Efficient Operations
57-
58-
- **Write operations**: Validated and applied via consensus
59-
- **Read operations**: Instant RPC queries (no transaction needed)
60-
- **Update operations**: Merge updates with existing data
61-
- **Delete operations**: Complete removal (deployer-only)
29+
- **Flexible access control**: Four modes cover private, collaborative, and public scenarios. See the [Access Control guide](./access-control.md) for details.
30+
- **Deterministic addressing**: `stor-` identifiers are derived from deployer inputs, so clients can pre-compute addresses before deployment.
31+
- **Consensus-backed writes**: Mutations are validated via consensus while reads are served instantly over RPC.
32+
- **Developer-friendly API**: High-level SDK helpers plus raw RPC endpoints give you control at the right abstraction.
33+
- **Predictable limits**: 128KB payload per program, 64 levels of nesting, 256 character keys.
6234

6335
## How Storage Programs Work
6436

@@ -120,107 +92,7 @@ Storage Programs are stored in the `GCR_Main` table's `data` column (JSONB):
12092

12193
## Use Cases
12294

123-
### 1. User Profiles and Settings
124-
125-
Store user preferences, profile data, and application settings:
126-
127-
```typescript
128-
// Create user profile storage
129-
const profileAddress = await demos.storageProgram.create(
130-
"userProfile",
131-
"private",
132-
{
133-
initialData: {
134-
displayName: "Alice",
135-
avatar: "ipfs://...",
136-
preferences: {
137-
theme: "dark",
138-
language: "en"
139-
}
140-
}
141-
}
142-
)
143-
```
144-
145-
### 2. Shared State Management
146-
147-
Coordinate state across multiple users with controlled access:
148-
149-
```typescript
150-
// Game lobby with restricted access
151-
const lobbyAddress = await demos.storageProgram.create(
152-
"gameLobby1",
153-
"restricted",
154-
{
155-
allowedAddresses: [player1, player2, player3],
156-
initialData: {
157-
status: "waiting",
158-
players: [],
159-
settings: { maxPlayers: 4, gameMode: "classic" }
160-
}
161-
}
162-
)
163-
```
164-
165-
### 3. Public Announcements
166-
167-
Publish read-only data that anyone can access:
168-
169-
```typescript
170-
// Project announcements
171-
const announcementsAddress = await demos.storageProgram.create(
172-
"projectAnnouncements",
173-
"public",
174-
{
175-
initialData: {
176-
latest: "Latest release shipped!",
177-
updates: []
178-
}
179-
}
180-
)
181-
```
182-
183-
### 4. Configuration Management
184-
185-
Store application configuration data:
186-
187-
```typescript
188-
// App configuration
189-
const configAddress = await demos.storageProgram.create(
190-
"appConfig",
191-
"deployer-only",
192-
{
193-
initialData: {
194-
apiEndpoints: ["https://api1.example.com", "https://api2.example.com"],
195-
featureFlags: {
196-
betaFeatures: false,
197-
newUI: true
198-
}
199-
}
200-
}
201-
)
202-
```
203-
204-
### 5. Collaborative Documents
205-
206-
Multiple users collaborating on shared data:
207-
208-
```typescript
209-
// Shared document
210-
const docAddress = await demos.storageProgram.create(
211-
"sharedDoc",
212-
"restricted",
213-
{
214-
allowedAddresses: [user1, user2, user3],
215-
initialData: {
216-
title: "Project Proposal",
217-
content: "",
218-
lastEdit: Date.now(),
219-
editors: []
220-
}
221-
}
222-
)
223-
```
95+
Looking for implementation-ready patterns? Jump to the [Storage Program Cookbook](../cookbook/storage-programs/examples.md) for end-to-end recipes covering announcements, team workspaces, user profiles, and more. This overview keeps the focus on concepts so each scenario has a single canonical home.
22496

22597
## Comparison with Other Storage Solutions
22698

sdk/storage-programs/getting-started.md

Lines changed: 6 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -119,38 +119,14 @@ Reading data is **free** and doesn't require a transaction:
119119
```typescript
120120
// Read all data
121121
const allData = await demos.storageProgram.read(storageAddress)
122-
console.log('All data:', allData.data)
123-
console.log('Metadata:', allData.metadata)
122+
console.log('All data:', allData.data.variables)
124123

125124
// Read specific key
126125
const username = await demos.storageProgram.read(storageAddress, 'username')
127126
console.log('Username:', username)
128127
```
129128

130-
**Read Response Structure**:
131-
```typescript
132-
{
133-
success: true,
134-
data: {
135-
variables: {
136-
username: "alice",
137-
email: "alice@example.com",
138-
preferences: { theme: "dark", notifications: true },
139-
bio: "Web3 developer...",
140-
socialLinks: { twitter: "@alice_demos", github: "alice" }
141-
},
142-
metadata: {
143-
programName: "myFirstProgram",
144-
deployer: "0xabc123...",
145-
accessControl: "private",
146-
allowedAddresses: [],
147-
created: 1706745600000,
148-
lastModified: 1706745700000,
149-
size: 2048
150-
}
151-
}
152-
}
153-
```
129+
Need more detail on pagination, caching, or response formats? The [RPC Queries guide](./rpc-queries.md) covers the full schema and performance advice.
154130

155131
## Complete Example
156132

@@ -224,69 +200,11 @@ async function main() {
224200
main().catch(console.error)
225201
```
226202

227-
## Common Patterns
228-
229-
### Creating Public Storage (Announcements)
230-
231-
```typescript
232-
const announcementAddress = await demos.storageProgram.create(
233-
"projectAnnouncements",
234-
"public", // Anyone can read, only you can write
235-
{
236-
initialData: {
237-
latest: "Latest release shipped!",
238-
updates: [
239-
{ date: Date.now(), message: "Initial release" }
240-
]
241-
}
242-
}
243-
)
244-
```
245-
246-
### Creating Restricted Storage (Team Collaboration)
247-
248-
```typescript
249-
const teamStorage = await demos.storageProgram.create(
250-
"teamWorkspace",
251-
"restricted",
252-
{
253-
allowedAddresses: [
254-
"0xteamMember1...",
255-
"0xteamMember2...",
256-
"0xteamMember3..."
257-
],
258-
initialData: {
259-
projectName: "DeFi Dashboard",
260-
tasks: []
261-
}
262-
}
263-
)
264-
```
265-
266-
### Updating Access Control
203+
## Where to Go Next
267204

268-
```typescript
269-
// Add new team member to restricted storage
270-
await demos.storageProgram.updateAccessControl(
271-
storageAddress,
272-
{
273-
allowedAddresses: [
274-
"0xteamMember1...",
275-
"0xteamMember2...",
276-
"0xteamMember3...",
277-
"0xnewMember..." // New member added
278-
]
279-
}
280-
)
281-
282-
// Change access mode
283-
await demos.storageProgram.updateAccessControl(
284-
storageAddress,
285-
{
286-
accessControl: "public" // Change from restricted to public
287-
}
288-
)
289-
```
205+
- Master permissions in the [Access Control guide](./access-control.md).
206+
- Dive deeper into each operation in the [Operations guide](./operations.md).
207+
- Explore practical recipes in the [Storage Program Cookbook](../cookbook/storage-programs/examples.md).
290208

291209
## Troubleshooting
292210

0 commit comments

Comments
 (0)