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

# TransactionHash

> 32-byte transaction identifier

## Overview

TransactionHash is a branded `Uint8Array` type representing a 32-byte transaction identifier in Ethereum. Every transaction has a unique hash computed from its contents.

```typescript theme={null}
import * as TransactionHash from '@tevm/primitives/TransactionHash'

const hash = TransactionHash.fromHex(
  '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
)
```

## Type Definition

```typescript theme={null}
type TransactionHashType = Uint8Array & {
  readonly [brand]: "TransactionHash";
  readonly length: 32;
}
```

## Creating TransactionHashes

### from

Universal constructor accepting hex string or bytes.

```typescript theme={null}
// From hex string
const hash1 = TransactionHash.from(
  '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
)

// From bytes
const bytes = new Uint8Array(32)
const hash2 = TransactionHash.from(bytes)
```

### fromHex

Parse from hex string (with or without 0x prefix).

```typescript theme={null}
const hash = TransactionHash.fromHex(
  '1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
)
```

**Validation**: Must be 64 hex characters (32 bytes).

### fromBytes

Create from `Uint8Array`.

```typescript theme={null}
const bytes = new Uint8Array(32)
const hash = TransactionHash.fromBytes(bytes)
```

**Validation**: Must be exactly 32 bytes.

## Converting TransactionHashes

### toHex

Convert to lowercase hex string with 0x prefix.

```typescript theme={null}
const hex = TransactionHash.toHex(hash)
// '0x1234567890abcdef...'
```

## Comparing TransactionHashes

### equals

Check equality using constant-time byte comparison.

```typescript theme={null}
const a = TransactionHash.fromHex('0x1234...')
const b = TransactionHash.fromHex('0x1234...')

if (TransactionHash.equals(a, b)) {
  console.log('Hashes are equal')
}
```

## Errors

**InvalidTransactionHashLengthError**: Bytes length is not 32.

**InvalidTransactionHashFormatError**: Invalid hex format or unsupported type.

## See Also

* [TransactionHash (Effect)](https://voltaire-effect.tevm.sh/primitives/transaction-hash) - Effect.ts integration with Schema validation
* [BlockHash](/primitives/block-hash) - Block identifier
* [Receipt](/primitives/receipt) - Transaction receipts
* [EventLog](/primitives/eventlog) - Event logs
