ERC-3224 · Stagnant · ERC · 2021-01-23
ERC-3224: Described Data
Proposes that a contract computes both a human-readable description and the exact calldata or message to sign, so wallets can show users "Send 3.14 TOKN to ricmoose.eth?" instead of an opaque hex blob.
What problem does it solve?
When a wallet asks you to sign a transaction or message, it usually shows raw hex. Outside a few special-cased actions (like ERC-20 transfers) the user cannot tell what they are approving.
Decoding the final calldata is often not enough. The spec's example is ENS commit(bytes32): the name being registered is hidden inside a hash, so nothing in the calldata says which name you are committing to.
ERC-3224 flips the approach. Instead of the wallet decoding data, the dapp gives the wallet higher-level inputs, and the contract itself, running as a read-only describer, returns both a description and the bytes to actually sign.
How it works
A describer contract implements one view method (the spec still uses a placeholder name):
function eipXXXDescribe(bytes describer_inputs)
view returns (string description_string, bytes described_data);
- The wallet calls it statically with the real
to,from,valueand gas price, so the code can tailor the text. description_stringstarts with a MIME type and a semicolon; onlytext/plain;is defined, e.g.text/plain;Log into ethereum.org?.described_datais what gets signed: the transaction's calldata, or the message body.- If the method reverts, signing is aborted.
Three JSON-RPC methods are proposed for wallets:
| Method | Result |
|---|---|
eth_signDescribedMessage(address, describer, describerInput) |
description, described data and an EIP-191 signature |
eth_sendDescribedTransaction(address, tx) |
description and the signed, sent transaction |
eth_signDescribedTransaction(address, tx) |
description and the signed (not sent) transaction |
Messages are signed under EIP-191 version 0x00 ("data with intended validator"), with the describer's address included, so a signature for one contract cannot be replayed against another:
0x19 0x00 <describer address> <described data>
Sample code
A describer for an ERC-20-style transfer (illustrative; method name per the draft):
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
contract DescribedToken {
function transfer(address to, uint256 amount) external returns (bool) { /* ... */ }
function eipXXXDescribe(bytes calldata input)
external view returns (string memory description, bytes memory data)
{
require(bytes4(input[:4]) == this.transfer.selector, "unsupported");
(address to, uint256 amount) = abi.decode(input[4:], (address, uint256));
description = string.concat(
"text/plain;Send ", Strings.toString(amount),
" units to ", Strings.toHexString(to), "?"
);
data = abi.encodeCall(this.transfer, (to, amount));
}
}
Things to know
- Status is Stagnant. The method name is still a placeholder, and the spec's test vectors target Ropsten, a testnet that has since been shut down. Wallets did not adopt these RPC methods; structured signing with EIP-712 is the widespread alternative.
- It only helps honest contracts. A malicious contract can return a misleading description; the authors rely on audits reviewing describer code alongside the contract.
- Wallets must sanitise description text: hidden HTML, invisible whitespace, homoglyphs and right-to-left marks can make
not-ricmoo.ethlook likericmoo.eth. - Signed messages have no built-in nonce. Describers should embed one (e.g. a timestamp) when replay matters, as in a login flow.