pub fn storage_remove(key: &[u8]) -> bool
Expand description
Removes the value stored under the given key.
If key-value existed returns true
, otherwise false
.
§Use cases
Storage functions are typically used to upgrade/migrate a contract state, preventing errors like Cannot deserialize the contract state
after rolling out the breaking changes to the network.
For practical examples, see different implementations in this repository.
§Examples
use near_sdk::env::{storage_write, storage_remove};
assert_eq!(storage_remove(b"key"), false);
storage_write(b"key", b"value");
assert_eq!(storage_remove(b"key"), true);
Example of usage here