EIP-7749 · Draft · Interface · 2024-06-21
EIP-7749: Add wallet_signIntendedValidatorData method
A wallet RPC method for ERC-191 version 0x00 signatures, which bind a signature to one intended validator contract and are simpler than EIP-712 yet safer than eth_sign.
What problem does it solve?
Wallets today mostly offer two ways to sign arbitrary messages:
personal_sign/eth_sign(ERC-191 version0x45): easy to use, but the wallet just shows opaque bytes, which makes phishing easy.eth_signTypedData(EIP-712): structured and readable, but often seen as heavy for simple cases.
ERC-191 also defines version 0x00, "data with intended validator": the signed bytes include the address of the contract that is supposed to verify the signature. That fits smart accounts, entry points and key managers well, but no standard RPC method exposes it, so dapps resort to raw signing that many wallets restrict. EIP-7749 adds that method.
How it works
wallet_signIntendedValidatorData takes three parameters:
signerAddress: the account that signs.validatorAddress: the contract (or EOA) that is meant to verify the signature.dataToSign: the payload, as hex.
The wallet signs:
keccak256(0x19 ‖ 0x00 ‖ validatorAddress ‖ dataToSign)
and returns the 65-byte signature. Because the wallet knows the structure, it can show the user which validator the signature is for. A signature intended for contract A cannot be replayed at contract B, as long as B checks that the validator address equals itself.
Sample code
Request from a dapp (EIP-1193 provider):
const signature = await window.ethereum.request({
method: "wallet_signIntendedValidatorData",
params: [
"0x6aFbBC5e6AFcB251371711a6551E60ead2779Dc0", // signer
"0x345B918b9E06fAa7B0e56bd71Ba418F31F47FED4", // intended validator
"0x59616d656e", // data ("Yamen")
],
});
Computing the same digest and verifying it off-chain (ethers v6):
import { solidityPacked, keccak256, recoverAddress } from "ethers";
function intendedValidatorHash(validator: string, data: string): string {
return keccak256(solidityPacked(["bytes1", "bytes1", "address", "bytes"], ["0x19", "0x00", validator, data]));
}
const digest = intendedValidatorHash("0x345B918b9E06fAa7B0e56bd71Ba418F31F47FED4", "0x59616d656e");
console.log(recoverAddress(digest, signature)); // should equal the signer
On-chain, the validator rebuilds the hash with itself as the address:
bytes32 digest = keccak256(abi.encodePacked(bytes1(0x19), bytes1(0x00), address(this), data));
address signer = ECDSA.recover(digest, signature);
Things to know
- Status is Draft: do not assume wallets support the method; handle a "method not found" error and fall back to another signing method.
- The format does not include a chain ID or nonce. The spec advises putting them inside
dataToSignto prevent replay across chains and repeated use. - The wallet can show the validator address, but
dataToSignis still raw bytes. For anything users need to read, EIP-712 remains the better choice. - Smart accounts verifying via ERC-1271 can accept this format as one of several supported signature schemes.