Python implementation of the Safe Protocol Kit
Project description
Safe Kit (Python)
A Python implementation of the Safe Protocol Kit, designed to mirror the developer experience of the official Node.js SDK.
Features
- DX First: Intuitive API for interacting with Safe smart accounts.
- Type Safe: Built with Pydantic and fully typed for robust development.
- Modern Stack: Uses Web3.py, Eth-account, and Python 3.10+.
- Full Protocol Support: Supports Safe deployment, transaction creation, signing (EIP-712 & eth_sign), and execution.
Installation
This project uses Poetry for dependency management.
# Install dependencies
poetry install
Usage
Initialization
from web3 import Web3
from eth_account import Account
from safe_kit.safe import Safe
from safe_kit.adapter import Web3Adapter
# Setup Web3 and Signer
w3 = Web3(Web3.HTTPProvider("RPC_URL"))
owner = Account.from_key("PRIVATE_KEY")
adapter = Web3Adapter(web3=w3, signer=owner)
# Initialize Safe
safe = Safe(eth_adapter=adapter, safe_address="0xSafeAddress")
Creating and Signing Transactions
from safe_kit.types import SafeTransactionData
# Create a transaction (e.g., send ETH)
tx_data = SafeTransactionData(
to="0xRecipient",
value=1000000000000000000, # 1 ETH
data="0x"
)
safe_tx = safe.create_transaction(tx_data)
# Sign the transaction
# Supports "eth_sign_typed_data" (default, EIP-712) or "eth_sign" (legacy)
signed_tx = safe.sign_transaction(safe_tx)
Executing Transactions
# Execute the transaction on-chain
tx_hash = safe.execute_transaction(signed_tx)
print(f"Transaction executed: {tx_hash}")
Development
Running Tests
poetry run pytest
Linting
poetry run ruff check .
poetry run mypy .
Roadmap
See docs/roadmap.md for the current implementation status.
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
safe_kit-0.0.2.tar.gz
(10.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
safe_kit-0.0.2-py3-none-any.whl
(12.3 kB
view details)
File details
Details for the file safe_kit-0.0.2.tar.gz.
File metadata
- Download URL: safe_kit-0.0.2.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.14.2 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c5d8c8f3d5a2824eb6601dc044918bfca1e1446f28aee46af6d307892383981
|
|
| MD5 |
0874d9854b92d76a655ab1de162d707f
|
|
| BLAKE2b-256 |
a1e081cb75cb5a76d105251783c16403ce7d2115b0a1ab4b4fae1b0aef7dcc6c
|
File details
Details for the file safe_kit-0.0.2-py3-none-any.whl.
File metadata
- Download URL: safe_kit-0.0.2-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.14.2 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be0ae697f5d3a3a7eabde4261954eafda60cdc1e0249c5c20e8a35e76260b009
|
|
| MD5 |
7c80a63e873eccc09348cc35c7bd1a6e
|
|
| BLAKE2b-256 |
0a622679173a9dd5bc98cac5c54549ffc767a30cfec9de04c06d0cfa43c8071c
|