---
eip: 7654
label: ERC-7654
title: Request Method Types
status: Draft
type: Standards Track
category: ERC
created: 2024-03-13
official: https://eips.ethereum.org/EIPS/eip-7654
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7654.md
canonical: https://eips.huatuo.xyz/eip-7654/
lang: en
tldr: "A draft interface that exposes a contract's functions through HTTP-like GET, POST and PUT entry points with self-describing parameter types, so clients can discover and call any contract the same way."
tags: [interface, api, discovery, rest, draft]
---

# ERC-7654: Request Method Types

> Use a set of request methods to indicate the type of action to take on the contract.

**TL;DR:** A draft interface that exposes a contract's functions through HTTP-like GET, POST and PUT entry points with self-describing parameter types, so clients can discover and call any contract the same way.

## What problem does it solve?

Every contract has its own function names and argument lists. A client must know a contract's ABI in advance to do anything with it, and there is no common way to ask a contract "what can you do and what does each action expect?".

ERC-7654 borrows the familiar web pattern of request methods. Instead of arbitrary functions, a contract exposes a fixed set of entry points (`get`, `post`, `put`) plus discovery functions. A client can then list the available methods, read their instructions and parameter types, and call them generically.

## How it works

There are four method types:

| Type | Meaning | Safe (read-only)? |
| --- | --- | --- |
| `GET` | read records | yes |
| `POST` | create a record | no |
| `PUT` | update a record | no |
| `OPTIONS` | list supported method types | yes |

There is deliberately no `DELETE`: deleting on-chain data is inefficient, so the spec suggests a `PUT` that marks records invalid and a `GET` that hides them.

The client workflow:

1. `options()` to see which method types the contract supports.
2. `getMethods(type)` to list method names for a type.
3. `getMethodInstruction(name)` to read a human-readable description.
4. `getMethodReqAndRes(name)` to get the request and response parameter types (an enum of Solidity types from the spec's `Types` library).
5. ABI-encode the request and call `get`, `post` or `put` with the method name.
6. ABI-decode the `bytes` response. `post` and `put` also emit `Response(bytes)`.

## Sample code

Interface excerpt:

```solidity
// SPDX-License-Identifier: CC0-1.0
pragma solidity >=0.8.0;

interface IRequestMethodTypes {
    enum MethodTypes { GET, POST, PUT, OPTIONS }

    event Response(bytes _response);

    function getMethods(MethodTypes _methodTypes) external view returns (string[] memory);
    function getMethodInstruction(string memory _methodName) external view returns (string memory);
    function get(string memory _methodName, bytes memory _methodReq) external view returns (bytes memory);
    function post(string memory _methodName, bytes memory _methodReq) external payable returns (bytes memory);
    function put(string memory _methodName, bytes memory _methodReq) external payable returns (bytes memory);
    function options() external returns (MethodTypes[] memory);
}
```

Calling a hypothetical `getUser` method (ethers v6):

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

const abi = AbiCoder.defaultAbiCoder();
const c = new Contract(addr, [
  "function getMethods(uint8) view returns (string[])",
  "function get(string,bytes) view returns (bytes)",
], provider);

console.log(await c.getMethods(0)); // GET methods, e.g. ["getUser"]
const raw = await c.get("getUser", abi.encode(["address"], [userAddress]));
const [name, score] = abi.decode(["string", "uint256"], raw);
```

## Things to know

- Status is **Draft**; the interface may still change.
- Methods are dispatched by string name and arguments are packed into `bytes`, which costs extra gas and loses compile-time type checking compared with ordinary typed functions.
- Standard tools (explorers, wallets, ERC-20/721 integrations) expect normal function selectors, so a contract using only this pattern will not be recognised by them.
- `post` and `put` change state and must have their own access control; the method type labels are descriptive, not enforced.


---

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