# HexString

### `hexToU8a`

Converts a hex string to a Uint8Array

```typescript
import { hexToU8a } from 'dedot/utils';

hexToU8a('0x1234') // new Uint8Array([0x12, 0x34])
```

### `hexToString`

Converts a hex to a string

```typescript
import { hexToString } from 'dedot/utils';

hexToString('0x616263') // 'abc'
```

### `isZeroHex`

Check if a hex is zero

```typescript
import { isZeroHex } from 'dedot/utils';

isZeroHex('0x00000000') // true
isZeroHex('0x00000001') // false
```

### `hexAddPrefix` & `hexStripPrefix`

Add/remove the '0x' prefix to/from a hex string

```typescript
import { hexAddPrefix, hexStripPrefix } from 'dedot/utils';

hexAddPrefix('00000000') // '0x00000000'
hexAddPrefix('0x00000001') // '0x00000001'

hexStripPrefix('00000000') // '00000000'
hexStripPrefix('0x00000001') // '00000001'
```

### `toHex`

Converts the input to a hex string, input can be in different types: `string | number | Uint8Array | HexString`

```typescript
import { toHex } from 'dedot/utils';

toHex(new Uint8Array([0x12, 0x34])) // '0x1234'
toHex(4660) // '0x1234'
toHex('0x1234') // '0x1234'
toHex('abc') // '0x1234'
```


---

# 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.dedot.dev/utilities/hex.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.
