Skip to main content

Stripe for AI Agent Wallets - Python SDK

Project description

Claw Wallet Python SDK

Stripe for AI Agent Wallets
Add wallet functionality to any AI agent in seconds

PyPI Version Python Versions License


Installation

pip install claw-wallet

# With WebSocket support
pip install claw-wallet[websocket]

# With development tools
pip install claw-wallet[dev]

Quick Start

from claw_wallet import WalletClient

# Initialize the client
client = WalletClient(api_key="sk_your_api_key_here")

# Create a wallet for your AI agent
wallet = client.create_wallet(
    agent_name="MyAIAgent",
    chain="base-sepolia"  # or "ethereum", "solana", "sui", "aptos", "starknet"
)

print(f"Wallet created: {wallet.address}")

# Check balance
balance = client.get_balance(wallet.address)
print(f"Balance: {balance}")

Features

Multi-Chain Support

Claw Wallet supports multiple blockchain networks:

Chain Network ID Status
Ethereum ethereum, ethereum-sepolia ✅ Supported
Base base, base-sepolia ✅ Supported
Solana solana, solana-devnet ✅ Supported
Sui sui, sui-testnet ✅ Supported
Aptos aptos, aptos-testnet ✅ Supported
Starknet starknet, starknet-testnet ✅ Supported

WebSocket Real-Time Updates

from claw_wallet import WebSocketClient

ws = WebSocketClient(api_key="sk_...")
ws.connect()

# Subscribe to wallet events
ws.subscribe("0x123...")

for event in ws.listen():
    if event['type'] == 'transaction.confirmed':
        print(f"Transaction confirmed: {event['transaction']['hash']}")
    elif event['type'] == 'approval.requested':
        print(f"Approval needed: {event['details']}")

LangChain Integration

from claw_wallet.langchain import WalletTools, create_wallet_agent

# Create wallet tools for LangChain
tools = WalletTools(api_key="sk_...")

# Create an agent with wallet capabilities
agent = create_wallet_agent(
    api_key="sk_...",
    model="gpt-4"
)

# The agent can now perform wallet operations
response = agent.run("Create a wallet on Base and check its balance")

Policy Engine

# Set spending limits
client.create_policy(
    wallet_id=wallet.id,
    policy_type="spend_limit",
    config={
        "max_amount": "100",  # in USD
        "period": "daily"
    }
)

# Require approval for large transactions
client.create_policy(
    wallet_id=wallet.id,
    policy_type="approval_required",
    config={
        "threshold": "50"  # USD threshold
    }
)

API Reference

WalletClient

__init__(api_key: str, base_url: str = None)

Initialize the wallet client.

  • api_key: Your API key (starts with sk_)
  • base_url: Optional custom API endpoint

create_wallet(agent_name: str, chain: str, metadata: dict = None) -> Wallet

Create a new wallet for an AI agent.

get_wallet(wallet_id: str) -> Wallet

Get wallet details by ID.

get_balance(address: str, chain: str = None) -> Balance

Get the balance of a wallet address.

send_transaction(from: str, to: str, value: str, chain: str) -> Transaction

Send a transaction from a wallet.

get_transaction(hash: str, chain: str = None) -> Transaction

Get transaction details by hash.

Error Handling

from claw_wallet import WalletClient
from claw_wallet.exceptions import (
    AuthenticationError,
    RateLimitError,
    WalletNotFoundError,
    ValidationError
)

client = WalletClient(api_key="sk_...")

try:
    wallet = client.create_wallet(agent_name="", chain="invalid")
except ValidationError as e:
    print(f"Invalid input: {e}")
except AuthenticationError as e:
    print(f"Authentication failed: {e}")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")

Environment Variables

  • CLAW_API_KEY: Default API key
  • CLAW_BASE_URL: Custom API endpoint
  • CLAW_TIMEOUT: Request timeout in seconds (default: 30)

Development

# Clone the repository
git clone https://github.com/Vibes-me/Claw-wallet.git
cd Claw-wallet/agent-wallet-service-python

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black claw_wallet

# Type check
mypy claw_wallet

License

Apache-2.0 - See LICENSE for details.

Links


Built with 🦞 by Mr. Claw

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

claw_wallet-0.2.1.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

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

claw_wallet-0.2.1-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file claw_wallet-0.2.1.tar.gz.

File metadata

  • Download URL: claw_wallet-0.2.1.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for claw_wallet-0.2.1.tar.gz
Algorithm Hash digest
SHA256 de9b6f9258e161eb12f4d1f531d0aca50b4a8f726cfd58bfed1a948b55515018
MD5 07cee92e33d6673d98f57cd5910d1ac3
BLAKE2b-256 79539aa466f007582924a6ffed2e3b35fc2cfc471a1ef79bea52ffe953b2cfe1

See more details on using hashes here.

File details

Details for the file claw_wallet-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: claw_wallet-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for claw_wallet-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8acd122592211a697c60292523a214adbde129dd665e4768f61602f45c4a12ba
MD5 3b4ea1509ad0cd4825bb9fe6dac13d30
BLAKE2b-256 27fa815ebae7b3e8ad5d1772b39830350db64ad000441668cd757451a471aee6

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