Skip to content
19 changes: 19 additions & 0 deletions docs/book/src/reference/compiler_intrinsics.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@

# Compiler Intrinsics

## `__state_clear`

**Type Signature**:

## `__state_clear() -> bool`

The `__state_clear` intrinsic function is used to clear all entries in the contract's storage. It removes all key-value pairs from the storage, effectively resetting the contract's state to its initial empty condition. This intrinsic returns a boolean value: `true` if the operation was successful, and `false` if it failed for any reason.

### Example

```sway
fn reset_contract_storage() -> bool {
// Clear all storage and return the result
__state_clear()
}

```

The Sway compiler supports a list of intrinsics that perform various low level operations that are useful for building libraries. Compiler intrinsics should rarely be used but are preferred over `asm` blocks because they are type-checked and are safer overall. Below is a list of all available compiler intrinsics:

---
Expand Down