pub fn write_slice(key: b256, slice: raw_slice) 
Expand description

Store a raw_slice from the heap into storage.

Arguments

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

Number of Storage Accesses

  • Writes: 2

Examples

use std::{alloc::alloc_bytes, storage::{write_slice, read_slice}};

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