> ## Documentation Index
> Fetch the complete documentation index at: https://docs.starknet.io/llms.txt
> Use this file to discover all available pages before exploring further.

# core::starknet::storage_access::Store

Trait for types that can be stored in Starknet contract storage.
The `Store` trait enables types to be stored in and retrieved from Starknet's contract storage.
Cairo implements `Store` for most primitive types. However, collection types (arrays, dicts,
etc.) do not implement `Store` directly. Instead, use specialized storage types, such as [`Vec`](./core-starknet-storage-vec-Vec)
or [`Map`](./core-starknet-storage-map-Map).

## Signature

```rust theme={null}
pub trait Store
```

## Derivation

To make a type storable in contract storage, simply derive the `Store` trait:

```rust theme={null}
#[derive(Drop, starknet::Store)]
struct Sizes {
    tiny: u8,    // 8 bits
    small: u32,  // 32 bits
    medium: u64, // 64 bits
}
```

This allows the `Size` struct to be stored in a contract's storage.
There's no real reason to implement this trait yourself, as it can be trivially derived.
For efficiency purposes, consider manually implementing [`StorePacking`](./core-starknet-storage_access-StorePacking) to optimize storage
usage.

## Trait functions

### read

Reads a value from storage at the given domain and base address.

#### Arguments

* `address_domain` - The storage domain (currently only 0 is supported)
* `base` - The base storage address to read from

#### Signature

```rust theme={null}
fn read(address_domain: u32, base: StorageBaseAddress) -> Result>
```

### write

Writes a value to storage at the given domain and base address.

#### Arguments

* `address_domain` - The storage domain (currently only 0 is supported)
* `base` - The base storage address to write to
* `value` - The value to store

#### Signature

```rust theme={null}
fn write(
    address_domain: u32, base: StorageBaseAddress, value: T,
) -> Result>
```

### read\_at\_offset

Reads a value from storage at a base address plus an offset.

#### Arguments

* `address_domain` - The storage domain (currently only 0 is supported)
* `base` - The base storage address
* `offset` - The offset from the base address where the value should be read

#### Signature

```rust theme={null}
fn read_at_offset(
    address_domain: u32, base: StorageBaseAddress, offset: u8,
) -> Result>
```

### write\_at\_offset

Writes a value to storage at a base address plus an offset.

#### Arguments

* `address_domain` - The storage domain (currently only 0 is supported)
* `base` - The base storage address
* `offset` - The offset from the base address where the value should be written
* `value` - The value to store

#### Signature

```rust theme={null}
fn write_at_offset(
    address_domain: u32, base: StorageBaseAddress, offset: u8, value: T,
) -> Result>
```

### size

Returns the size in storage for this type.
This is bounded to 255, as the offset is a u8. As such, a single type can only take up to
255 slots in storage.

#### Signature

```rust theme={null}
fn size() -> u8
```

### scrub

Clears the storage area by writing zeroes to it.

#### Arguments

* `address_domain` - The storage domain
* `base` - The base storage address to start clearing
* `offset` - The offset from the base address where clearing should start

The operation writes zeroes to storage starting from the specified base address and offset,
and continues for the size of the type as determined by the `size()` function.

#### Signature

```rust theme={null}
fn scrub(
    address_domain: u32, base: StorageBaseAddress, offset: u8,
) -> Result>
```
