pub fn write_slice_slot(slot: b256, slice: raw_slice) 
Expand description

Stores slice into storage, in a single dynamic storage slot.

Additional Information

If slice is empty (i.e., has a length of zero), storage access will still occur.
The slot will be marked as occupied and storing a content of length zero.
Any eventual existing content of the slice in storage will be deleted.

Arguments

  • slot: [b256] - The storage slot at which slice will be stored.
  • slice: [raw_slice] - The raw_slice to be stored.

Number of Storage Accesses

  • Writes: 1 (for storing the slice content)

Examples

use std::{alloc::alloc_bytes, storage::{write_slice_slot, read_slice_slot}};

fn foo() {
    let slice = asm(ptr: (alloc_bytes(1), 1)) { ptr: raw_slice };
    assert(read_slice_slot(b256::zero()).is_none());
    write_slice_slot(b256::zero(), slice);
    let stored_slice = read_slice_slot(b256::zero()).unwrap();
    assert_eq(slice, stored_slice);
}