Skip to main content

Python implementation of the Safe Protocol Kit

Project description

Safe Kit (Python)

PyPI version Python versions License CI codecov

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

safe_kit-0.0.13.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

safe_kit-0.0.13-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file safe_kit-0.0.13.tar.gz.

File metadata

  • Download URL: safe_kit-0.0.13.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for safe_kit-0.0.13.tar.gz
Algorithm Hash digest
SHA256 9e9517c098d15d0b5830fa78006a6c282cdc5ec8d8b2cb5b4fcf497f7b1bec2b
MD5 abd212cf008baf12e69b57f0da5bed72
BLAKE2b-256 53e838028655dbeff3b65de9eae822b33551acc4680cf7af095c8b60ebb4ad68

See more details on using hashes here.

Provenance

The following attestation bundles were made for safe_kit-0.0.13.tar.gz:

Publisher: release.yml on smallyunet/safe-kit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file safe_kit-0.0.13-py3-none-any.whl.

File metadata

  • Download URL: safe_kit-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for safe_kit-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 9bf53c1f03f6ed9eae1c849f61080b9a1955eab1c36c24d045190b4cb4b1e7e4
MD5 19d1ea181021e6bde6a2c1f1c7fcf8c0
BLAKE2b-256 f2b0550cebb807bd8195168669c5c60f6c42bd128bb074d33b27b6f40230064d

See more details on using hashes here.

Provenance

The following attestation bundles were made for safe_kit-0.0.13-py3-none-any.whl:

Publisher: release.yml on smallyunet/safe-kit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page