permit(...) on-chain.
Spot the Replay Bug
Suppose you ask the user to sign a plain string with EIP-191 (personal_sign):
- Cross-chain replay: An attacker takes the exact same signature and replays it on Arbitrum, Optimism, and Base where the user also holds USDC.
- Cross-contract replay: If two tokens share the same message format, a signature meant for a testnet token works on mainnet.
- Opaque wallet UX: Wallets show raw hex or unstructured text, so users cannot verify what they are signing.
How EIP-712 Fixes All Three
EIP-712 binds every signature to a domain separator (name, version,chainId, verifyingContract) and a typed struct hash, joined under the \x19\x01 prefix:
Why 0x19 0x01? EIP-191 reserves 0x19 as a leading byte that can never be valid RLP (an RLP transaction list starts at 0xc0–0xff, and typed EIP-2718 envelopes use 0x01–0x04). That guarantees an EIP-712 digest can never collide with a valid Ethereum transaction!
Step-by-Step: Sign, Transmit, and Verify a Permit
1
Define the EIP-712 typed data payload
2
Compute the digest and sign on the client
3
Verify on the relayer before paying gas
Your relayer must verify the signature offline before submitting it on-chain so attackers cannot drain your relayer’s ETH with invalid permits:
4
Prove cross-chain replay fails
Flip
chainId from 1n (Ethereum) to 42161n (Arbitrum) and try verifying the exact same signature:Check your understanding: Why does signature verification pass the signature FIRST in Secp256k1.recoverPublicKey(signature, digest)?
Check your understanding: Why does signature verification pass the signature FIRST in Secp256k1.recoverPublicKey(signature, digest)?
Voltaire follows a consistent data-first convention: the object being inspected (
signature) comes first, followed by the context it operates against (digest). When in doubt, TypeScript’s branded types (SignatureType vs HashType) catch reversed arguments at compile time.What You Built
- Bound an ERC-20 Permit signature to
chainIdandverifyingContractvia EIP-712. - Signed and recovered the signer offline using
EIP712andSecp256k1. - Proved that replaying the signature on another chain fails verification immediately.

