ERC-6384 · Stagnant · ERC · 2023-01-08
ERC-6384: Human-readable offline signatures
Proposes an evalEIP712Buffer view function on the verifying contract so wallets can show users a plain-language description of an EIP-712 message before they sign it.
What problem does it solve?
Off-chain signatures in EIP-712 format are everywhere: token permits (ERC-2612), NFT marketplace listings, order books. They are gas-free for the user, but the signature can later be used on chain by someone else. Phishing sites exploit this: they ask the victim to sign a message that, for example, lists their NFT for sale at almost zero price. Wallets typically display the raw typed fields, which most users cannot interpret, so they sign blindly.
ERC-6384 proposes letting the contract that will eventually consume the signature explain the message in human-readable terms.
How it works
EIP-712 messages already name a verifyingContract in their domain. ERC-6384 asks such contracts to implement a view function:
function evalEIP712Buffer(
bytes32 domainHash, // the EIP-712 domain separator
string memory primaryType, // the EIP-712 primaryType
bytes memory typedDataBuffer // ABI-encoded message part
) external view returns (string[] memory);
Flow:
- A dApp asks the wallet to sign an EIP-712 message.
- The wallet calls
evalEIP712Bufferon theverifyingContractwith the message data (a freeeth_call). - The contract returns one or more plain strings, e.g. "Sell NFT #1234 for 0.0001 ETH". The wallet shows them to the user, optionally enriched (for example by resolving addresses to names).
The trust argument: the message comes from a possibly malicious website, but the verifying contract is controlled by the legitimate protocol. An attacker cannot swap in a different contract, because then the signature would not be accepted on chain.
Rules worth knowing:
- An array is returned so multi-part messages (several transfers) can be shown one per line.
- The strings must be treated as untrusted input and rendered as plain text, not HTML.
- If the domain has no
verifyingContract, wallets must not use this method and should fall back to their normal display.
Sample code
A contract describing its own TransferWithSig message (simplified):
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
contract MyToken {
function evalEIP712Buffer(bytes32, string memory primaryType, bytes memory buf)
external view returns (string[] memory out)
{
require(keccak256(bytes(primaryType)) == keccak256("TransferWithSig"), "unknown type");
(address from, address to, uint256 amount, , ) =
abi.decode(buf, (address, address, uint256, uint256, uint256));
out = new string[](1);
out[0] = string.concat(
"Transfer ", Strings.toString(amount), " tokens from ",
Strings.toHexString(from), " to ", Strings.toHexString(to)
);
}
}
Wallet side (ethers v6):
const c = new Contract(domain.verifyingContract, [
"function evalEIP712Buffer(bytes32,string,bytes) view returns (string[])",
], provider);
const lines: string[] = await c.evalEIP712Buffer(domainHash, primaryType, encodedMessage);
lines.forEach((l) => ui.appendText(l)); // render as plain text
Things to know
- Status: Stagnant. Few contracts or wallets are known to implement it; do not rely on it being available.
- It only helps when the verifying contract is honest. A malicious contract could return misleading text, but the spec argues such a contract could already cause harm without this function.
- The description is only as accurate as the contract's decoding code, and adding it costs contract size for every supported message type.
- ERC-5267 is a related, Final standard that lets wallets retrieve a contract's EIP-712 domain.