Install & Compatibility
Where this runs
tested against v4.4.0 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 4.472s · 77.3MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 10.3s · import 4.106s · 82MB
80MB installed
● package 80MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SiweMessage
✓ from siwe import SiweMessage
Main class for creating and verifying SIWE messages.
generate_nonce
✓ from siwe import generate_nonce
Utility function to generate a random nonce.
Create and verify a SIWE message.
from siwe import SiweMessage, generate_nonce
from eth_account.messages import encode_defunct
from eth_account.account import Account
# Generate a nonce
nonce = generate_nonce()
# Create a SIWE message
message = SiweMessage(
domain='example.com',
address='0x1234...',
uri='https://example.com',
version='1',
chain_id=1,
nonce=nonce,
issued_at='2022-01-01T00:00:00Z'
)
# Prepare message for signing
prepared = message.prepare_message()
# (Typically you'd send `prepared` to the client to sign with their wallet)
# To verify, you need the signature from the wallet
# signature = '0x...' # signature from the client
# recovered_address = message.verify(signature=signature)
# print(recovered_address)
Errors
Common errors & fixes
AttributeError: module 'siwe' has no attribute 'SiweMessage'
Old import path or incomplete install; in v4.0.0+ the class is at the top level.
fixUse `from siwe import SiweMessage` (not `from siwe.siwe import SiweMessage`).
TypeError: verify() got an unexpected keyword argument 'message'
Using v4+ API but passing arguments from earlier versions.
fixCall `verify(signature=signature)` instead of `verify(message=..., signature=...)`.
ValueError: Invalid nonce length
The nonce must be at least 8 characters long according to EIP-4361. Some generated nonces may be shorter if using a custom one.
fixUse `generate_nonce()` from siwe which ensures proper length, or provide a nonce of at least 8 characters.
Upgrade
Version history
4.4.0latest on PyPI · released Oct 11, 2024
Audit
Dependencies
No dependency data recorded yet.