{"eip":8119,"title":"Parameterized Storage Keys","description":"A format for parameterized string keys used in EVM key-value storage.","authors":["Prem Makeig (@nxt3d)"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2025-01-06","discussionsTo":"https://ethereum-magicians.org/t/erc-8119-key-parameters-standard-format-for-parameterized-string-keys/27397","repo":"ERCs","label":"ERC-8119","officialUrl":"https://eips.ethereum.org/EIPS/eip-8119","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-8119.md","url":"https://eips.huatuo.xyz/eip-8119/","tldr":{"en":"A small convention for string keys like \"registration/1\" or \"resource[chain][1]\" in on-chain key-value storage, so different contracts and tools parse parameterized metadata keys the same way.","ja":"オンチェーンのキー・バリューストレージで、\"registration/1\" や \"resource[chain][1]\" のような文字列キーを書く小さな規約。コントラクトやツールが違っても、パラメータ付きメタデータキーを同じ方法で解析できる。","ko":"온체인 키-값 저장소에서 \"registration/1\"이나 \"resource[chain][1]\" 같은 문자열 키를 쓰는 작은 규약. 서로 다른 컨트랙트와 도구가 파라미터가 있는 메타데이터 키를 같은 방식으로 파싱할 수 있게 한다.","zh":"一个关于链上键值存储中字符串键（如 \"registration/1\" 或 \"resource[chain][1]\"）的小约定，让不同合约和工具以同样的方式解析带参数的元数据键。"},"tags":["metadata","storage","keys","format","erc"],"explainers":{"en":{"lang":"en","tldr":"A small convention for string keys like \"registration/1\" or \"resource[chain][1]\" in on-chain key-value storage, so different contracts and tools parse parameterized metadata keys the same way.","tags":["metadata","storage","keys","format","erc"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-8119/","markdown":"## What problem does it solve?\n\nMany contracts store metadata in a `mapping(string =\u003e bytes)` or similar key-value store. Often you need several instances of the same kind of value: registration #1, #2, #3, or a name per language. Each project invents its own way to write those keys (`registration-1`, `registration1`, `registration_1`...), so a generic tool cannot tell which part is the type and which part is the parameter.\n\nERC-8119 picks one format so any client can split a key into a *label* and its *parameters*.\n\n## How it works\n\nThere are two encodings.\n\n**Slash/colon form (exactly one parameter):** `\u003ckey-label\u003e/\u003ckey-parameter\u003e` or `\u003ckey-label\u003e:\u003ckey-parameter\u003e`\n\n- The parser splits on the **first** `/` or `:`. Everything after it is a single parameter, so `website/http://website.com` and `key/value:with:colons` are valid.\n- The parameter may be any UTF-8 text (`name/María`, `title/タイトル`) but must **not start with a space**. If you need a leading space, put it inside quotes: `quote/' starts with a space'`.\n\n**Bracket form (one or more parameters):** `\u003ckey-label\u003e[\u003cp1\u003e][\u003cp2\u003e]...`\n\n- The label runs up to the first `[`; then one or more bracketed parameters follow, e.g. `resource[chain][1][token][42]`.\n- A parameter may contain anything except `]`. Nothing may follow the last `]`.\n\n**The label** must be printable ASCII without space, `/`, `:` or `[`. Punctuation such as `%gain`, `$price` or `#tag` is allowed. Plain keys without parameters (`name`) remain valid.\n\nInvalid examples from the spec: `registration-1`, `registration1`, `key/ value`, `key label/value`, `key[label`, `key[]tail`, and mixing the two forms like `key/param[extra]`.\n\n## Sample code\n\nStoring parameterized keys in Solidity:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.25;\n\ncontract Metadata {\n    mapping(string =\u003e bytes) private _metadata;\n\n    function setMetadata(string calldata key, bytes calldata value) external {\n        _metadata[key] = value; // e.g. \"registration/1\", \"user[alice]\"\n    }\n\n    function getMetadata(string calldata key) external view returns (bytes memory) {\n        return _metadata[key];\n    }\n}\n```\n\nA simple client-side parser (TypeScript):\n\n```ts\ntype Parsed = { label: string; params: string[] };\n\nconst LABEL = /^[\\x21-\\x2E\\x30-\\x39\\x3B-\\x5A\\x5C-\\x7E]+$/; // no space, '/', ':', '['\n\nexport function parseKey(key: string): Parsed | null {\n  const i = key.search(/[\\/:\\[]/);\n  if (i === -1) return LABEL.test(key) ? { label: key, params: [] } : null;\n  const label = key.slice(0, i);\n  if (!LABEL.test(label)) return null;\n\n  if (key[i] === \"[\") {\n    const rest = key.slice(i);\n    if (!/^(\\[[^\\]]*\\])+$/.test(rest)) return null; // unclosed or trailing text\n    return { label, params: [...rest.matchAll(/\\[([^\\]]*)\\]/g)].map((m) =\u003e m[1]) };\n  }\n\n  const param = key.slice(i + 1);\n  if (param.startsWith(\" \")) return null;            // \"key/ value\" is invalid\n  if (/\\[[^\\]]*\\]$/.test(param)) return null;        // reject mixed \"key/param[extra]\"\n  return { label, params: [param] };\n}\n\nparseKey(\"resource[chain][1]\"); // { label: \"resource\", params: [\"chain\", \"1\"] }\nparseKey(\"website/http://x.io\"); // { label: \"website\", params: [\"http://x.io\"] }\n```\n\n## Things to know\n\n- **Status: Draft.** The format could still change.\n- This is purely a naming convention. It needs no new contract interface and is fully backward compatible; contracts without parameters are unaffected.\n- The spec asks clients to validate user-supplied keys and reject malformed bracket input to avoid different parsers disagreeing.\n- The spec lists `key/param[extra]` as invalid but does not spell out an exact rule for detecting mixed forms; the check in the sample above is one reasonable interpretation.\n"},"ja":{"lang":"ja","tldr":"オンチェーンのキー・バリューストレージで、\"registration/1\" や \"resource[chain][1]\" のような文字列キーを書く小さな規約。コントラクトやツールが違っても、パラメータ付きメタデータキーを同じ方法で解析できる。","tags":["metadata","storage","keys","format","erc"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-8119/","markdown":"## 何を解決するのか\n\n多くのコントラクトは、メタデータを `mapping(string =\u003e bytes)` などのキー・バリューストアに保存します。同じ種類の値が複数必要になることがよくあります。たとえば registration の #1、#2、#3 や、言語ごとの名前です。プロジェクトごとにそうしたキーの書き方が異なる（`registration-1`、`registration1`、`registration_1` など）ため、汎用ツールはどの部分が種類でどの部分がパラメータなのか判別できません。\n\nERC-8119 は 1 つの形式を定めることで、どのクライアントでもキーを*ラベル*とその*パラメータ*に分割できるようにします。\n\n## 仕組み\n\nエンコードは 2 種類あります。\n\n**スラッシュ／コロン形式（パラメータはちょうど 1 つ）:** `\u003ckey-label\u003e/\u003ckey-parameter\u003e` または `\u003ckey-label\u003e:\u003ckey-parameter\u003e`\n\n- パーサーは**最初の** `/` または `:` で分割します。それ以降はすべて 1 つのパラメータとなるため、`website/http://website.com` や `key/value:with:colons` は有効です。\n- パラメータは任意の UTF-8 テキスト（`name/María`、`title/タイトル`）にできますが、**スペースで始めてはいけません**。先頭にスペースが必要な場合は、引用符の中に入れます: `quote/' starts with a space'`。\n\n**ブラケット形式（パラメータは 1 つ以上）:** `\u003ckey-label\u003e[\u003cp1\u003e][\u003cp2\u003e]...`\n\n- ラベルは最初の `[` までで、その後に 1 つ以上のブラケット付きパラメータが続きます。たとえば `resource[chain][1][token][42]` のようになります。\n- パラメータには `]` 以外なら何でも含められます。最後の `]` の後には何も続けてはいけません。\n\n**ラベル**は、スペース、`/`、`:`、`[` を含まない印字可能な ASCII でなければなりません。`%gain`、`$price`、`#tag` のような句読点は使えます。パラメータなしのプレーンなキー（`name`）も引き続き有効です。\n\n仕様に挙げられている無効な例: `registration-1`、`registration1`、`key/ value`、`key label/value`、`key[label`、`key[]tail`、そして `key/param[extra]` のように 2 つの形式を混ぜたもの。\n\n## サンプルコード\n\nSolidity でパラメータ付きキーを保存する例:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.25;\n\ncontract Metadata {\n    mapping(string =\u003e bytes) private _metadata;\n\n    function setMetadata(string calldata key, bytes calldata value) external {\n        _metadata[key] = value; // e.g. \"registration/1\", \"user[alice]\"\n    }\n\n    function getMetadata(string calldata key) external view returns (bytes memory) {\n        return _metadata[key];\n    }\n}\n```\n\nシンプルなクライアント側パーサー（TypeScript）:\n\n```ts\ntype Parsed = { label: string; params: string[] };\n\nconst LABEL = /^[\\x21-\\x2E\\x30-\\x39\\x3B-\\x5A\\x5C-\\x7E]+$/; // no space, '/', ':', '['\n\nexport function parseKey(key: string): Parsed | null {\n  const i = key.search(/[\\/:\\[]/);\n  if (i === -1) return LABEL.test(key) ? { label: key, params: [] } : null;\n  const label = key.slice(0, i);\n  if (!LABEL.test(label)) return null;\n\n  if (key[i] === \"[\") {\n    const rest = key.slice(i);\n    if (!/^(\\[[^\\]]*\\])+$/.test(rest)) return null; // unclosed or trailing text\n    return { label, params: [...rest.matchAll(/\\[([^\\]]*)\\]/g)].map((m) =\u003e m[1]) };\n  }\n\n  const param = key.slice(i + 1);\n  if (param.startsWith(\" \")) return null;            // \"key/ value\" is invalid\n  if (/\\[[^\\]]*\\]$/.test(param)) return null;        // reject mixed \"key/param[extra]\"\n  return { label, params: [param] };\n}\n\nparseKey(\"resource[chain][1]\"); // { label: \"resource\", params: [\"chain\", \"1\"] }\nparseKey(\"website/http://x.io\"); // { label: \"website\", params: [\"http://x.io\"] }\n```\n\n## 知っておくべきこと\n\n- **ステータス: Draft。** 形式はまだ変わる可能性があります。\n- これは純粋に命名規則です。新しいコントラクトインターフェースは不要で、完全に後方互換です。パラメータを使わないコントラクトは影響を受けません。\n- 仕様は、異なるパーサー間で解釈が食い違わないよう、クライアントにユーザー指定のキーを検証し、不正なブラケット入力を拒否することを求めています。\n- 仕様は `key/param[extra]` を無効として挙げていますが、混在形式を検出する正確なルールは明記していません。上のサンプルのチェックは、妥当な解釈の 1 つです。\n"},"ko":{"lang":"ko","tldr":"온체인 키-값 저장소에서 \"registration/1\"이나 \"resource[chain][1]\" 같은 문자열 키를 쓰는 작은 규약. 서로 다른 컨트랙트와 도구가 파라미터가 있는 메타데이터 키를 같은 방식으로 파싱할 수 있게 한다.","tags":["metadata","storage","keys","format","erc"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-8119/","markdown":"## 어떤 문제를 해결하나요?\n\n많은 컨트랙트가 메타데이터를 `mapping(string =\u003e bytes)` 같은 키-값 저장소에 보관합니다. 같은 종류의 값이 여러 개 필요한 경우가 흔합니다. registration #1, #2, #3이나 언어별 이름 같은 것입니다. 프로젝트마다 이런 키를 쓰는 방식이 제각각이어서(`registration-1`, `registration1`, `registration_1` 등) 범용 도구는 어느 부분이 종류이고 어느 부분이 파라미터인지 알 수 없습니다.\n\nERC-8119는 하나의 형식을 정해서, 어떤 클라이언트든 키를 *레이블*과 그 *파라미터*로 나눌 수 있게 합니다.\n\n## 어떻게 동작하나요?\n\n인코딩은 두 가지입니다.\n\n**슬래시/콜론 형식(파라미터가 정확히 하나):** `\u003ckey-label\u003e/\u003ckey-parameter\u003e` 또는 `\u003ckey-label\u003e:\u003ckey-parameter\u003e`\n\n- 파서는 **첫 번째** `/` 또는 `:`에서 나눕니다. 그 뒤의 모든 것이 하나의 파라미터이므로 `website/http://website.com`과 `key/value:with:colons`는 유효합니다.\n- 파라미터는 어떤 UTF-8 텍스트(`name/María`, `title/タイトル`)든 될 수 있지만 **공백으로 시작해서는 안 됩니다**. 앞에 공백이 필요하면 따옴표 안에 넣습니다: `quote/' starts with a space'`.\n\n**대괄호 형식(파라미터가 하나 이상):** `\u003ckey-label\u003e[\u003cp1\u003e][\u003cp2\u003e]...`\n\n- 레이블은 첫 번째 `[`까지이고, 그 뒤에 대괄호로 묶인 파라미터가 하나 이상 이어집니다. 예: `resource[chain][1][token][42]`.\n- 파라미터에는 `]`를 제외한 무엇이든 들어갈 수 있습니다. 마지막 `]` 뒤에는 아무것도 올 수 없습니다.\n\n**레이블**은 공백, `/`, `:`, `[`가 없는 출력 가능한 ASCII여야 합니다. `%gain`, `$price`, `#tag` 같은 구두점은 허용됩니다. 파라미터가 없는 일반 키(`name`)도 계속 유효합니다.\n\n명세에 나온 유효하지 않은 예: `registration-1`, `registration1`, `key/ value`, `key label/value`, `key[label`, `key[]tail`, 그리고 `key/param[extra]`처럼 두 형식을 섞은 것.\n\n## 샘플 코드\n\nSolidity에서 파라미터가 있는 키 저장하기:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.25;\n\ncontract Metadata {\n    mapping(string =\u003e bytes) private _metadata;\n\n    function setMetadata(string calldata key, bytes calldata value) external {\n        _metadata[key] = value; // e.g. \"registration/1\", \"user[alice]\"\n    }\n\n    function getMetadata(string calldata key) external view returns (bytes memory) {\n        return _metadata[key];\n    }\n}\n```\n\n간단한 클라이언트 측 파서(TypeScript):\n\n```ts\ntype Parsed = { label: string; params: string[] };\n\nconst LABEL = /^[\\x21-\\x2E\\x30-\\x39\\x3B-\\x5A\\x5C-\\x7E]+$/; // no space, '/', ':', '['\n\nexport function parseKey(key: string): Parsed | null {\n  const i = key.search(/[\\/:\\[]/);\n  if (i === -1) return LABEL.test(key) ? { label: key, params: [] } : null;\n  const label = key.slice(0, i);\n  if (!LABEL.test(label)) return null;\n\n  if (key[i] === \"[\") {\n    const rest = key.slice(i);\n    if (!/^(\\[[^\\]]*\\])+$/.test(rest)) return null; // unclosed or trailing text\n    return { label, params: [...rest.matchAll(/\\[([^\\]]*)\\]/g)].map((m) =\u003e m[1]) };\n  }\n\n  const param = key.slice(i + 1);\n  if (param.startsWith(\" \")) return null;            // \"key/ value\" is invalid\n  if (/\\[[^\\]]*\\]$/.test(param)) return null;        // reject mixed \"key/param[extra]\"\n  return { label, params: [param] };\n}\n\nparseKey(\"resource[chain][1]\"); // { label: \"resource\", params: [\"chain\", \"1\"] }\nparseKey(\"website/http://x.io\"); // { label: \"website\", params: [\"http://x.io\"] }\n```\n\n## 알아둘 점\n\n- **상태: Draft.** 형식은 아직 바뀔 수 있습니다.\n- 이는 순전히 명명 규약입니다. 새로운 컨트랙트 인터페이스가 필요 없고 완전히 하위 호환됩니다. 파라미터를 쓰지 않는 컨트랙트는 영향을 받지 않습니다.\n- 명세는 서로 다른 파서가 해석을 달리하는 일이 없도록, 클라이언트가 사용자가 제공한 키를 검증하고 잘못된 대괄호 입력을 거부하도록 요구합니다.\n- 명세는 `key/param[extra]`를 유효하지 않다고 나열하지만 혼합 형식을 감지하는 정확한 규칙은 명시하지 않습니다. 위 샘플의 검사는 합리적인 해석 중 하나입니다.\n"},"zh":{"lang":"zh","tldr":"一个关于链上键值存储中字符串键（如 \"registration/1\" 或 \"resource[chain][1]\"）的小约定，让不同合约和工具以同样的方式解析带参数的元数据键。","tags":["metadata","storage","keys","format","erc"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-8119/","markdown":"## 它解决什么问题？\n\n许多合约把元数据存放在 `mapping(string =\u003e bytes)` 或类似的键值存储中。常常需要同一类值的多个实例：registration #1、#2、#3，或每种语言一个名称。每个项目都发明了自己写这些键的方式（`registration-1`、`registration1`、`registration_1`……），因此通用工具无法分辨哪部分是类型，哪部分是参数。\n\nERC-8119 选定了一种格式，使任何客户端都能把键拆分为*标签*及其*参数*。\n\n## 它如何运作\n\n有两种编码。\n\n**斜杠/冒号形式（恰好一个参数）：** `\u003ckey-label\u003e/\u003ckey-parameter\u003e` 或 `\u003ckey-label\u003e:\u003ckey-parameter\u003e`\n\n- 解析器在**第一个** `/` 或 `:` 处拆分。其后的所有内容都是单个参数，因此 `website/http://website.com` 和 `key/value:with:colons` 都是有效的。\n- 参数可以是任意 UTF-8 文本（`name/María`、`title/タイトル`），但**不能以空格开头**。如果需要开头的空格，请放在引号内：`quote/' starts with a space'`。\n\n**方括号形式（一个或多个参数）：** `\u003ckey-label\u003e[\u003cp1\u003e][\u003cp2\u003e]...`\n\n- 标签到第一个 `[` 为止；随后是一个或多个带方括号的参数，例如 `resource[chain][1][token][42]`。\n- 参数可以包含除 `]` 之外的任何内容。最后一个 `]` 之后不能有任何内容。\n\n**标签**必须是不含空格、`/`、`:` 或 `[` 的可打印 ASCII。允许使用 `%gain`、`$price` 或 `#tag` 这类标点。不带参数的普通键（`name`）依然有效。\n\n规范中列出的无效示例：`registration-1`、`registration1`、`key/ value`、`key label/value`、`key[label`、`key[]tail`，以及混用两种形式，如 `key/param[extra]`。\n\n## 示例代码\n\n在 Solidity 中存储带参数的键：\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.25;\n\ncontract Metadata {\n    mapping(string =\u003e bytes) private _metadata;\n\n    function setMetadata(string calldata key, bytes calldata value) external {\n        _metadata[key] = value; // e.g. \"registration/1\", \"user[alice]\"\n    }\n\n    function getMetadata(string calldata key) external view returns (bytes memory) {\n        return _metadata[key];\n    }\n}\n```\n\n一个简单的客户端解析器（TypeScript）：\n\n```ts\ntype Parsed = { label: string; params: string[] };\n\nconst LABEL = /^[\\x21-\\x2E\\x30-\\x39\\x3B-\\x5A\\x5C-\\x7E]+$/; // no space, '/', ':', '['\n\nexport function parseKey(key: string): Parsed | null {\n  const i = key.search(/[\\/:\\[]/);\n  if (i === -1) return LABEL.test(key) ? { label: key, params: [] } : null;\n  const label = key.slice(0, i);\n  if (!LABEL.test(label)) return null;\n\n  if (key[i] === \"[\") {\n    const rest = key.slice(i);\n    if (!/^(\\[[^\\]]*\\])+$/.test(rest)) return null; // unclosed or trailing text\n    return { label, params: [...rest.matchAll(/\\[([^\\]]*)\\]/g)].map((m) =\u003e m[1]) };\n  }\n\n  const param = key.slice(i + 1);\n  if (param.startsWith(\" \")) return null;            // \"key/ value\" is invalid\n  if (/\\[[^\\]]*\\]$/.test(param)) return null;        // reject mixed \"key/param[extra]\"\n  return { label, params: [param] };\n}\n\nparseKey(\"resource[chain][1]\"); // { label: \"resource\", params: [\"chain\", \"1\"] }\nparseKey(\"website/http://x.io\"); // { label: \"website\", params: [\"http://x.io\"] }\n```\n\n## 需要注意\n\n- **状态：Draft。** 格式仍可能变化。\n- 这纯粹是一种命名约定。它不需要新的合约接口，完全向后兼容；不带参数的合约不受影响。\n- 规范要求客户端验证用户提供的键，并拒绝格式错误的方括号输入，以避免不同解析器之间出现分歧。\n- 规范将 `key/param[extra]` 列为无效，但没有明确写出检测混用形式的具体规则；上面示例中的检查是一种合理的解读。\n"}},"requiredBy":[8041,8048]}
