Quick Start
Message classes for typed structured data hashing and signing in Ethereum. See EIP-712 for details.
Dependencies
- python3 version 3.10 up to 3.14.
Installation
via pip
You can install the latest release via pip:
pip install eip712
via uv
You can clone the repository and use uv for the most up-to-date version:
git clone https://github.com/ApeWorX/eip712.git
cd eip712
uv sync --group dev
Quick Usage
Define EIP-712 models:
from eip712.messages import EIP712Message
# NOTE: It is **highly** recommended to use ABI types from this library
from eth_pydantic_types import abi
from pydantic import BaseModel
# You can define your inner nested types using normal Pydantic models
class Person(EIP712Type):
# Define fields using types from the `abi` module
name: abi.string
wallet: abi.address
# All valid EIP712 Message Structs **must** subclass `EIP712Message`
class Mail(EIP712Message):
# to define your EIP712 domain configuration
eip712_domain = EIP712Domain(
name="Ether Mail",
version="1",
verifyingContract="0xDDdDddDdDdddDDddDDddDDDDdDdDDdDDdDDDDDDd",
chainId=1,
)
# Struct fields (can be "basic" types, `BaseModel` types, or arrays of either)
sender: Person
# Dynamic array support is as easy as using `list` with the corresponding type
receivers: list[Person]
ttl: abi.uint256
Then initialize these models:
sender = Person(name="Alice", wallet="0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa")
receivers = [
Person(name="Bob", wallet="0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"),
Person(name="Charlie", wallet="0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"),
]
mail = Mail(sender=sender, receiver=receiver)
Finally, you can sign these messages using eth-account:
from eth_account import Account
acct = Account.from_key(private_key)
sig = acct.sign_message(mail.signable_message)
or natively in Ape:
# `ape console`
me = accounts.load(me)
sig = me.sign_message(mail)
Release files for eip712 0.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| eip712-0.3.3.tar.gz | 61.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| eip712-0.3.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 73.3 kB
Release files / eip712-0.3.3.tar.gz
| Download URL | eip712-0.3.3.tar.gz |
|---|---|
| Size | 61.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a27a4ba832ad9e2838e779170148478f271f7f093a603dd33e2a7bbf86aae7cd
|
|
BLAKE2b-256 checksum How to use checksums |
25f704f45a50f4539dc259a6c45343861ba99c75c3d401b72d20b6350f5e01d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 23, 2025.
Transparency logRelease files / eip712-0.3.3-py3-none-any.whl
| Download URL | eip712-0.3.3-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
45113f0d9aa85d5ef8b415957f962b58f47c5f9343998865ec831ad6c604aa21
|
|
BLAKE2b-256 checksum How to use checksums |
fcd356e16f54b37bf013c304c66d6cdbe9f1ba8fe7799166873721d4e3519273
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 23, 2025.
Transparency log