---
eip: 7827
label: ERC-7827
title: JSON Contract with Value Version Control
status: Draft
type: Standards Track
category: ERC
created: 2024-11-07
official: https://eips.ethereum.org/EIPS/eip-7827
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7827.md
canonical: https://eips.huatuo.xyz/eip-7827/
lang: en
tldr: "A small contract interface that stores a JSON object on-chain, returns it as a string, and keeps the full history of every key's values, aimed at developers coming from REST APIs."
tags: [json, storage, versioning, developer-experience]
---

# ERC-7827: JSON Contract with Value Version Control

> Manage a JSON object onchain with per-key version history and a REST-like read interface.

**TL;DR:** A small contract interface that stores a JSON object on-chain, returns it as a string, and keeps the full history of every key's values, aimed at developers coming from REST APIs.

## What problem does it solve?

Developers from web backgrounds are used to REST endpoints that return JSON. Smart contracts, by contrast, expose typed getters, and reading structured data usually means learning the ABI for each contract.

ERC-7827 proposes a standard "JSON contract": you can fetch the whole object as a JSON string in one call, and every key keeps an append-only version history. The goal is to make on-chain data feel familiar to REST developers.

## How it works

Three functions:

| Function | Behavior |
| --- | --- |
| `json()` | Returns the current object as a JSON string |
| `version(key)` | Returns a JSON array string of all values the key has had, oldest first |
| `write(keys, values, replace)` | Adds or updates keys; with `replace = false` it reverts if a key already exists |

Values are treated as strings, leaving encoding efficiency to client libraries. Updates append to a key's history, so older values remain readable while `json()` shows only the latest.

Example from the spec:

1. `write(["name"], ["Alice"], false)` → `json()` is `{"name":"Alice"}`, history `["Alice"]`.
2. `write(["name"], ["Bob"], true)` → `{"name":"Bob"}`, history `["Alice","Bob"]`.
3. `write(["name"], ["Charlie"], false)` → reverts, because `name` exists.

## Sample code

The interface (non-normative in the spec) and a call from ethers v6:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IERC7827 {
    function json() external view returns (string memory);
    function version(string calldata key) external view returns (string memory);
    function write(string[] calldata keys, string[] calldata values, bool replace) external;
}
```

```ts
import { Contract, JsonRpcProvider } from "ethers";

const doc = new Contract(address, [
  "function json() view returns (string)",
  "function version(string key) view returns (string)",
], new JsonRpcProvider(process.env.RPC_URL));

const current = JSON.parse(await doc.json());          // { name: "Bob" }
const history = JSON.parse(await doc.version("name")); // ["Alice", "Bob"]
```

## Things to know

- **Status: Draft.** The interface may change.
- The spec does not define access control for `write`; real deployments need to decide who may write.
- Building JSON strings on-chain is gas-heavy, and histories only grow. The spec says implementations should guard against unbounded array writes and handle large objects carefully.
- Values are strings, so numbers, booleans and nested objects need an agreed encoding between writer and reader.
- For serving web-style responses from contracts more generally, see [ERC-5219](/eip-5219/).


---

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