pub fn clear_slice(key: b256) -> bool 
Expand description

Clear a sequence of storage slots starting at a some key.

Arguments

  • key: [b256] - The key of the first storage slot that will be cleared

Returns

  • [bool] - Indicates whether all of the storage slots cleared were previously set.

Number of Storage Accesses

  • Reads: 1
  • Clears: 2

Examples

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

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