pub fn storage_read(key: &[u8]) -> Option<Vec<u8>>
Expand description
Reads the value stored under the given key.
§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_read};
assert!(storage_read(b"key").is_none());
storage_write(b"key", b"value");
assert_eq!(storage_read(b"key").unwrap(), b"value");