> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kash.bot/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart — Smart-account mode (Python)

> ERC-4337 v0.7 trading via SimpleAccount + bundler from Python. Same surface as the TS SDK.

Smart-account mode in Python mirrors the TypeScript surface
exactly. Use it for Python AA-stack integrations, paymaster
sponsorship, batched approve+trade flows, or any case where the
trading address should be a SimpleAccount derived from an external
signer.

## Construct the client

```python theme={null}
import asyncio
import os

from eth_account import Account
from kashdao_protocol_sdk import (
    BundlerOptions,
    create_smart_account_client,
    viem_account_signer,
)


async def main() -> None:
    account = Account.from_key(os.environ["KASH_PRIVATE_KEY"])

    async with create_smart_account_client(
        chain_id=84532,
        rpc=os.environ["BASE_SEPOLIA_RPC"],
        signer=viem_account_signer(account),
        bundler=BundlerOptions(
            provider="pimlico",
            url=os.environ["KASH_BUNDLER_URL"],
        ),
    ) as client:
        sa = await client.account.compute_address(client.signer.owner_address)
        print(f"SmartAccount: {sa}")
        health = await client.bundler.health()
        print(f"bundler health: {health}")


asyncio.run(main())
```

`BundlerOptions(provider=..., url=..., api_key=...)` accepts
`alchemy`, `pimlico`, `flashbots`, or `generic`. The provider value
is informational; the actual vendor preset is chosen by the consumer
when wiring the client.

## Place a trade

```python theme={null}
from kashdao_protocol_sdk import BuildBuyParams, usdc

sa = await client.account.compute_address(client.signer.owner_address)

result = await client.trades.send.buy(
    os.environ["KASH_MARKET"],
    BuildBuyParams(
        account=sa,
        outcome=0,
        amount_usdc=usdc(10),
        max_slippage_bps=50,
    ),
)
print(
    result.user_op_hash,
    result.receipt.receipt.get("transactionHash"),
    result.receipt.success,
)
```

The `user_op_hash` is what the signer signed — useful for log
correlation across the bundler RPC and the EntryPoint contract. The
smart-account `send.buy` result carries only `user_op_hash` and the
bundler-returned `receipt`; the on-chain transaction hash is nested
at `result.receipt.receipt["transactionHash"]` and success at
`result.receipt.success`. External monitoring typically wants both
views.

## First-trade-with-deployment

Same auto-deploy story as the TypeScript SDK: the first UserOp
from a fresh SmartAccount carries `factory` + `factory_data` so
the EntryPoint deploys the account in the same op. The Python SDK
auto-detects the undeployed state and populates these fields; you
don't pass anything special. Verification gas is \~5x higher on
the deployment op, and the bundler's gas estimate accounts for
this automatically.

## Run the bundled examples

```bash theme={null}
# Read-only by default: derives the SA via CREATE2, prints deploy/balance state and a quote
python examples/smart_account/buy_with_simple_account.py

# --confirm opts in to broadcasting: submits a real SA BUY UserOp on Base Sepolia
python examples/smart_account/quote_and_buy.py --confirm
```

## What's next

<CardGroup cols={2}>
  <Card title="EOA quickstart" icon="key" href="/developer-docs/protocol-sdk-python/quickstart-eoa">
    Vanilla EIP-1559, no bundler.
  </Card>

  <Card title="Hummingbot integration" icon="chart-line" href="/developer-docs/protocol-sdk-python/hummingbot">
    Full strategy walkthrough.
  </Card>
</CardGroup>
