# TxEnvelopeLegacy.hash

Hashes a [`TxEnvelopeLegacy.TxEnvelopeLegacy`](/api/TxEnvelopeLegacy/types#txenvelopelegacy). This is the "transaction hash".

## Imports

:::code-group
```ts [Named]
import { TxEnvelopeLegacy } from 'ox'
```

```ts [Entrypoint]
import * as TxEnvelopeLegacy from 'ox/TxEnvelopeLegacy'
```
:::

## Examples

```ts twoslash
import { Secp256k1, TxEnvelopeLegacy } from 'ox'

const envelope = TxEnvelopeLegacy.from({
  chainId: 1,
  nonce: 0n,
  gasPrice: 1000000000n,
  gas: 21000n,
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1000000000000000000n
})

const signature = Secp256k1.sign({
  payload: TxEnvelopeLegacy.getSignPayload(envelope),
  privateKey: '0x...'
})

const envelope_signed = TxEnvelopeLegacy.from(envelope, {
  signature
})

const hash = TxEnvelopeLegacy.hash(envelope_signed) // [!code focus]
```

## Definition

```ts
function hash<presign>(
  envelope: TxEnvelopeLegacy<presign extends true ? false : true>,
  options?: hash.Options<presign>,
): hash.ReturnType
```

**Source:** [src/core/TxEnvelopeLegacy.ts](https://github.com/wevm/ox/blob/main/src/core/TxEnvelopeLegacy.ts#L671)

## Parameters

### envelope

* **Type:** `TxEnvelopeLegacy<presign extends true ? false : true>`

The Legacy Transaction Envelope to hash.

#### envelope.gasPrice

* **Type:** `bigintType`
* **Optional**

Base fee per gas.

### options

* **Type:** `hash.Options<presign>`
* **Optional**

Options.

#### options.presign

* **Type:** `boolean | presign`
* **Optional**

Whether to hash this transaction for signing.

## Return Type

The hash of the transaction envelope.

`hash.ReturnType`
