Ability: Store
The key ability requires all fields to have store, which defines what the store ability means: it is the ability to serve as a field of an Object. A struct with copy or drop but without store can never be stored. A type with key but without store cannot be wrapped - used as a field—in another object, and is constrained to always remain at the top level.
Definition
The store ability allows a type to be used as a field in a struct with the key ability.
/// Extra metadata with `store`; all fields must have `store` as well!
public struct Metadata has store {
bio: String,
}
/// An object for a single user record.
public struct User has key {
id: UID,
name: String, // String has `store`
age: u8, // All integers have `store`
metadata: Metadata, // Another type with the `store` ability
}
Relation to copy and drop
All three non-key abilities can be used in any combination.
Relation to key
An object with the store ability can be stored in other objects.
While not a language or verifier feature, store acts as a public modifier on a struct, allowing calling public transfer functions which do not have an internal constraint.
Types with the store Ability
All native types (except references) in Move have the store ability. This includes:
All of the types defined in the standard library have the store ability as well. This includes:
Further Reading
- Type Abilities in the Move Reference.