ERC-4430 · Stagnant · ERC · 2021-11-07
ERC-4430: Described Transactions
Proposed a contract method that returns both a human-readable description of an action and the exact calldata to perform it, so wallets can show users what they are signing instead of an opaque hex blob.
What problem does it solve?
When a wallet asks you to approve a transaction, it usually shows a contract address and a blob of calldata. Outside a few special-cased actions like ERC-20 transfers, the wallet has no idea what the call does, so the user signs blind.
Decoding the calldata does not always help either. The spec's example is ENS commit(bytes32): the argument is a hash of the name, owner and a secret, so the information a user would care about is not in the transaction at all.
EIP-4430 lets an honest contract explain itself. The contract author writes code that turns the user's original inputs into both a sentence and the matching calldata, and auditors can check that the two agree.
How it works
A contract exposes a "virtual function" (the spec still uses the placeholder name eipXXXDescribe):
function eipXXXDescribe(bytes inputs, bytes32 reserved)
view returns (string description, bytes execcode);
- The dapp gives the wallet the high-level
inputs(for ENS: name, owner, secret). - The wallet calls the method statically. During that call
ADDRESS,CALLER,VALUEandGASPRICEmust equal those of the transaction being described, so the description can depend on who is sending what. Block values should match the latest block, withCOINBASEset to zero. - The wallet shows
descriptionto the user. If they accept, it sends a transaction to the same contract withexeccodeas its data. - If the method reverts, signing is aborted.
Because the description and the calldata come out of one evaluation, the user approves the text and the machine executes the bytes that text was generated with.
Sample code
Illustrative wallet flow (ethers v6). The method name is a placeholder from the draft:
import { Contract, BrowserProvider, ZeroHash } from "ethers";
const provider = new BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const abi = ["function eipXXXDescribe(bytes inputs, bytes32 reserved) view returns (string, bytes)"];
const target = new Contract(contractAddress, abi, provider);
// Evaluate as the real sender, with the real value
const [description, execcode] = await target.eipXXXDescribe.staticCall(
encodedInputs, ZeroHash, { from: await signer.getAddress(), value }
);
if (await askUser(description)) { // show sanitized text
await signer.sendTransaction({ to: contractAddress, data: execcode, value });
}
Things to know
- Status: Stagnant. No final method name or selector was ever assigned, and wallets did not adopt it as a standard.
- It explicitly does not protect against malicious contracts: a contract can lie in its description. The security model relies on descriptions being audited with the code.
- Wallets must sanitize descriptions carefully: hidden HTML, homoglyphs, right-to-left marks and odd whitespace can all make text look like something it is not.
- For off-chain signatures, EIP-712 typed data addresses a related readability problem.