Skill — Copyable reference implementation. Use as-is or customize. See Skills Philosophy.
Domain Separator
The domain separator cryptographically binds signatures to specific contract + chain combinations, preventing replay attacks.- 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:- Integers:
uint8throughuint256,int8throughint256 - Address:
address - Boolean:
bool - Fixed bytes:
bytes1throughbytes32 - 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:- 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:Complete Example: ERC-2612 Permit
Gasless token approvals using EIP-712:Validation
Validate typed data structure before signing:- Primary type exists in types
- All referenced types are defined
- Message fields match type definitions
- No circular type references
Error Handling
Security Best Practices
- Always include deadlines - Prevent signature reuse after expiry
- Use nonces - Contract tracks nonces to prevent replay
- Validate before signing - Call
validate()on user-provided data - Verify recovered address - Never trust signatures without verification
- Include chainId - Prevents cross-chain replay attacks

