> For the complete documentation index, see [llms.txt](https://whs3-doge5k.gitbook.io/smartcontract-security-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whs3-doge5k.gitbook.io/smartcontract-security-docs/basics/3.-evm/evm-2/undefined/uint-n-bytes-n-bool-n-address-n.md).

# uint\[n], bytes\[n], bool\[n], address\[n]

{% hint style="info" %}
배열의 크기가 정해진 경우는 정적 타입으로 간주한다.
{% endhint %}

### **특징**

| 항목           | 설명                                                                                  |
| ------------ | ----------------------------------------------------------------------------------- |
| **타입**       | 정적 타입 (크기 고정)                                                                       |
| **크기**       | n x 변수 바이트                                                                          |
| **슬롯 사용 방식** | <p>변수의 크기에 따라 결정됨:<br>– uint256\[3] → 3개 슬롯 사용<br>– bool\[3] → 1개 슬롯 안에 packing</p> |
| **패킹 여부**    | <p>대부분은 packing 안됨<br>단, bool\[n], uint8\[n], bytes1\[n] 등은 packing 발생</p>          |
| **접근 방식**    | array\[i] → base\_slot + i 방식으로 접근(packing이 없을 경우)                                  |

***

### **예시 1**

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Example6 {
    uint[3] public nums;

    constructor() {
        nums[0] = 10;
        nums[1] = 20;
        nums[2] = 30;
    }
}
```

<figure><img src="https://2462457462-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLf9vwRuaws92ULgGvzTi%2Fuploads%2FnglRhREDkYyFo9TLTUqS%2Fimage.png?alt=media&amp;token=f55e952d-dae5-4e8b-8f44-ad7b708fb4e8" alt=""><figcaption></figcaption></figure>

```
// 스토리지

address: 0x0000000000000000000000000000000000000000000000000000000000000000
0x000000000000000000000000000000000000000000000000000000000000000a

address: 0x0000000000000000000000000000000000000000000000000000000000000001
0x0000000000000000000000000000000000000000000000000000000000000014

address: 0x0000000000000000000000000000000000000000000000000000000000000002
0x000000000000000000000000000000000000000000000000000000000000001e
```

슬롯 0, 1, 2에 각각 uint\[0], uint\[1], uint\[2] 값이 저장되었다.

* nums\[0]: 0x000000000000000000000000000000000000000000000000000000000000000a
* nums\[1]: 0x0000000000000000000000000000000000000000000000000000000000000014
* nums\[2]: 0x000000000000000000000000000000000000000000000000000000000000001e

고정된 배열은 각각 독립적인 슬롯 하나를 할당 받는다.

***

### **예시 2**

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Example7 {
    bool[3] public flags;

    constructor() {
        flags[0] = true;
        flags[1] = false;
        flags[2] = true;
    }
}
```

<figure><img src="https://2462457462-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLf9vwRuaws92ULgGvzTi%2Fuploads%2F7fOB9bjq0URemNZBAbww%2Fimage.png?alt=media&amp;token=ee0fd5e4-7547-466a-aeab-5a822b196d5b" alt=""><figcaption></figcaption></figure>

```
address: 0x0000000000000000000000000000000000000000000000000000000000000000
0x0000000000000000000000000000000000000000000000000000000000010001
```

bool 타입 배열은 하나의 슬롯에 packing 된다.

* flags\[0] = 0x01
* flags\[1] = 0x02
* flags\[2] = 0x01

***

### **예시 3**

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Example8 {
    address[3] public addresses;

    constructor() {
        addresses[0] = msg.sender;
        addresses[1] = tx.origin;
        addresses[2] = msg.sender;
    }
}
```

<figure><img src="https://2462457462-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLf9vwRuaws92ULgGvzTi%2Fuploads%2F4hEWGskdmSwxANpVNS8I%2Fimage.png?alt=media&amp;token=64acdb5b-449b-42c1-9438-bb29ca17a289" alt=""><figcaption></figcaption></figure>

```
address: 0x0000000000000000000000000000000000000000000000000000000000000000
0x0000000000000000000000005a933567a53548b7dcb37df4af2d4b6816a476e4

address: 0x0000000000000000000000000000000000000000000000000000000000000001
0x0000000000000000000000005a933567a53548b7dcb37df4af2d4b6816a476e4

address: 0x0000000000000000000000000000000000000000000000000000000000000002
0x0000000000000000000000005a933567a53548b7dcb37df4af2d4b6816a476e4
```

address 타입 배열은 각각 개별 슬롯을 할당받는다.

base slot + i 인덱스를 통해 각각의 address 배열 값에 접근할 수 있다.
