{"id":23659,"library":"eip712","title":"eip712","description":"Message classes for typed structured data hashing and signing in Ethereum, based on EIP-712. Current version 0.3.3, requires Python >=3.10, <4. Maintained actively by ApeWorX.","status":"active","version":"0.3.3","language":"python","source_language":"en","source_url":"https://github.com/ApeWorX/eip712","tags":["eip712","ethereum","structured-data","signing","pydantic"],"install":[{"cmd":"pip install eip712","lang":"bash","label":"Default install"}],"dependencies":[{"reason":"EIP712Message subclasses pydantic.BaseModel.","package":"pydantic","optional":true},{"reason":"Used for signing and hash computation.","package":"eth-account","optional":true}],"imports":[{"note":"Correct import for the main message class.","symbol":"EIP712Message","correct":"from eip712 import EIP712Message"},{"note":"EIP712Type is exported from top-level eip712 since v0.3.0.","wrong":"from eip712.messages import EIP712Type","symbol":"EIP712Type","correct":"from eip712 import EIP712Type"},{"note":"EIP712Domain is now directly available from eip712.","wrong":"from eip712.domain import EIP712Domain","symbol":"EIP712Domain","correct":"from eip712 import EIP712Domain"}],"quickstart":{"code":"from eip712 import EIP712Message, EIP712Domain\n\nclass Person(EIP712Message):\n    name: str\n    wallet: str\n\nclass Mail(EIP712Message):\n    from_: Person = Person(name='Alice', wallet='0x...')  # field alias\n    to: Person\n    contents: str\n\nmessage = Mail(\n    from_=Person(name='Alice', wallet='0x...'),\n    to=Person(name='Bob', wallet='0x...'),\n    contents='Hello!'\n)\nprint(message.to_message())\nprint(message.encode_712())\nprint(message.signable_message())","lang":"python","description":"Define EIP-712 message structures using pydantic-based classes and generate the structured data for signing."},"warnings":[{"fix":"Ensure you use pydantic field types and aliases instead of dataclassy patterns.","message":"v0.3.0 replaced dataclassy with pydantic. If you subclasses EIP712Message directly, you need to adapt to pydantic behavior (e.g., field aliases, validation).","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Remove EIP712Type subclass usage; define nested types as pydantic models directly.","message":"In v0.3.0, EIP712Type was removed as a separate class. Inner types should be plain pydantic models or Python types.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Use from eip712 import EIP712Message, Field; then define from_: str = Field(alias='from')","message":"Field names that conflict with Python keywords (e.g., 'from') must use pydantic aliasing with Field(alias=...).","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Replace 'uint256' with int and add pydantic validators if needed.","message":"String type annotations like 'uint256' are deprecated; use pydantic numeric types (e.g., int, float) or custom validators.","severity":"deprecated","affected_versions":">=0.3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install eip712'","cause":"Library not installed.","error":"ModuleNotFoundError: No module named 'eip712'"},{"fix":"Use pydantic models instead; or upgrade to a version <0.3.0 if you must use EIP712Type.","cause":"EIP712Type was removed in version 0.3.0.","error":"ImportError: cannot import name 'EIP712Type' from 'eip712'"},{"fix":"Define the field with an alias: from_: Person = Field(alias='from')","cause":"Field name 'from_' is used but pydantic treats it as a field name; likely missing alias.","error":"ValidationError: 1 validation error for Mail\nfrom_\n  field required"},{"fix":"Use 'encode_712()' or 'signable_message()' depending on needs. Check docstrings.","cause":"Method 'to_message' may not exist in older versions.","error":"AttributeError: 'EIP712Message' object has no attribute 'to_message'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}