This example demonstrates how to use the storage capabilities of Neo N3 smart contracts. It provides comprehensive examples of various storage operations, data types, and patterns for persistent data management on the Neo blockchain.
- Storage operations (Put, Get, Delete)
- Multiple data type handling (bytes, strings, integers, booleans)
- Storage map implementations
- Serialization and deserialization of complex objects
- Storage iteration and search functionality
The SampleStorage contract demonstrates several Neo N3 storage features:
StorageMapusage for organized data storage- Prefix-based storage segregation using byte, string, and byte array prefixes
- Index-based property access for storage
The example includes methods for storing and retrieving various data types:
- Byte arrays (basic and arrays larger than 16 bytes)
- Strings
- Integers
- Booleans
- UInt160 values
- UInt256 values
- ECPoint values
- Custom serialized objects
Storage.Findfor prefix-based searching- Iterator patterns for processing multiple storage entries
- Storage context management
- Read-only operations
The example demonstrates several important storage patterns:
- Direct Storage: Using the Storage class directly
- StorageMap: Using maps for organized, prefix-based storage
- Index Properties: Accessing storage through property-like syntax
- Serialization: Storing and retrieving complex objects
This contract serves as a reference implementation for:
- Building data-intensive Neo smart contracts
- Implementing persistent state in decentralized applications
- Optimizing storage operations for gas efficiency
- Handling complex data structures on-chain
The example illustrates several key performance aspects:
- Efficient storage key design
- Proper handling of large byte arrays
- Serialization patterns for complex data
- Prefix-based data organization
This example teaches:
- Fundamental Neo N3 storage concepts
- Best practices for on-chain data management
- Various techniques for working with different data types
- Iteration and search patterns for blockchain storage
The storage patterns demonstrated in this example are applicable to:
- Token contracts requiring balance tracking
- Voting and governance systems
- Game state management
- Record-keeping applications
- Multi-signature wallets
- Any application requiring persistent state