Registry / auth-security / poly-eip712-structs

poly-eip712-structs

JSON →
library0.0.1pypypi✓ verified 24d ago

A Python library providing a robust interface for constructing EIP-712 typed data structures. It simplifies the creation of structured messages that can be signed off-chain and verified on-chain, adhering to the Ethereum EIP-712 standard. The library is currently at version `0.0.1` and aims to streamline secure off-chain data signing.

pip install poly-eip712-structs
INSTALL
IMPORT
SIG · POLY-EIP712-STRUCT
P
poly-eip712-structs
auth-securitypythonv0.0.1
Install
5.5s avg
Import
648ms
Disk
63MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.1 · 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.103.95 runs
installs and imports cleanly · install 0.0s · import 0.662s · 61.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.5s · import 0.634s · 64MB
63MB installed
● package 63MB
Code
Verified usage

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

EIP712Struct
from poly_eip712_structs import EIP712Struct
from eip712_structs import EIP712Struct
Address
from poly_eip712_structs import Address
make_domain
from poly_eip712_structs import make_domain

This quickstart demonstrates how to define an EIP-712 domain, create a custom struct, instantiate it with data, and convert it into a signable EIP-712 message dictionary and its corresponding byte hash.

from eip712_structs import make_domain, EIP712Struct, String, Uint import os # Define a domain separator for the EIP-712 message domain = make_domain(name='My Application', version='1.0.0', chainId=1) # Define your custom EIP-712 struct type class MyStruct(EIP712Struct): some_string = String() some_number = Uint(256) # Create an instance of your struct with data my_data = MyStruct(some_string='hello world', some_number=1234) # Convert to EIP-712 message dictionary message_dict = my_data.to_message(domain) print(f"EIP-712 Message Dict: {message_dict}") # Get the signable bytes hash (e.g., for use with a private key) signable_bytes = my_data.signable_bytes(domain) print(f"Signable Bytes Hash: {signable_bytes.hex()}") # Example of setting/getting values dictionary-style my_data['some_number'] = 4567 assert my_data['some_number'] == 4567
Debug
Known issues
gotchaThe PyPI package is `poly-eip712-structs`, but the Python import name is `eip712_structs`. Ensure you use `from eip712_structs import ...` in your code.
fix
Always use `from eip712_structs import ...` for imports.
affects: All versions
gotchaBe aware of other packages named `eip712-structs` or `eip712-structs-ng` on PyPI which use the same `eip712_structs` import path. Installing multiple such packages might lead to import conflicts or unexpected behavior.
fix
Ensure only one EIP-712 struct implementation is installed in your environment, or manage import paths carefully if multiple are needed.
affects: All versions
gotchaThe `make_domain()` helper function for creating the EIP-712 domain separator requires at least one parameter (e.g., `name`, `version`, `chainId`) to be defined. Omitting all parameters will result in an invalid domain struct definition.
fix
Always provide at least one parameter when calling `make_domain()`.
affects: All versions
gotchaThe GitHub README states support for Python 3.6 and 3.7. However, the official PyPI metadata specifies `requires_python: >=3.9.10`. Users on older Python versions might encounter installation or runtime issues.
fix
Use Python 3.9.10 or newer for full compatibility as indicated by PyPI metadata.
affects: All versions
breakingAs the library is currently at version `0.0.1`, it is in an early development stage. Future updates, especially before a `1.0.0` release, may introduce breaking API changes without strict adherence to semantic versioning for non-major versions.
fix
Pin your dependency to a specific `0.0.x` version and review changelogs carefully when upgrading.
affects: <1.0.0
Upgrade
Version history
0.0.1latest on PyPI · released Jul 18, 2024
Audit
Dependencies
eth-utilsrequiredRequired for Ethereum utility functions.
pycryptodomerequiredRequired for cryptographic operations.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
poly-eip712-structs — pip install poly-eip712-structs · libregistry