# Account Structure

On ENI, accounts are represented by two address formats:

* ENI **native Bech32** (`eni...`)
* **EVM-compatible Hex** (`0x...`)

Both addresses for a single account are derived from the same **public key**.Because eni is fully compatible with Ethereum and the Ethereum ecosystem is prosperous, it is recommended to use an eth address.

***

#### Deriving Addresses from Public Key

**ENI Address Derivation**

**ENI native addresses** are derived from the **public key** using the following steps:

1. Hash the public key using the `Keccak256` algorithm.
2. Extract the **first 20 bytes** of the resulting hash.
3. Encode the extracted bytes in **Bech32 format** with the **"eni" prefix.**

Example implementation:

```ts
import { bech32 } from 'bech32';
import { keccak256 } from 'ethereumjs-util';

export function deriveEniAddress(publicKey: Buffer): string {
  const hash = keccak256(publicKey);
  const words = bech32.toWords(hash.slice(0, 20));
  return bech32.encode('eni', words);
}
```

#### **EVM Address Derivation**

The EVM-compatible address is derived as follows:

1. Hash the public key using the `Keccak256` algorithm.
2. Extract the **last 20 bytes** of the resulting hash.
3. Prefix the extracted bytes with `0x` to obtain the EVM address.

Example implementation:

```ts
import { keccak256 } from 'ethereumjs-util';

export function deriveEVMAddress(publicKey: Buffer): string {
  const hash = keccak256(publicKey);
  return `0x${hash.slice(-20).toString('hex')}`;
}
```

#### **Summary**

* **Public Key Hash**：Both address derivations rely on the **Keccak256 hashing algorithm**.
* **ENI Address**：
  * Extracts the **first 20 bytes** of the hash.
  * Encodes these bytes into **Bech32 format** with the **"eni" prefix**.
* **EVM Address**：
  * Extracts the **last 20 bytes** of the hash.
  * Formats these bytes as **Hex** with the **"0x" prefix**.

#### **Why This Works**

`Keccak256` **hashing** ensures that the process of deriving both address formats from the same public key is **consistent and verifiable**.

This mechanism enables a **single account** to remain **compatible** in both **ENI native** and **EVM environments**.

***

#### **Next Steps**

For a detailed technical explanation on how to perform **account linking**, please refer to the **Wallet Linking** section.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.eniac.network/getting-started/quickstart/account-structure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
