Skip to main content

A Python implementation of Sign-In with Ethereum (EIP-4361).

Project description

with Ethereum

This package provides a Python implementation of EIP-4631: Sign In With Ethereum.


SIWE can be easily installed in any Python project with pip:

pip install siwe


SIWE provides a SiweMessage class which implements EIP-4361.

Parsing a SIWE Message

Parsing is done by initializing a SiweMessage object with an EIP-4361 formatted string:

message: SiweMessage = SiweMessage(message=eip_4361_string)

Alternatively, initialization of a SiweMessage object can be done with a dictionary containing expected attributes:

message: SiweMessage = SiweMessage(message={"domain": "", "address": "0x1234...", ...})

Verifying and Authenticating a SIWE Message

Verification and authentication is performed via EIP-191, using the address field of the SiweMessage as the expected signer. The validate method checks message structural integrity, signature address validity, and time-based validity attributes.

if message.validate():
    # Valid
    # Invalid

Serialization of a SIWE Message

SiweMessage instances can also be serialized as their EIP-4361 string representations via the sign_message method:



Parsing and verifying a SiweMessage is easy:

message: SiweMessage = SiweMessage(message=eip_4361_string)

    if not message.validate():
        # Authentication attempt rejected.
except SiweError.EXPIRED_MESSAGE:
    # Authentication attempt rejected.
    # Authentication attempt rejected.
    # Authentication attempt rejected.
# Message has been validated. Authentication complete. Continue with authorization/other.


  • Support for contract wallets.

See Also

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

siwe-0.1.1.tar.gz (12.3 kB view hashes)

Uploaded Source

Built Distribution

siwe-0.1.1-py3-none-any.whl (8.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page