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

# Addresses

> Quai and Qi address utilities.

## Overview

**Addresses are a fundamental part of interacting with Quai Network**. They represent the global identity of Externally Owned Accounts (accounts backed by a private key), contracts, and UTXO wallets.

These functions help convert between various formats, validate addresses across the Quai and Qi address spaces, and other utilities for working with addresses.

The Quais SDK supports the following address formats:

* **Quai addresses**: Account ledger addresses
* **Qi addresses**: UTXO ledger addresses

Quai and Qi addresses utilize a [sharded address space](/learn/advanced-introduction/hierarchical-structure/sharding#sharded-address-space) to allow nodes and wallets to quickly identify which chain and ledger an address resides on. The first 9 bits of every address is the binary identification prefix, of which the first 8 bits are the chain identifiers, and the last bit is the ledger identifier.

| bits 0-3      | bits 4-7    | bit 8             |
| ------------- | ----------- | ----------------- |
| region number | zone number | ledger identifier |

The following addresses are examples to illustrate how the binary identification prefixes work in practice.

| Address                                    | Region    | Zone    | Ledger |
| ------------------------------------------ | --------- | ------- | ------ |
| 0x000DEADBEEFCAFE0000000000000000000000000 | region-0  | zone-0  | Quai   |
| 0x2A40000DEADBEEFCAFE000000000000000000000 | region-2  | zone-10 | Quai   |
| 0xFF700000000DEADBEEFCAFE00000000000000000 | region-15 | zone-15 | Quai   |
| 0x008000000000000DEADBEEFCAFE0000000000000 | region-0  | zone-0  | Qi     |
| 0xF3F0000000000000000DEADBEEFCAFE000000000 | region-15 | zone-3  | Qi     |

## Usage

Most commonly, the provided address utilities are used to validate addresses in the Quai and Qi address spaces.

### Validate a Quai address

To validate a Quai address, you can use the [isQuaiAddress](/content/functions/isQuaiAddress) function, which returns `true` if the address is in the Quai ledger scope, and `false` otherwise.

```ts theme={null}
import { isQuaiAddress } from 'quais'

const address = '0x8ba1f109551bD432803012645Ac136ddd64DBA72'

if (isQuaiAddress(address)) {
	console.log('This is a valid Quai address')
} else {
	console.log('This is not a valid Quai address')
}
```

### Validate a Qi address

In the case of Qi addresses, you can use the [isQiAddress](/content/functions/isQiAddress) function, which returns `true` if the address is in the Qi ledger scope, and `false` otherwise.

```ts theme={null}
import { isQiAddress } from 'quais'

const address = '0x8ba1f109551bD432803012645Ac136ddd64DBA72'

if (isQiAddress(address)) {
	console.log('This is a valid Qi address')
} else {
	console.log('This is not a valid Qi address')
}
```
