{"id":24594,"library":"siwe","title":"Sign-In with Ethereum","description":"A Python implementation of Sign-In with Ethereum (EIP-4361). Supports parsing, verifying, and generating EIP-4361 messages for Ethereum authentication. Current version 4.4.0, requires Python >=3.8, <4.0. Actively maintained.","status":"active","version":"4.4.0","language":"python","source_language":"en","source_url":"https://github.com/spruceid/siwe-py","tags":["ethereum","siwe","eip-4361","authentication","web3"],"install":[{"cmd":"pip install siwe","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Main class for creating and verifying SIWE messages.","wrong":"","symbol":"SiweMessage","correct":"from siwe import SiweMessage"},{"note":"Utility function to generate a random nonce.","wrong":"","symbol":"generate_nonce","correct":"from siwe import generate_nonce"}],"quickstart":{"code":"from siwe import SiweMessage, generate_nonce\nfrom eth_account.messages import encode_defunct\nfrom eth_account.account import Account\n\n# Generate a nonce\nnonce = generate_nonce()\n\n# Create a SIWE message\nmessage = SiweMessage(\n    domain='example.com',\n    address='0x1234...',\n    uri='https://example.com',\n    version='1',\n    chain_id=1,\n    nonce=nonce,\n    issued_at='2022-01-01T00:00:00Z'\n)\n\n# Prepare message for signing\nprepared = message.prepare_message()\n\n# (Typically you'd send `prepared` to the client to sign with their wallet)\n# To verify, you need the signature from the wallet\n# signature = '0x...'  # signature from the client\n# recovered_address = message.verify(signature=signature)\n# print(recovered_address)\n","lang":"python","description":"Create and verify a SIWE message."},"warnings":[{"fix":"Use `message.verify(signature=signature)` instead of passing separate arguments or calling deprecated methods.","message":"In v4.0.0, the signature verification API changed: `verify` now requires the `signature` parameter and no longer accepts `message` param. Also, `SiweMessage` no longer has a `check_valid` method.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Import directly from the top-level `siwe` package: `from siwe import SiweMessage`.","message":"Using `from siwe import SiweMessage` is correct, but importing from submodules like `siwe.siwe` is deprecated and may break in future versions.","severity":"deprecated","affected_versions":"<4.0.0"},{"fix":"Compare the recovered address to the expected signer: `recovered = message.verify(signature=signature); assert recovered == expected_address`.","message":"The `verify` method returns the recovered address (a string) on success, not a boolean. Many users expect a boolean and incorrectly check `if message.verify(signature)`. This will always be truthy if a valid address is returned.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"search_vec":"'-4361':16,23,40 '3.8':33 '4.0':34 '4.4.0':30 'activ':35 'authent':27,41 'current':28 'eip':15,22,39 'ethereum':5,14,26,37 'generat':21 'implement':8 'maintain':36 'messag':24 'pars':18 'python':7,32 'requir':31 'sign':2,11 'sign-in':1,10 'siw':38 'support':17 'verifi':19 'version':29 'web3':42","created_at":"2026-05-01T08:13:55.057042+00:00","updated_at":"2026-05-01T08:13:55.057042+00:00","problems":[{"fix":"Use `from siwe import SiweMessage` (not `from siwe.siwe import SiweMessage`).","cause":"Old import path or incomplete install; in v4.0.0+ the class is at the top level.","error":"AttributeError: module 'siwe' has no attribute 'SiweMessage'"},{"fix":"Call `verify(signature=signature)` instead of `verify(message=..., signature=...)`.","cause":"Using v4+ API but passing arguments from earlier versions.","error":"TypeError: verify() got an unexpected keyword argument 'message'"},{"fix":"Use `generate_nonce()` from siwe which ensures proper length, or provide a nonce of at least 8 characters.","cause":"The nonce must be at least 8 characters long according to EIP-4361. Some generated nonces may be shorter if using a custom one.","error":"ValueError: Invalid nonce length"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.4.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://login.xyz","github":"https://github.com/ethereum/EIPs","docs":null,"changelog":null,"pypi":"https://pypi.org/project/siwe/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["auth-security","llm-agents"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}