Skip to content

Storage Program Standard Calls API #644

@tcsenpai

Description

@tcsenpai

Make storage programs behave like actual programs with granular read/write methods instead of full data blob operations.

Goal: Hybrid approach - Node does heavy lifting (efficient), SDK wraps with nice API.

Read Methods:

  • getAll() - retrocompat, returns full data
  • getFields() - list top-level field names
  • getValue(field) - get specific field value
  • getItem(field, index) - get array element
  • hasField(field) - check field exists
  • getFieldType(field) - get field type

Write Methods (with fee calculation based on size delta):

  • setValue(field, value) - set/create field
  • setItem(field, index, value) - set array element
  • appendItem(field, value) - push to array
  • deleteField(field) - remove field
  • deleteItem(field, index) - remove array element

Safeguards:

  • ACL enforcement on ALL operations (read + write)
  • Binary encoding → error for granular access
  • Non-existent field → error
  • Out-of-bounds array → error
  • appendItem on non-array → error
  • deleteField on missing → error

Fee Model (reuses existing GCRStorageProgramRoutines.ts logic):

  • Granular writes calculate delta bytes
  • delta > 0 → charge proportional storage fee
  • delta ≤ 0 → base tx fee only

Beads Epic: node-9idc

Sub-issues

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions