---
eip: 2294
label: EIP-2294
title: Explicit bound to Chain ID size
status: Stagnant
type: Informational
created: 2019-09-19
requires: 155
official: https://eips.ethereum.org/EIPS/eip-2294
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2294.md
canonical: https://eips.huatuo.xyz/eip-2294/
lang: en
tldr: Proposes explicit upper bounds on chain ID values, a JavaScript-safe range up to 2^31-1 and a hard maximum that keeps EIP-155 signature math inside uint64, so wallets, clients and contracts agree on every ID.
tags: [chain-id, transactions, signatures, wallets, informational]
---

# EIP-2294: Explicit bound to Chain ID size

> Adds a maximum value to the Chain ID parameter to avoid potential encoding issues that may occur when using large values of the parameter.

**TL;DR:** Proposes explicit upper bounds on chain ID values, a JavaScript-safe range up to 2^31-1 and a hard maximum that keeps EIP-155 signature math inside uint64, so wallets, clients and contracts agree on every ID.

## What problem does it solve?

[EIP-155](/eip-155/) introduced the chain ID for replay protection but never said how large it may be. In principle it is an arbitrary integer, and [EIP-1344](/eip-1344/) exposes it to contracts as a 256-bit word. In practice different components store it differently:

- Legacy transactions encode it inside the signature's `v` value as `chainId * 2 + 35` or `+ 36`, which overflows fixed-width integers for very large IDs.
- JavaScript tooling often handles it as a `number`, which loses precision above 2^53 and is commonly treated as a 32-bit value.
- [EIP-712](/eip-712/) domains and [ERC-1271](/eip-1271/) verification hash the chain ID, so two components disagreeing on its value means signatures that verify in one place and fail (or replay) in another.

With L2s, L3s and app chains multiplying, the authors wanted a clear statement of which values are safe.

## How it works

The EIP defines two ranges, informationally:

| Range | Bounds | Reason |
| --- | --- | --- |
| Safe Range | 1 to 2^31 − 1 (2,147,483,647) | Representable everywhere, including common JavaScript handling |
| Max Range | 1 to `MAX_CHAIN_ID` | Keeps EIP-155 arithmetic within uint64 |

```
MAX_CHAIN_ID = floor(MAX_UINT64 / 2) - 36 = 9,223,372,036,854,775,771
```

The largest intermediate value in EIP-155 math is `chainId * 2 + 36`, so this bound guarantees no overflow with 64-bit unsigned arithmetic. Zero and negative values are not allowed.

The ~63 bits of the max range also leave room for ideas like hash-derived chain IDs for temporary or forked chains, without making collisions likely in normal use.

## Sample code

Validating a chain ID before adding a network or signing (TypeScript):

```ts
const SAFE_MAX = 2n ** 31n - 1n;                   // 2147483647
const MAX_UINT64 = 2n ** 64n - 1n;
const MAX_CHAIN_ID = MAX_UINT64 / 2n - 36n;        // 9223372036854775771n

type Verdict = "safe" | "max-range" | "invalid";

function checkChainId(id: bigint): Verdict {
  if (id < 1n) return "invalid";
  if (id <= SAFE_MAX) return "safe";
  if (id <= MAX_CHAIN_ID) return "max-range";      // fine for clients, risky for JS number-based tools
  return "invalid";
}

// Legacy (EIP-155) v value stays within uint64 for any max-range ID
const v = (id: bigint, recovery: 0n | 1n) => id * 2n + 35n + recovery;

console.log(checkChainId(1n));            // "safe"
console.log(checkChainId(MAX_CHAIN_ID));  // "max-range"
console.log(v(MAX_CHAIN_ID, 1n) <= MAX_UINT64); // true
```

## Things to know

- Status is **Stagnant** and the type is Informational: it describes recommended limits but does not change consensus rules.
- The authors state that, as of 2022, no known chain used an ID outside these bounds.
- If you are choosing a chain ID for a new network, staying inside the Safe Range avoids problems with wallets and libraries that treat it as a JavaScript number.
- Always handle chain IDs as `bigint` (ethers v6 already does) rather than `number` in new code.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-2294
