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

Stores slice into storage, in slots of 32 bytes, starting at the slot.

Additional Information

If slice is empty (i.e., has a length of zero), storage access will still occur,
but no content slots will be written to. The length of the slice in the storage will be set
to zero, but eventual existing content of the slice in storage will not be cleared.

Arguments

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

Number of Storage Accesses

  • Reads: 1 (to read the existing data in the slice length slot)
  • Writes: 2 (one for the length of the slice, and one for the slice content)

Examples

use std::{alloc::alloc_bytes, storage::{write_slice_quads, read_slice_quads}};

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