Function std::storage::storage_api::read
pub fn read<T>(slot: b256, offset: u64) -> Option<T> Expand description
Reads a value of type T starting at the location specified by slot and offset. If the
value crosses the boundary of a storage slot, reading continues at the following slot.
Arguments
slot: [b256] - The storage slot to load the value from.offset: [u64] - An offset, in words, from the start ofslot, from which the value should be read.
Returns
- [Option] -
Option(value)if the storage slots read were valid and containvalue. Otherwise,
returnsNone.
Number of Storage Accesses
- Reads:
1
Examples
use std::storage::storage_api::{read, write};
fn foo() {
let five = 5_u64;
write(b256::zero(), 2, five);
let stored_five = read::<u64>(b256::zero(), 2);
assert(five == stored_five.unwrap());
}