Metadata-Version: 2.4
Name: abstract_wallet
Version: 1.0.0b1
Summary: A software development kit for creating and managing ERC-4337 smart contract accounts on ethereum and ethereum layer-2 blockchains.
Author: Davide Casale
License-Expression: MIT
Project-URL: Homepage, https://github.com/davi0k/abstract-wallet
Project-URL: Documentation, https://github.com/davi0k/abstract-wallet/tree/main/docs
Project-URL: Repository, https://github.com/davi0k/abstract-wallet
Project-URL: Issues, https://github.com/davi0k/abstract-wallet/issues
Keywords: wallet,bip-32,erc-4337
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.13
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: ecdsa>=0.19.2
Requires-Dist: eth-utils>=6.0.0
Requires-Dist: eth_abi>=5.2.0
Requires-Dist: eth-account>=0.13.7
Requires-Dist: pyhumps>=3.8.0
Requires-Dist: requests>=2.33.1
Requires-Dist: safe-pysha3>=1.0.5
Dynamic: license-file

# abstract-wallet

[![Python 3.13](https://img.shields.io/badge/python-3.13-blue.svg)](https://www.python.org/downloads/release/python-3130/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

A software development kit for creating and managing [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337) smart contract accounts on ethereum and ethereum layer-2 blockchains.

## Installation

```console
pip install abstract_wallet
```

## Quickstart

```python
from abstract_wallet import AbstractWallet

seed_phrase = AbstractWallet.get_random_seed_phrase()

wallet = AbstractWallet(seed_phrase, {
    "provider": "https://eth-mainnet.g.alchemy.com/v2/<YOUR API-KEY>",
    "url": "https://api.pimlico.io/v2/1/rpc?apikey=<YOUR API-KEY>",
    "entry_point": "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
    "factory": "0x9406Cc6185a346906296840746125a0E44976454"
})

account = wallet.get_account(0)

print(f"Address: {account.address}")

print(f"Balance: {account.get_balance()} wei")
```

## Configuration

The `BundlerConfig` dictionary accepts the following fields:

| Field | Type | Required | Description |
|---|---|---|---|
| `provider` | `str` | Yes | URL of a JSON-RPC provider (e.g. Alchemy, Infura). |
| `url` | `str` | Yes | URL of the ERC-4337 bundler (e.g. Pimlico, Stackup). |
| `entry_point` | `str` | Yes | Address of the EntryPoint contract. |
| `factory` | `str` | Yes | Address of a SimpleAccountFactory contract. |
| `paymaster` | `str` | No | Address of a paymaster contract to sponsor operations. |
| `paymaster_data` | `bytes` | No | Data to pass to the paymaster. |

## Sending a user operation

```python
hash = account.send_user_operation({
    "to": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
    "value": 0,
    "data": b"..."  # Encoded calldata
})

print(f"User operation hash: {hash}")

receipt = account.get_user_operation_receipt(hash)
```

## Account discovery

The SDK implements the BIP-44 account discovery algorithm, scanning derivation paths until it finds a gap of 20 unused addresses:

```python
accounts = wallet.get_accounts()

for path, account in accounts.items():
    print(f"{path} -> {account.address}")
```

## Examples

See the [examples/](examples/) directory for complete, runnable scripts.

## Documentation

Full API documentation is available in the [docs/](docs/) directory. Open `docs/index.html` in your browser to browse it.

## License

MIT - see [LICENSE](LICENSE) for details.
