Skip to content

mfrashidi/pysquad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PySquad

A Python SDK for interacting with Squads Protocol on Solana. PySquad provides a simple and intuitive interface for managing multisig wallets, creating and executing transactions, and handling proposals on the Solana blockchain.

Features

  • 🏦 Multisig wallet management
  • 💼 Transaction creation and execution
  • 📝 Proposal creation and approval
  • 🔐 Secure key management
  • ⚡️ Solana blockchain integration
  • 🛡️ Time-locked transactions
  • 💰 Treasury management

Installation

# Clone the repository
git clone https://github.com/yourusername/pysquad.git
cd pysquad

# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows, use `.venv\Scripts\activate`

# Install dependencies
pip install -r requirements.txt

Dependencies

  • anchorpy==0.21.0
  • solana==0.36.6
  • solders==0.26.0

Quick Start

from sdk.squads import SquadsWallet
from sdk.client import SolanaClient
from solders.pubkey import Pubkey
from solders.solders import Keypair

# Initialize Solana client
client = SolanaClient()

# Create a new multisig wallet
members = [
    Member(key=Pubkey("member1_public_key"), permissions={"mask": 7}),
    Member(key=Pubkey("member2_public_key"), permissions={"mask": 7})
]
threshold = 2  # Require 2 approvals for transactions

wallet = SquadsWallet(
    client=client,
    members=members,
    threshold=threshold
)

# Deploy the wallet
tx_sig = wallet.deploy()
print(f"Wallet deployed with transaction: {tx_sig}")

Core Functionality

Creating a Multisig Wallet

wallet = SquadsWallet(
    client=client,
    members=members,
    threshold=threshold,
    time_lock=0,  # Optional time lock in seconds
    memo="My multisig wallet"  # Optional memo
)

Creating a Transaction

# Create a transaction
tx_sig = wallet.create_vault_transaction(
    instructions=[your_instructions],
    creator=member_keypair,
    memo="Transaction description"
)

Creating and Approving Proposals

# Create a proposal
proposal_sig = wallet.create_proposal(
    creator=member_keypair,
    draft=False
)

# Approve a proposal
approval_sig = wallet.approve_proposal(
    member=member_keypair,
    memo="Approval comment"
)

Executing Transactions

# Execute an approved transaction
execute_sig = wallet.vault_transaction_execute(
    member=member_keypair
)

Project Structure

pysquad/
├── sdk/
│   ├── squads.py      # Main SDK implementation
│   ├── client.py      # Solana client wrapper
│   ├── constants.py   # Protocol constants
│   └── __init__.py
├── squads/           # Protocol-specific implementations
├── requirements.txt  # Project dependencies
└── README.md        # This file

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License

MIT License

Security

This project is for interacting with the Squads Protocol on Solana. Please ensure you understand the security implications of managing multisig wallets and executing transactions on the blockchain.

Support

For support, please open an issue in the GitHub repository or contact the maintainers.

About

A Python SDK for Squads Protocol on Solana

Topics

Resources

Stars

Watchers

Forks

Languages