{"eip":3338,"title":"Limit account nonce to 2^52","description":"Limit account nonce to be between 0 and 2^52.","authors":["Micah Zoltu (@MicahZoltu)","Alex Beregszaszi (@axic)"],"status":"Withdrawn","type":"Standards Track","category":"Core","created":"2021-03-07","discussionsTo":"https://ethereum-magicians.org/t/eip-2681-limit-account-nonce-to-2-64-1/4324","repo":"EIPs","label":"EIP-3338","officialUrl":"https://eips.ethereum.org/EIPS/eip-3338","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3338.md","url":"https://eips.huatuo.xyz/eip-3338/","tldr":{"en":"A withdrawn proposal to cap account nonces at 2^52 so they fit in compact encodings and float64; it was dropped in favour of the 2^64-1 limit in EIP-2681.","ja":"アカウントの nonce を 2^52 に制限し、コンパクトなエンコーディングや float64 に収まるようにする提案。取り下げられ、EIP-2681 の 2^64-1 という上限が採用された。","ko":"계정 nonce를 2^52로 제한해 컴팩트한 인코딩과 float64에 들어가게 하자는 철회된 제안. EIP-2681의 2^64-1 한도를 택하면서 폐기되었다.","zh":"一项已撤回的提案：将账户 nonce 上限设为 2^52，使其能放进紧凑编码和 float64；它被放弃，转而采用 EIP-2681 的 2^64-1 上限。"},"tags":["nonce","core","state","withdrawn"],"explainers":{"en":{"lang":"en","tldr":"A withdrawn proposal to cap account nonces at 2^52 so they fit in compact encodings and float64; it was dropped in favour of the 2^64-1 limit in EIP-2681.","tags":["nonce","core","state","withdrawn"],"related":[2681,155],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-3338/","markdown":"## What problem does it solve?\n\nIn the original protocol an account nonce is an arbitrarily large unsigned integer. That is awkward in a few places:\n\n- State proofs and witnesses have to handle variable-length data instead of a compact fixed-size field.\n- Some transaction-format proposals wanted a bounded nonce.\n- Clients store nonces as 256-bit numbers when 64 bits would do.\n\nERC-3338 proposed a hard upper bound to clean this up. It picked `2^52` specifically because every integer up to `2^52` can be represented exactly in a 64-bit floating-point number, which helps languages such as JavaScript that only have floats.\n\n## How it works\n\nAfter a fork block, two rules would apply:\n\n1. Any transaction whose nonce exceeds `2^52` is invalid.\n2. `CREATE` aborts with an exceptional halt if the creating account's nonce is `2^52`.\n\nThe spec argues no one would ever hit the limit in practice. Sending enough transactions to reach even a 64-bit limit would cost an absurd amount of gas, and at the time of writing the highest nonce on mainnet was about 29 million.\n\nIt also notes that the old Morden testnet started account nonces at `2^20` as a crude form of replay protection, an approach made obsolete by chain IDs in [EIP-155](/eip-155/).\n\n## Sample code\n\nPseudocode for the proposed checks:\n\n```python\nMAX_NONCE = 2**52\n\ndef validate_transaction(tx, state):\n    if tx.nonce \u003e MAX_NONCE:\n        raise InvalidTransaction(\"nonce too high\")\n    ...\n\ndef op_create(evm, sender):\n    if state.get_nonce(sender) == MAX_NONCE:\n        raise ExceptionalHalt(\"nonce limit\")\n    ...\n```\n\nWhy `2^52` was attractive for JavaScript:\n\n```ts\nconsole.log(Number.isSafeInteger(2 ** 52));   // true\nconsole.log(Number.MAX_SAFE_INTEGER);         // 9007199254740991 (2^53 - 1)\n```\n\n## Things to know\n\n- Status is **Withdrawn**. The authors withdrew it in favour of [EIP-2681](/eip-2681/), which limits nonces to `2^64 - 1` instead.\n- The 2^64-1 limit matches what clients such as go-ethereum already did internally, so it achieves the compactness goal without the float-specific bound.\n- If you need to handle nonces in JavaScript, use `bigint` rather than relying on any float-safe ceiling.\n"},"ja":{"lang":"ja","tldr":"アカウントの nonce を 2^52 に制限し、コンパクトなエンコーディングや float64 に収まるようにする提案。取り下げられ、EIP-2681 の 2^64-1 という上限が採用された。","tags":["nonce","core","state","withdrawn"],"related":[2681,155],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-3338/","markdown":"## 何を解決するのか\n\n元のプロトコルでは、アカウントの nonce は任意の大きさの符号なし整数です。これはいくつかの場面で扱いにくくなります。\n\n- ステート証明やウィットネスは、コンパクトな固定長フィールドではなく可変長データを扱う必要があります。\n- トランザクション形式に関する提案の中には、上限のある nonce を求めるものがありました。\n- クライアントは、64 ビットで足りるのに nonce を 256 ビットの数値として保存しています。\n\nERC-3338 は、これを整理するためにハードな上限を提案しました。特に `2^52` を選んだのは、`2^52` までのすべての整数が 64 ビット浮動小数点数で正確に表現でき、JavaScript のように浮動小数点しかない言語に役立つからです。\n\n## 仕組み\n\nフォークブロックの後、2 つのルールが適用されます。\n\n1. nonce が `2^52` を超えるトランザクションは無効です。\n2. 作成元アカウントの nonce が `2^52` の場合、`CREATE` は例外的な停止で中断します。\n\n仕様は、実際にこの上限に達する人はいないと主張しています。64 ビットの上限に達するだけの数のトランザクションを送るにも、途方もない量のガスがかかります。執筆時点でメインネットの最大の nonce は約 2,900 万でした。\n\nまた、かつての Morden テストネットが、粗いリプレイ保護の形としてアカウントの nonce を `2^20` から始めていたことにも触れています。この方法は [EIP-155](/eip-155/) のチェーン ID によって時代遅れになりました。\n\n## サンプルコード\n\n提案されたチェックの疑似コード:\n\n```python\nMAX_NONCE = 2**52\n\ndef validate_transaction(tx, state):\n    if tx.nonce \u003e MAX_NONCE:\n        raise InvalidTransaction(\"nonce too high\")\n    ...\n\ndef op_create(evm, sender):\n    if state.get_nonce(sender) == MAX_NONCE:\n        raise ExceptionalHalt(\"nonce limit\")\n    ...\n```\n\n`2^52` が JavaScript にとって魅力的だった理由:\n\n```ts\nconsole.log(Number.isSafeInteger(2 ** 52));   // true\nconsole.log(Number.MAX_SAFE_INTEGER);         // 9007199254740991 (2^53 - 1)\n```\n\n## 知っておくべきこと\n\n- ステータスは **Withdrawn** です。作者は、nonce を代わりに `2^64 - 1` に制限する [EIP-2681](/eip-2681/) を支持して取り下げました。\n- 2^64-1 の上限は go-ethereum などのクライアントが内部で既に行っていたことと一致するため、浮動小数点固有の上限なしでコンパクト化の目標を達成できます。\n- JavaScript で nonce を扱う必要がある場合は、浮動小数点で安全な上限に頼らず `bigint` を使ってください。\n"},"ko":{"lang":"ko","tldr":"계정 nonce를 2^52로 제한해 컴팩트한 인코딩과 float64에 들어가게 하자는 철회된 제안. EIP-2681의 2^64-1 한도를 택하면서 폐기되었다.","tags":["nonce","core","state","withdrawn"],"related":[2681,155],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-3338/","markdown":"## 어떤 문제를 해결하나요?\n\n원래 프로토콜에서 계정 nonce는 임의로 큰 부호 없는 정수입니다. 이는 몇 군데에서 불편합니다.\n\n- 상태 증명과 위트니스는 컴팩트한 고정 크기 필드 대신 가변 길이 데이터를 처리해야 합니다.\n- 일부 트랜잭션 형식 제안은 범위가 한정된 nonce를 원했습니다.\n- 클라이언트는 64비트면 충분한데도 nonce를 256비트 숫자로 저장합니다.\n\nERC-3338은 이를 정리하기 위해 엄격한 상한을 제안했습니다. 특히 `2^52`를 고른 이유는 `2^52`까지의 모든 정수가 64비트 부동소수점 수로 정확하게 표현되기 때문이며, 이는 부동소수점만 있는 JavaScript 같은 언어에 도움이 됩니다.\n\n## 어떻게 동작하나요?\n\n포크 블록 이후 두 가지 규칙이 적용됩니다.\n\n1. nonce가 `2^52`를 넘는 트랜잭션은 유효하지 않습니다.\n2. 생성하는 계정의 nonce가 `2^52`이면 `CREATE`는 예외적 중단(exceptional halt)으로 중단됩니다.\n\n스펙은 실제로 이 한도에 도달할 사람은 없다고 주장합니다. 64비트 한도에 이를 만큼 트랜잭션을 보내는 것만으로도 터무니없는 양의 가스가 들며, 작성 시점에 메인넷의 가장 높은 nonce는 약 2,900만이었습니다.\n\n또한 예전 Morden 테스트넷이 거친 형태의 리플레이 방지로 계정 nonce를 `2^20`에서 시작했으며, 이 방식은 [EIP-155](/eip-155/)의 체인 ID로 쓸모없어졌다고 언급합니다.\n\n## 샘플 코드\n\n제안된 검사의 의사 코드:\n\n```python\nMAX_NONCE = 2**52\n\ndef validate_transaction(tx, state):\n    if tx.nonce \u003e MAX_NONCE:\n        raise InvalidTransaction(\"nonce too high\")\n    ...\n\ndef op_create(evm, sender):\n    if state.get_nonce(sender) == MAX_NONCE:\n        raise ExceptionalHalt(\"nonce limit\")\n    ...\n```\n\n`2^52`가 JavaScript에 매력적이었던 이유:\n\n```ts\nconsole.log(Number.isSafeInteger(2 ** 52));   // true\nconsole.log(Number.MAX_SAFE_INTEGER);         // 9007199254740991 (2^53 - 1)\n```\n\n## 알아둘 점\n\n- 상태는 **Withdrawn**입니다. 작성자들은 nonce를 대신 `2^64 - 1`로 제한하는 [EIP-2681](/eip-2681/)을 지지하며 철회했습니다.\n- 2^64-1 한도는 go-ethereum 같은 클라이언트가 이미 내부적으로 하던 것과 일치하므로, 부동소수점 전용 한도 없이도 컴팩트화 목표를 달성합니다.\n- JavaScript에서 nonce를 다뤄야 한다면 부동소수점에 안전한 상한에 기대지 말고 `bigint`를 사용하세요.\n"},"zh":{"lang":"zh","tldr":"一项已撤回的提案：将账户 nonce 上限设为 2^52，使其能放进紧凑编码和 float64；它被放弃，转而采用 EIP-2681 的 2^64-1 上限。","tags":["nonce","core","state","withdrawn"],"related":[2681,155],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-3338/","markdown":"## 它解决什么问题？\n\n在最初的协议中，账户 nonce 是任意大的无符号整数。这在几个地方很不方便：\n\n- 状态证明和见证必须处理变长数据，而不是紧凑的定长字段。\n- 一些交易格式提案希望 nonce 有界。\n- 客户端把 nonce 存成 256 位数字，而 64 位就够了。\n\nERC-3338 提出了一个硬性上限来整理这件事。它特意选择 `2^52`，因为不超过 `2^52` 的每个整数都能用 64 位浮点数精确表示，这对只有浮点数的语言（如 JavaScript）有帮助。\n\n## 它如何运作\n\n分叉区块之后，将适用两条规则：\n\n1. 任何 nonce 超过 `2^52` 的交易都是无效的。\n2. 如果创建者账户的 nonce 为 `2^52`，`CREATE` 会以异常中止（exceptional halt）终止。\n\n规范认为实际上没有人会碰到这个上限。发送足够多的交易来达到哪怕 64 位的上限，也要花费荒谬数量的 gas；撰写时主网上最高的 nonce 约为 2900 万。\n\n它还指出，旧的 Morden 测试网把账户 nonce 从 `2^20` 开始，作为一种粗糙的重放保护，这种做法已被 [EIP-155](/eip-155/) 的链 ID 淘汰。\n\n## 示例代码\n\n所提议检查的伪代码：\n\n```python\nMAX_NONCE = 2**52\n\ndef validate_transaction(tx, state):\n    if tx.nonce \u003e MAX_NONCE:\n        raise InvalidTransaction(\"nonce too high\")\n    ...\n\ndef op_create(evm, sender):\n    if state.get_nonce(sender) == MAX_NONCE:\n        raise ExceptionalHalt(\"nonce limit\")\n    ...\n```\n\n为什么 `2^52` 对 JavaScript 有吸引力：\n\n```ts\nconsole.log(Number.isSafeInteger(2 ** 52));   // true\nconsole.log(Number.MAX_SAFE_INTEGER);         // 9007199254740991 (2^53 - 1)\n```\n\n## 需要注意\n\n- 状态为 **Withdrawn**。作者撤回了它，转而支持 [EIP-2681](/eip-2681/)，后者把 nonce 限制为 `2^64 - 1`。\n- 2^64-1 的上限与 go-ethereum 等客户端内部已经采用的做法一致，因此无需针对浮点数的上限就达到了紧凑化的目标。\n- 如果需要在 JavaScript 中处理 nonce，请使用 `bigint`，不要依赖任何浮点安全的上限。\n"}}}
