---
description: Gets all storage slots that have been read or written to on an address
---

## `accesses`

### Signature

```solidity
function accesses(address target) external returns (bytes32[] memory reads, bytes32[] memory writes);
```

### Description

Gets all storage slots that have been read (`reads`) or written to (`writes`) on an address since [`record`](/reference/cheatcodes/record) was called.

### Parameters

| Parameter | Type      | Description                                     |
|-----------|-----------|-------------------------------------------------|
| `target`  | `address` | The address to get storage accesses for         |

### Returns

| Parameter | Type        | Description                            |
|-----------|-------------|----------------------------------------|
| `reads`   | `bytes32[]` | Array of storage slots that were read  |
| `writes`  | `bytes32[]` | Array of storage slots that were written |

### Examples

:::code-group

```solidity [test/Accesses.t.sol]
function testAccesses() public {
    vm.record();
    numsContract.num2(); // reads slot 1
    
    (bytes32[] memory reads, bytes32[] memory writes) = vm.accesses(
        address(numsContract)
    );
    
    assertEq(uint256(reads[0]), 1); // slot 1 was read
    assertEq(writes.length, 0);
}
```

```solidity [src/NumsContract.sol]
contract NumsContract {
    uint256 public num1 = 100; // slot 0
    uint256 public num2 = 200; // slot 1
}
```

:::

### Gotchas

:::warning
You must call [`record`](/reference/cheatcodes/record) before calling `accesses`, otherwise the returned arrays will be empty.
:::

:::note
Every write also counts as an additional read. If you write to a slot, it will appear in both the `reads` and `writes` arrays.
:::

### Related Cheatcodes

- [`record`](/reference/cheatcodes/record) - Starts recording storage accesses
