eip712: Message classes for typed structured data hashing and signing in Ethereum
Project description
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eip712-0.3.3.tar.gz.
File metadata
- Download URL: eip712-0.3.3.tar.gz
- Upload date:
- Size: 61.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a27a4ba832ad9e2838e779170148478f271f7f093a603dd33e2a7bbf86aae7cd
|
|
| MD5 |
eed96c651616d1c75a785f476f3c7ca4
|
|
| BLAKE2b-256 |
25f704f45a50f4539dc259a6c45343861ba99c75c3d401b72d20b6350f5e01d8
|
Provenance
The following attestation bundles were made for eip712-0.3.3.tar.gz:
Publisher:
publish.yaml on ApeWorX/eip712
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eip712-0.3.3.tar.gz -
Subject digest:
a27a4ba832ad9e2838e779170148478f271f7f093a603dd33e2a7bbf86aae7cd - Sigstore transparency entry: 777799691
- Sigstore integration time:
-
Permalink:
ApeWorX/eip712@95495f0407a2ab3858449258a13da0bef2995a87 -
Branch / Tag:
refs/tags/v0.3.3 - Owner: https://github.com/ApeWorX
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@95495f0407a2ab3858449258a13da0bef2995a87 -
Trigger Event:
release
-
Statement type:
File details
Details for the file eip712-0.3.3-py3-none-any.whl.
File metadata
- Download URL: eip712-0.3.3-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45113f0d9aa85d5ef8b415957f962b58f47c5f9343998865ec831ad6c604aa21
|
|
| MD5 |
a750a32cc8871d9eda3062c240652d20
|
|
| BLAKE2b-256 |
fcd356e16f54b37bf013c304c66d6cdbe9f1ba8fe7799166873721d4e3519273
|
Provenance
The following attestation bundles were made for eip712-0.3.3-py3-none-any.whl:
Publisher:
publish.yaml on ApeWorX/eip712
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eip712-0.3.3-py3-none-any.whl -
Subject digest:
45113f0d9aa85d5ef8b415957f962b58f47c5f9343998865ec831ad6c604aa21 - Sigstore transparency entry: 777799702
- Sigstore integration time:
-
Permalink:
ApeWorX/eip712@95495f0407a2ab3858449258a13da0bef2995a87 -
Branch / Tag:
refs/tags/v0.3.3 - Owner: https://github.com/ApeWorX
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@95495f0407a2ab3858449258a13da0bef2995a87 -
Trigger Event:
release
-
Statement type: