Storage Architecture
Sui uses a versioned object storage model where:Object-Based
Each object is stored independently with its own version
Content-Addressed
Objects are referenced by ID and version number
Permanent History
All object versions are retained for historical queries
Direct Access
Objects can be read directly without scanning
Object Serialization
Objects are stored as BCS (Binary Canonical Serialization) bytes:Object Layout
The first 32 bytes of an object’s contents are always its ID:This predictable layout allows Sui to efficiently extract object IDs without deserializing the entire object.
Storage Costs
Sui implements a storage fund mechanism to ensure sustainable long-term storage:Storage Rebate System
From the storage fund implementation:How Storage Charges Work
- Creating Objects
- Modifying Objects
- Deleting Objects
When you create an object, you pay for its storage:This cost is held in the storage fund as a rebate for when the object is deleted.
Object Size Limits
Sui enforces maximum object sizes to ensure efficient processing:System Object Exception
allow_unbounded_system_objects is enabled.
Optimized Storage for Coins
Coins have a special optimized storage format:Why Coins are Special
Why Coins are Special
Coins always have a fixed 40-byte structure:
- 32 bytes: Object ID
- 8 bytes: Balance (u64)
Dynamic Fields and Storage
Dynamic fields are stored as separate child objects:Storage Benefits
Bypass Size Limits
Store unlimited data by splitting across dynamic fields
Efficient Updates
Modify individual fields without touching parent object
Selective Loading
Load only the fields you need
Granular Rebates
Receive storage rebates when removing fields
Storage Patterns
Small Objects
For small, frequently accessed data, use direct struct fields:Large Collections
For large collections, use dynamic fields or Table:Hierarchical Data
For nested structures, use object wrapping or dynamic object fields:Object Versioning
Sui maintains a complete version history of all objects:Querying Historical State
You can query any past version of an object if you know its version number. This is useful for:- Auditing changes
- Replaying transactions
- Historical analysis
- Debugging
Storage Best Practices
Minimize object size
Minimize object size
Smaller objects mean lower storage costs:
Use appropriate data structures
Use appropriate data structures
Choose the right structure for your access patterns:
- Direct fields: Fast, fixed-size data
- Dynamic fields: Flexible, variable-size data
- Table: Large key-value collections
- Bag: Heterogeneous collections
Clean up unused objects
Clean up unused objects
Delete objects when no longer needed to recover storage rebates:
Consider off-chain storage
Consider off-chain storage
For large data (images, documents), store only URLs or hashes on-chain:
Storage Fund Economics
- Total Object Storage Rebates: Sum of all storage rebates for active objects
- Non-Refundable Balance: Accumulated fees that fund long-term storage
Related Topics
Objects
Understand the object model
Dynamic Fields
Extend objects at runtime
Gas Mechanism
Learn about gas and storage costs