storage¶
- class FindOptions(value)¶
Bases:
enum.IntFlag
An enumeration.
- NONE = 0¶
- KEYS_ONLY = 1¶
- REMOVE_PREFIX = 2¶
- VALUES_ONLY = 4¶
- DESERIALIZE_VALUES = 8¶
- PICK_FIELD_0 = 16¶
- PICK_FIELD_1 = 32¶
- class StorageContext¶
Bases:
object
The storage context used to read and write data in smart contracts.
- create_map(prefix: bytes) → boa3.builtin.interop.storage.storagemap.StorageMap¶
Creates a storage map with the given prefix.
- Parameters
prefix (bytes) – the identifier of the storage map
- Returns
a map with the key-values in the storage that match with the given prefix
- Return type
- as_read_only() → boa3.builtin.interop.storage.storagecontext.StorageContext¶
Converts the specified storage context to a new readonly storage context.
- Returns
current StorageContext as ReadOnly
- Return type
- class StorageMap(context, prefix: bytes)¶
Bases:
object
The key-value storage for the specific prefix in the given storage context.
- get(key: bytes, context: Optional[boa3.builtin.interop.storage.storagecontext.StorageContext] = None) → bytes¶
Gets a value from the persistent store based on the given key.
- Parameters
key (bytes) – value identifier in the store
context (StorageContext) – storage context to be used
- Returns
the value corresponding to given key for current storage context
- Return type
- get_context() → boa3.builtin.interop.storage.storagecontext.StorageContext¶
Gets current storage context.
- Returns
the current storage context
- Return type
- get_read_only_context() → boa3.builtin.interop.storage.storagecontext.StorageContext¶
Gets current read only storage context.
- Returns
the current read only storage context
- Return type
- put(key: bytes, value: Union[int, bytes, str], context: Optional[boa3.builtin.interop.storage.storagecontext.StorageContext] = None)¶
Inserts a given value in the key-value format into the persistent storage.
- Parameters
key (bytes) – the identifier in the store for the new value
context (StorageContext) – storage context to be used
- delete(key: bytes, context: Optional[boa3.builtin.interop.storage.storagecontext.StorageContext] = None)¶
Removes a given key from the persistent storage if exists.
- Parameters
key (bytes) – the identifier in the store for the new value
context (StorageContext) – storage context to be used
- find(prefix: bytes, context: Optional[boa3.builtin.interop.storage.storagecontext.StorageContext] = None, options: boa3.internal.neo3.contracts.findoptions.FindOptions = <FindOptions.NONE: 0>) → boa3.builtin.interop.iterator.Iterator¶
Searches in the storage for keys that start with the given prefix.
- Parameters
prefix (bytes) – prefix to find the storage keys
context (StorageContext) – storage context to be used
options (FindOptions) – the options of the search
- Returns
an iterator with the search results
- Return type
StorageContext¶
- class StorageContext¶
Bases:
object
The storage context used to read and write data in smart contracts.
- create_map(prefix: bytes) → boa3.builtin.interop.storage.storagemap.StorageMap¶
Creates a storage map with the given prefix.
- Parameters
prefix (bytes) – the identifier of the storage map
- Returns
a map with the key-values in the storage that match with the given prefix
- Return type
- as_read_only() → boa3.builtin.interop.storage.storagecontext.StorageContext¶
Converts the specified storage context to a new readonly storage context.
- Returns
current StorageContext as ReadOnly
- Return type
StorageMap¶
- class StorageMap(context, prefix: bytes)¶
Bases:
object
The key-value storage for the specific prefix in the given storage context.