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.0.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.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: claw_wallet-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 a1aeb0642271c3aa2cff7af6c2e170c952183f394968da2933f61e4950cfd16c
MD5 c1b6c8ea11d081f74158dddf7b1a4f18
BLAKE2b-256 c4ea76211efe8deebcf42b44deba113e55085ec8a232bd3313cbe6a7491483b0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: claw_wallet-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c3e2be5f9b3a268db28100b09da6748f9740cf920ed3b86e4b323b4f54aa45a
MD5 dad6aeb2a1af06478e52726a0e305b6f
BLAKE2b-256 8ca4f157ba9e00f83d274f8d2d3f151ccee824619f7290afb5c527a8d0f32437

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