---
eip: 8119
label: ERC-8119
title: Parameterized Storage Keys
status: Draft
type: Standards Track
category: ERC
created: 2025-01-06
official: https://eips.ethereum.org/EIPS/eip-8119
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-8119.md
canonical: https://eips.huatuo.xyz/eip-8119/
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]
---

# ERC-8119: Parameterized Storage Keys

> A format for parameterized string keys used in EVM key-value storage.

**TL;DR:** 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.

## What problem does it solve?

Many contracts store metadata in a `mapping(string => 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.

ERC-8119 picks one format so any client can split a key into a *label* and its *parameters*.

## How it works

There are two encodings.

**Slash/colon form (exactly one parameter):** `<key-label>/<key-parameter>` or `<key-label>:<key-parameter>`

- 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.
- 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'`.

**Bracket form (one or more parameters):** `<key-label>[<p1>][<p2>]...`

- The label runs up to the first `[`; then one or more bracketed parameters follow, e.g. `resource[chain][1][token][42]`.
- A parameter may contain anything except `]`. Nothing may follow the last `]`.

**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.

Invalid 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]`.

## Sample code

Storing parameterized keys in Solidity:

```solidity
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.25;

contract Metadata {
    mapping(string => bytes) private _metadata;

    function setMetadata(string calldata key, bytes calldata value) external {
        _metadata[key] = value; // e.g. "registration/1", "user[alice]"
    }

    function getMetadata(string calldata key) external view returns (bytes memory) {
        return _metadata[key];
    }
}
```

A simple client-side parser (TypeScript):

```ts
type Parsed = { label: string; params: string[] };

const LABEL = /^[\x21-\x2E\x30-\x39\x3B-\x5A\x5C-\x7E]+$/; // no space, '/', ':', '['

export function parseKey(key: string): Parsed | null {
  const i = key.search(/[\/:\[]/);
  if (i === -1) return LABEL.test(key) ? { label: key, params: [] } : null;
  const label = key.slice(0, i);
  if (!LABEL.test(label)) return null;

  if (key[i] === "[") {
    const rest = key.slice(i);
    if (!/^(\[[^\]]*\])+$/.test(rest)) return null; // unclosed or trailing text
    return { label, params: [...rest.matchAll(/\[([^\]]*)\]/g)].map((m) => m[1]) };
  }

  const param = key.slice(i + 1);
  if (param.startsWith(" ")) return null;            // "key/ value" is invalid
  if (/\[[^\]]*\]$/.test(param)) return null;        // reject mixed "key/param[extra]"
  return { label, params: [param] };
}

parseKey("resource[chain][1]"); // { label: "resource", params: ["chain", "1"] }
parseKey("website/http://x.io"); // { label: "website", params: ["http://x.io"] }
```

## Things to know

- **Status: Draft.** The format could still change.
- This is purely a naming convention. It needs no new contract interface and is fully backward compatible; contracts without parameters are unaffected.
- The spec asks clients to validate user-supplied keys and reject malformed bracket input to avoid different parsers disagreeing.
- 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.


---

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