Skip to main content

🧪 Experimental

Integrating with eth-account

Privy EVM wallets natively integrate with the Python eth-account library, allowing you to use the library's interfaces for signing messages, signing typed data, sending transactions, and more.

To integrate with eth-account, first install the library as a dependency:

pip install privy-eth-account

Then, use Privy's create_eth_account function to initialize an instance of an Account for an EVM server wallet. As parameters to this function, pass:

Parameter Type Description
client PrivyHTTPClient Instance of the Privy HTTP client for your app.
address str Ethereum address of the wallet.
wallet_id str ID of the wallet.

Here's an example showing how to integrate with eth-account:

from privy_eth_account import create_eth_account, PrivyHTTPClient
from eth_account.messages import encode_typed_data, encode_defunct

# Initialize your Privy client
client = PrivyHTTPClient(
    app_id="YOUR_APP_ID",
    app_secret="YOUR_APP_SECRET",
    authorization_key="YOUR_AUTHORIZATION_KEY"
)

# Create an account instance for a wallet
wallet_id = "insert-wallet-id"
wallet_address = "insert-wallet-address"
account = create_eth_account(client, wallet_address, wallet_id)

Once you created an account instance, you can use it to sign messages, sign transactions, and sign typed data:

Sign a message

# Signing a message (personal_sign)
message = encode_defunct(text="Hello, Privy!")
signed_message = account.sign_message(message)
print(f"Signed message: {signed_message}")

Sign a transaction

# Signing a transaction
transaction = {
    "to": "0x123...789",
    "value": 100,
    "chain_id": 8453
}
signed_tx = account.sign_transaction(transaction)
print(f"Signed transaction: {signed_tx}")

Signing EIP-712 Typed Data

# Example EIP-712 typed data
# Structure your typed data as a full message
full_message = {
    "domain": {
        "name": "My App",
        "version": "1",
        "chainId": 8453,
        "verifyingContract": "0xCc9c3D98163F4F6Af884e259132e15D6d27A5c57",
        "salt": "pepper"
    },
    "types": {
        'EIP712Domain': [
            {'name': 'name', 'type': 'string'},
            {'name': 'version', 'type': 'string'},
            {'name': 'chainId', 'type': 'uint256'},
            {'name': 'verifyingContract', 'type': 'address'},
            {'name': 'salt', 'type': 'string'}
        ],
        'Person': [
            {'name': 'name', 'type': 'string'},
            {'name': 'wallet', 'type': 'address'}
        ],
        'Mail': [
            {'name': 'from', 'type': 'Person'},
            {'name': 'to', 'type': 'Person'},
            {'name': 'contents', 'type': 'string'}
        ]
    },
    "message": {
        "from": {
            "name": "Alice",
            "wallet": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e"
        },
        "to": {
            "name": "Bob",
            "wallet": "0xCc9c3D98163F4F6Af884e259132e15D6d27A5c57"
        },
        "contents": "Hello, Bob!"
    },
    "primaryType": "Mail"
}

# Sign the typed data using the full_message parameter
signed_typed_data = account.sign_typed_data(full_message=full_message)
print(f"Signed typed data: {signed_typed_data}")

Metadata

Release files for privy-eth-account 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for privy-eth-account 0.1.0
File Size Uploaded Provenance
privy_eth_account-0.1.0.tar.gz 5.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for privy-eth-account 0.1.0
File Interpreter ABI Platform
privy_eth_account-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / privy_eth_account-0.1.0.tar.gz

Download URL privy_eth_account-0.1.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aadcffff42497e2d87f3ffe225a9a0799876afe58f4c7b91d8e20795a1dbbd1e
BLAKE2b-256 checksum
How to use checksums
ef6724ec603ae8ddbd2ce0573cbf471b5f00f7fcd44818f79c6ff123ded357b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.3 Darwin/24.1.0

Release files / privy_eth_account-0.1.0-py3-none-any.whl

Download URL privy_eth_account-0.1.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff0d83dba811e423c3e504ca8d6f5dcd22931b7835c885f8e49c007139974d32
BLAKE2b-256 checksum
How to use checksums
d78de30173ee459fa7b2f6ff93dfa48a2ba1d44b3d20b73e6c3240987ce9cd15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.3 Darwin/24.1.0

Security for privy-eth-account 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page