Global Storage Operations
Move programs can create
, delete
, and update
resources in global storage using the following five instructions:
Operation | Description | Aborts? |
---|---|---|
| Publish | If |
| Remove | If |
| Return a mutable reference to the | If |
| Return an immutable reference to the | If |
| Return | Never |
Each of these instructions is parameterized by a type T
with the key
ability. However, each type T
must be declared in the current module. This ensures that a resource can only be manipulated via the API exposed by its defining module. The instructions also take either an address &signer
representing the account address where the resource of type T
is stored.
In the counter
example, you might have noticed that the get_count
, increment
, reset
, and delete
functions are annotated with acquires Counter
. A Move function m::f
must be annotated with acquires T
if and only if:
The body of
m::f
contains amove_from<T>
,borrow_global_mut<T>
, orborrow_global<T>
instruction, orThe body of
m::f
invokes a functionm::g
declared in the same module that is annotated withacquires.
Last updated