# Name processing

When interacting with Nad Name Service smart-contracts directly, note that names are not stored in their human readable format. We must process the name before it can be used by a smart-contract by execute below steps **in order**:

* Name normalization
* Name hash

### Name normalization

Normalization is the process of standardizing a name before passing it through the Namehash algorithm. It's crucial to normalize all input consistently, as even a small variation, such as a difference between uppercase and lowercase letters, can result in a completely different namehash.

For example,  `Salmo.Nad` normalizes to `salmo.nad`. This ensures that no matter how the user types in the name, the correct node is used.

Using `viem:`

{% code lineNumbers="true" %}

```typescript
import { normalize } from 'viem/ens'

const normalizedName = normalize('Salmo.Nad') 
// => salmo.nad
```

{% endcode %}

Using `ethersjs(v6):`

<pre class="language-typescript" data-line-numbers><code class="lang-typescript">import { ensNormalize, namehash } from "ethers/hash";

<strong>const normalizedName = ensNormalize('Salmo.Nad')
</strong><strong>// => salmo.nad
</strong></code></pre>

### Namehash

{% hint style="info" %}
You must normalize names before creating a namehash.
{% endhint %}

In NNS core smart-contracts, names are stored as a hash instead of the raw string for optimization purpose. The hashed value is called a `node` , which is a hex-encoded 32-byte value that is derived from the name using the `namehash` algorithm from ENS [ENSIP-1](https://docs.ens.domains/ensip/1).

Using `viem:`

```typescript
import { namehash, normalize } from "viem/ens";

const normalizedName = normalize('salmo.nad');
const node = namehash(normalizedName);
```

Using `ethersjs(v6):`

```typescript
import { ensNormalize, namehash } from "ethers/hash";

const normalizedName = ensNormalize('salmo.nad')
const node = namehash(normalizedName)
```


---

# 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.nad.domains/developers/integrating-into-your-dapps/name-processing.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.
