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.
- Advanced Features: MultiSend (batching), Safe Transaction Service integration, and more.
Installation
You can install safe-kit via pip:
pip install safe-kit
Or with Poetry:
poetry add safe-kit
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}")
For more advanced usage (Batching, Transaction Service, Deployment), please refer to the User Guide.
Development
Setup
# Install dependencies
poetry install
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
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
File details
Details for the file safe_kit-0.0.14.tar.gz.
File metadata
- Download URL: safe_kit-0.0.14.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fef00490500162e25ad3e7303c7ab7006f363442e8b3bb837f343e5d00960a52
|
|
| MD5 |
28abe6aa5f750667f3dac1557b331f9c
|
|
| BLAKE2b-256 |
62a9c66fef6050244417ce1a2033df791f6fb5cfb83b23b0409a4655360c3017
|
Provenance
The following attestation bundles were made for safe_kit-0.0.14.tar.gz:
Publisher:
release.yml on smallyunet/safe-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
safe_kit-0.0.14.tar.gz -
Subject digest:
fef00490500162e25ad3e7303c7ab7006f363442e8b3bb837f343e5d00960a52 - Sigstore transparency entry: 845714877
- Sigstore integration time:
-
Permalink:
smallyunet/safe-kit@647a9e657a0d6254fd2abe08bdafb0b3ec98968b -
Branch / Tag:
refs/tags/v0.0.14 - Owner: https://github.com/smallyunet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@647a9e657a0d6254fd2abe08bdafb0b3ec98968b -
Trigger Event:
push
-
Statement type:
File details
Details for the file safe_kit-0.0.14-py3-none-any.whl.
File metadata
- Download URL: safe_kit-0.0.14-py3-none-any.whl
- Upload date:
- Size: 27.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3f990db4b82f6667f86ef0570bc41ac47aab7358b55da635ea65c6bd7ace7b0
|
|
| MD5 |
6a2ee3f125a61a02a05e96e4d5308509
|
|
| BLAKE2b-256 |
1c8ddbb3c015c9e87be51be80cbe3dd1d5720847b48ba998d797ed8d3159bb3d
|
Provenance
The following attestation bundles were made for safe_kit-0.0.14-py3-none-any.whl:
Publisher:
release.yml on smallyunet/safe-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
safe_kit-0.0.14-py3-none-any.whl -
Subject digest:
e3f990db4b82f6667f86ef0570bc41ac47aab7358b55da635ea65c6bd7ace7b0 - Sigstore transparency entry: 845714882
- Sigstore integration time:
-
Permalink:
smallyunet/safe-kit@647a9e657a0d6254fd2abe08bdafb0b3ec98968b -
Branch / Tag:
refs/tags/v0.0.14 - Owner: https://github.com/smallyunet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@647a9e657a0d6254fd2abe08bdafb0b3ec98968b -
Trigger Event:
push
-
Statement type: