# Storage (env)

> NeuroWASM contract storage — get_storage and set_storage with their fuel prices and growth cap, plus planned storage functions.

Source: https://docs.nro.world/neurowasm/storage

Per-contract KV (isolated prefix). Live host uses UTF-8 string keys/values. Writes are fuel-priced and capped.

## `get_storage` <Badge type="tip" text="live" />

```text
get_storage(key_ptr, key_len, val_ptr, val_max) → i32
```

Copies `min(value_len, val_max)` bytes to `val_ptr`. Missing key → length `0`. Bad UTF-8/ptr → `-1`.

**Fuel:** `FUEL_STORAGE_READ_BASE + PER_BYTE × len` (defaults `800 + 5×len`). OOG → `-1`.

**Analogs:** CosmWasm `storage.get`, NEAR `storage_read`.

## `set_storage` <Badge type="tip" text="live" />

```text
set_storage(key_ptr, key_len, val_ptr, val_len)
```

Writes into overlay + `storage_changes`. Denied (no write) on bad UTF-8, OOG, or growth cap.

**Fuel:** `FUEL_STORAGE_WRITE_BASE + PER_BYTE × (key+val)` (defaults `5000 + 50×nbytes`).

**Cap:** cumulative new bytes ≤ `MAX_STATE_GROWTH_BYTES_PER_TX` (64 KiB).

## `remove_storage` <Badge type="info" text="planned" />

```text
remove_storage(key_ptr, key_len) → i32
```

`1` if existed, `0` otherwise.

## `storage_has` <Badge type="info" text="planned" />

```text
storage_has(key_ptr, key_len) → i32
```

## `storage_usage` <Badge type="info" text="planned" />

```text
storage_usage() → i64
```

Total bytes stored by this contract (NEAR-compatible).
