--- eip: 8230 title: Self-Explanatory Smart Contract Instruction description: An interface for self-explanatory smart contracts that expose operational instructions to AI agents. author: LucasZHANG (@wispig66) discussions-to: https://ethereum-magicians.org/t/erc-8230-self-explanatory-smart-contract-instruction/28223 status: Draft type: Standards Track category: ERC created: 2026-04-13 --- ## Abstract This ERC defines a single function `instruction()` that allows a smart contract to describe — in its own bytecode — how it should be used. The returned content is a Markdown string intended for AI agents and automated systems to read, interpret, and act upon. A contract that implements `instruction()` is **self-explanatory**: it carries its own operational documentation on-chain, with the same immutability and authority as the contract logic itself. ## Motivation AI agents are increasingly interacting with smart contracts on behalf of users. To do so effectively, an agent needs to understand not just *what functions exist* (the ABI), but *how to use the contract to accomplish a goal* — the roles, the workflow, the state machine, the edge cases. Today this knowledge lives in off-chain docs, READMEs, and human-written guides. It is separated from the contract, can go stale, can be censored, and cannot be programmatically discovered. There is no standard way for a contract to say: "here is how you use me." This ERC fills that gap with three design principles: ### 1. Self-Explanatory Contracts A contract should be able to explain itself. Just as NatSpec lets a contract document its functions for developers, `instruction()` lets a contract document its complete workflow for agents. The contract becomes its own manual. ### 2. On-Chain Authority The instruction is part of the contract's bytecode (when implemented as `pure`) or storage (when `view`). It is deployed, verified, and immutable alongside the contract logic. This gives the instruction the **same authority as the contract itself** — it cannot be altered, taken down, or fall out of sync independently. Off-chain documentation, no matter how well-maintained, can never make this guarantee. ### 3. AI-Native Format The instruction is Markdown — the format that large language models understand most naturally. No schema negotiation, no deserialization step, no tooling required. An agent reads the string and knows what to do. ### Relationship to Existing Standards | Standard | What it provides | Audience | |---|---|---| | ABI / NatSpec | Function-level signatures and developer docs | Developers | | [ERC-7572](./eip-7572.md) (`contractURI()`) | Contract identity (name, image) | Frontends | | [ERC-7730](./eip-7730.md) | Transaction display format | Wallets / humans | | **This ERC** (`instruction()`) | Complete operational workflow | **AI agents** | ## Specification The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174. ### Interface ```solidity // SPDX-License-Identifier: CC0-1.0 pragma solidity ^0.8.0; interface IInstruction { /// @notice Returns the operational instruction for this contract. /// @return A Markdown (CommonMark subset) string. function instruction() external view returns (string memory); } ``` That is the entire interface. One function, one string. The [ERC-165](./eip-165.md) identifier for this interface is `0x5e486e0f` (`bytes4(keccak256("instruction()"))`). Contracts that implement ERC-165 SHOULD return `true` for this identifier. ### Mutability - Contracts with static instructions SHOULD declare `instruction()` as `pure`. This guarantees immutability at the language level and costs zero gas to read. - Contracts whose instructions depend on runtime state (e.g., dynamically computed parameters) MAY declare it as `view`. ### Content Format: CommonMark Subset The returned string MUST conform to the following subset of CommonMark: **Allowed elements:** | Element | Syntax | Purpose | |---|---|---| | Headings | `#`, `##`, `###` | Document structure (max 3 levels) | | Bold / Italic | `**bold**`, `*italic*` | Emphasis | | Unordered lists | `- item` | Enumerations | | Ordered lists | `1. item` | Sequential steps | | Inline code | `` `code` `` | Function names, parameters, values | | Code blocks | ` ``` ` | Multi-line code, ABI fragments | | Tables | `\| col \| col \|` | Parameter tables, status code tables | | Blockquotes | `> text` | Callouts, important notes | | Links | `[text](url)` | References to external resources | **Disallowed elements:** - Raw HTML (`