Skip to main content

Python SDK for interacting with SafeTea Multi-Signature Wallets

Project description

SafeTea

SafeTea is a Python SDK for interacting with SafeTea Multi-Signature Wallets on Ethereum-compatible networks.

It provides a simple and modular interface to create new multi-signature wallets, manage transaction proposals, and execute approved transactions.

Installation

Install the package via pip:

pip install safteawallet-py

Usage

Connecting and Initializing the Client

To interact with SafeTea contracts, initialize the SafeTeaClient using a Web3 instance and your private key.

from web3 import Web3
from safteawallet_py.client import SafeTeaClient

# Initialize the SafeTea client
private_key = "0x..."
client = SafeTeaClient(rpc_url="https://your.rpc.endpoint", factory_address="0xYourFactoryAddress", private_key=private_key)

Creating a New Multi-Signature Wallet

You can deploy a new SafeTea wallet by specifying the owners. A minimum of two owners is required.

# Assuming the factory is already deployed at this address
factory_address = "0xYourFactoryAddress"
factory = client.get_factory(factory_address)

owners = [
    "0xOwnerAddress1",
    "0xOwnerAddress2",
    "0xOwnerAddress3"
]

result = factory.create_wallet(owners)
print(f"New Wallet Address: {result.wallet_address}")
print(f"Transaction Hash: {result.transaction_hash}")

Proposing a Transaction

Once a wallet is deployed, any owner can submit a transaction proposal.

wallet_address = "0xYourWalletAddress"
wallet = client.get_wallet(wallet_address)

# Submit a transaction (e.g., sending 1 ETH)
to_address = "0xRecipientAddress"
value_in_wei = w3.to_wei(1, "ether")
data = b""

# The expiry is defined as a Unix timestamp
expiry_timestamp = w3.eth.get_block("latest")["timestamp"] + 86400 # 24 hours

tx_index = wallet.submit_transaction(to_address, value_in_wei, data, expiry_timestamp)
print(f"Transaction submitted with index: {tx_index}")

Confirming a Transaction

Other owners can review and confirm pending transactions. Once the confirmation threshold is reached, the transaction executes automatically.

# Assuming you are initialized as another owner
tx_index = 0
wallet.confirm_transaction(tx_index)
print(f"Transaction {tx_index} confirmed.")

Managing Owners

Owners can propose adding or removing participants.

new_owner = "0xNewOwnerAddress"
expiry_timestamp = w3.eth.get_block("latest")["timestamp"] + 86400

# Propose a new owner
wallet.propose_add_owner(new_owner, expiry_timestamp)

# Other owners can confirm this proposal
proposal_index = 0
wallet.confirm_owner_proposal(proposal_index)

Development

To run the test suite, ensure dependencies are installed and execute:

pytest tests/

License

This project is open-source and available under the MIT License.

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

safteawallet_py-0.1.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

safteawallet_py-0.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file safteawallet_py-0.1.0.tar.gz.

File metadata

  • Download URL: safteawallet_py-0.1.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for safteawallet_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 70c34ba3bcf94192f9b21d9e758c360406116057d633f13c91b7d67cbc49b456
MD5 b1e9c97335a32f714cabd5907be211b5
BLAKE2b-256 6241eda331cbc10caa65b985d4a5de6061d806fe129f0522eb0e166e44467e12

See more details on using hashes here.

File details

Details for the file safteawallet_py-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for safteawallet_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d6cf8a19a1fb482ffae1ed00943d1d58fd5410569d867eebf5c605303a812a7
MD5 1d5cf9b3fcfa74eeff4c0fcfab63144d
BLAKE2b-256 053cc4111abf37b7168e3c6f55592da38960af622c62fb95d743cffe72fc219f

See more details on using hashes here.

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