Skip to main content
Skill — Copyable reference implementation. Use as-is or customize. See Skills Philosophy.
EIP-712 enables human-readable message signing with domain separation. Instead of signing opaque hex blobs, users see structured data in their wallet prompts.

Domain Separator

The domain separator cryptographically binds signatures to specific contract + chain combinations, preventing replay attacks.
Domain fields:
  • name: DApp name shown to user
  • version: Versioning for signature schema changes
  • chainId: Prevents cross-chain replay (mainnet=1, polygon=137)
  • verifyingContract: Contract that will verify the signature
  • salt (optional): Additional entropy for extra separation

Type Definitions

Define message structure using Solidity-like type definitions:
Supported types:
  • Integers: uint8 through uint256, int8 through int256
  • Address: address
  • Boolean: bool
  • Fixed bytes: bytes1 through bytes32
  • Dynamic: bytes, string
  • Arrays: type[], type[N]
  • Custom structs: Referenced by name

Hashing Typed Data

Complete typed data combines domain, types, primary type, and message:

Signing Typed Data

Sign with a private key to produce ECDSA signature:
The signature can be submitted to:
  • Smart contracts via ecrecover
  • Relayers for meta-transactions
  • Order books for DEX orders

Verifying Typed Signatures

Recover the signer’s address and verify it matches expected:
Verification uses constant-time comparison to prevent timing attacks.

Complete Example: ERC-2612 Permit

Gasless token approvals using EIP-712:

Validation

Validate typed data structure before signing:
Validation checks:
  • Primary type exists in types
  • All referenced types are defined
  • Message fields match type definitions
  • No circular type references

Error Handling

Security Best Practices

  1. Always include deadlines - Prevent signature reuse after expiry
  2. Use nonces - Contract tracks nonces to prevent replay
  3. Validate before signing - Call validate() on user-provided data
  4. Verify recovered address - Never trust signatures without verification
  5. Include chainId - Prevents cross-chain replay attacks

API Reference