Metadata-Version: 2.3
Name: privy-eth-account
Version: 0.1.0
Summary: 
Author: imti
Author-email: imti@privy.io
Requires-Python: >=3.9.2,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: cryptography (>=44.0.3,<45.0.0)
Requires-Dist: eth-account (>=0.13.7,<0.14.0)
Requires-Dist: eth-utils (>=5.3.0,<6.0.0)
Requires-Dist: hexbytes (>=1.3.0,<2.0.0)
Requires-Dist: httpx (>=0.28.1,<0.29.0)
Requires-Dist: hyperliquid-python-sdk (>=0.14.1,<0.15.0)
Description-Content-Type: text/markdown

## 🧪 Experimental

### Integrating with [`eth-account`](https://pypi.org/project/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:

```sh
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`:

```Python
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

```Python
# 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

```Python
# 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

```Python
# 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}")
```
