Registry / auth-security / eip712

eip712

JSON →
library0.3.3pypypi✓ verified 89d ago

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.

pip install eip712
INSTALL
IMPORT
SIG · EIP712
E
eip712
auth-securitypythonv0.3.3
Install
6.5s avg
Import
1261ms
Disk
60MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.3.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.292s · 58.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 6.5s · import 1.230s · 62MB
60MB installed
● package 60MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EIP712Message
✓ from eip712 import EIP712Message
Correct import for the main message class.
EIP712Type
✓ from eip712 import EIP712Type
✗ from eip712.messages import EIP712Type
EIP712Type is exported from top-level eip712 since v0.3.0.
EIP712Domain
✓ from eip712 import EIP712Domain
✗ from eip712.domain import EIP712Domain
EIP712Domain is now directly available from eip712.

Define EIP-712 message structures using pydantic-based classes and generate the structured data for signing.

from eip712 import EIP712Message, EIP712Domain class Person(EIP712Message): name: str wallet: str class Mail(EIP712Message): from_: Person = Person(name='Alice', wallet='0x...') # field alias to: Person contents: str message = Mail( from_=Person(name='Alice', wallet='0x...'), to=Person(name='Bob', wallet='0x...'), contents='Hello!' ) print(message.to_message()) print(message.encode_712()) print(message.signable_message())
Debug
Known issues
breakingv0.3.0 replaced dataclassy with pydantic. If you subclasses EIP712Message directly, you need to adapt to pydantic behavior (e.g., field aliases, validation).
fix
Ensure you use pydantic field types and aliases instead of dataclassy patterns.
affects: >=0.3.0
breakingIn v0.3.0, EIP712Type was removed as a separate class. Inner types should be plain pydantic models or Python types.
fix
Remove EIP712Type subclass usage; define nested types as pydantic models directly.
affects: >=0.3.0
gotchaField names that conflict with Python keywords (e.g., 'from') must use pydantic aliasing with Field(alias=...).
fix
Use from eip712 import EIP712Message, Field; then define from_: str = Field(alias='from')
affects: >=0.3.0
deprecatedString type annotations like 'uint256' are deprecated; use pydantic numeric types (e.g., int, float) or custom validators.
fix
Replace 'uint256' with int and add pydantic validators if needed.
affects: >=0.3.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'eip712'
Library not installed.
fix
Run 'pip install eip712'
ImportError: cannot import name 'EIP712Type' from 'eip712'
EIP712Type was removed in version 0.3.0.
fix
Use pydantic models instead; or upgrade to a version <0.3.0 if you must use EIP712Type.
ValidationError: 1 validation error for Mail from_ field required
Field name 'from_' is used but pydantic treats it as a field name; likely missing alias.
fix
Define the field with an alias: from_: Person = Field(alias='from')
AttributeError: 'EIP712Message' object has no attribute 'to_message'
Method 'to_message' may not exist in older versions.
fix
Use 'encode_712()' or 'signable_message()' depending on needs. Check docstrings.
Upgrade
Version history
0.3.3latest on PyPI · released Dec 23, 2025
Audit
Dependencies
pydanticoptionalEIP712Message subclasses pydantic.BaseModel.
eth-accountoptionalUsed for signing and hash computation.
Agent activity
26 hits · last 30 days
node
24
Anthropic
1
OpenAI (training)
1
Resources
eip712 — pip install eip712 · libregistry