> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# TxEnvelope Errors

:::info
`TxEnvelope` is a re-export of ox's [`TransactionEnvelope`](https://oxlib.sh/api/TransactionEnvelope/errors). Refer to the ox documentation for the full reference.
:::

## `TxEnvelope.FeeCapTooHighError`

Thrown when a fee cap is too high.

### Examples

```ts twoslash
// @noErrors
import { TxEnvelopeEip1559 } from 'viem/utils'

TxEnvelopeEip1559.assert({
  maxFeePerGas: 2n ** 256n - 1n + 1n,
  chainId: 1
})
// @error: TxEnvelope.FeeCapTooHighError: The fee cap (`maxFeePerGas`/`maxPriorityFeePerGas` = 115792089237316195423570985008687907853269984665640564039457584007913.129639936 gwei) cannot be higher than the maximum allowed value (2^256-1).
```

## `TxEnvelope.GasPriceTooHighError`

Thrown when a gas price is too high.

### Examples

```ts twoslash
// @noErrors
import { TxEnvelopeLegacy } from 'viem/utils'

TxEnvelopeLegacy.assert({
  gasPrice: 2n ** 256n - 1n + 1n,
  chainId: 1
})
// @error: TxEnvelope.GasPriceTooHighError: The gas price (`gasPrice` = 115792089237316195423570985008687907853269984665640564039457584007913.129639936 gwei) cannot be higher than the maximum allowed value (2^256-1).
```

## `TxEnvelope.InvalidChainIdError`

Thrown when a chain ID is invalid.

### Examples

```ts twoslash
// @noErrors
import { TxEnvelopeEip1559 } from 'viem/utils'

TxEnvelopeEip1559.assert({ chainId: 0 })
// @error: TxEnvelope.InvalidChainIdError: Chain ID "0" is invalid.
```

## `TxEnvelope.InvalidSerializedError`

Thrown when a serialized transaction is invalid.

### Examples

```ts twoslash
// @noErrors
import { TxEnvelopeEip1559 } from 'viem/utils'

TxEnvelopeEip1559.deserialize('0x02c0')
// @error: TxEnvelope.InvalidSerializedError: Invalid serialized transaction of type "eip1559" was provided.
// @error: Serialized Transaction: "0x02c0"
// @error: Missing Attributes: chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gas, to, value, data, accessList
```

## `TxEnvelope.InvalidSerializedTypeError`

Thrown when a serialized transaction type cannot be resolved.

## `TxEnvelope.InvalidTypeError`

Thrown when a transaction envelope type cannot be resolved.

## `TxEnvelope.TipAboveFeeCapError`

Thrown when a tip is higher than a fee cap.

### Examples

```ts twoslash
// @noErrors
import { TxEnvelopeEip1559 } from 'viem/utils'

TxEnvelopeEip1559.assert({
  chainId: 1,
  maxFeePerGas: 10n,
  maxPriorityFeePerGas: 11n
})
// @error: TxEnvelope.TipAboveFeeCapError: The provided tip (`maxPriorityFeePerGas` = 11 gwei) cannot be higher than the fee cap (`maxFeePerGas` = 10 gwei).
```
