Skip to main content

clanker-wallet

Python SDK for Clanker Wallet — E2E encrypted transaction approval for AI agents.

An AI agent proposes transactions, a human reviews and signs them via the web app. All communication is end-to-end encrypted using x25519 + nacl.box.

Install

pip install clanker-wallet

Requires Python 3.10+.

Quick Start

import asyncio
from clanker_wallet import ClankerWallet, Transaction, RequestTxOptions, TxContext

async def main():
    # Create agent (generates new x25519 identity keypair)
    agent = ClankerWallet()

    # Pair with human's wallet — JSON from the prompt the human pasted
    # (or scanned from the QR on https://clanker-wallet.xyz)
    agent.pair(pairing_json)

    # Request a transaction: 0.001 ETH on Base Sepolia
    tx_hash = await agent.request_tx(RequestTxOptions(
        chain_id=84532,
        transaction=Transaction(
            to="0x000000000000000000000000000000000000dEaD",
            value="1000000000000000",  # 0.001 ETH in wei
            data="0x",
        ),
        context=TxContext(reason="Payment for service"),
    ))
    print(f"Approved: {tx_hash}")

asyncio.run(main())

Persistence

Save and restore agent identity across sessions:

# Save the 32-byte secret key (store securely)
secret = agent.secret_key

# Restore later — same keypair, same agent_id
agent = ClankerWallet(secret_key=secret)

API Reference

ClankerWallet

The main client class. Each instance represents an AI agent identity.

ClankerWallet(*, agent_name=None, secret_key=None)
Parameter Type Description
agent_name str | None Optional display name for this agent
secret_key bytes | None 32-byte x25519 secret key to restore identity. Omit to generate new.

Properties:

Property Type Description
public_key bytes 32-byte x25519 public key
secret_key bytes 32-byte x25519 secret key
signing_public_key bytes 32-byte Ed25519 public key (derived from secret)
agent_id str Deterministic ID: agent_{pubkey_hex[:12]}
paired bool Whether pair() has been called

Methods:

pair(pairing_json: str) -> PairingData

Parse the pairing JSON from the web app (also matches what the QR code encodes). Stores the human's public key and relay URL.

pairing = agent.pair('{"version":1,"pubkey":"ab12...","relay":"wss://relay.example/ws","wallet":"0x..."}')
print(pairing.relay)   # wss://relay.example/ws
print(pairing.wallet)  # 0x...

Raises PairingError if JSON is invalid or version != 1.

async request_tx(options: RequestTxOptions) -> str

Send an encrypted transaction request to the paired human. Blocks until the human approves, rejects, or the timeout expires.

Returns the on-chain transaction hash on approval. Raises InvalidTxError before anything is sent if chain_id, to, value or data is malformed.

tx_hash = await agent.request_tx(RequestTxOptions(
    chain_id=84532,
    transaction=Transaction(to="0x000000000000000000000000000000000000dEaD", value="0", data="0x"),
    context=TxContext(reason="swap tokens"),
    timeout_ms=60_000,  # 1 minute (default: 1 hour)
))

Types

All types are dataclass(slots=True) for performance.

Transaction

Transaction(to: str, value: str | int, data: str = "0x")
  • to — recipient address: 0x + 40 hex characters; mixed case must pass the EIP-55 checksum
  • value — whole number of wei, as a decimal string or int (not ETH, no decimals) (the js sdk takes a decimal string or bigint instead; a js number is rejected)
  • data — calldata, 0x + even-length hex (defaults to 0x)

TxContext

Optional context to help the human understand the request.

TxContext(reason=None, urgency=None, expected_outcome=None)

RequestTxOptions

RequestTxOptions(chain_id: int, transaction: Transaction, context=None, timeout_ms=None)
  • timeout_ms — defaults to 3,600,000 (1 hour)

PairingData

Returned by pair().

PairingData(version: int, pubkey: str, relay: str, wallet: str, mode: str | None = None)
  • mode — "managed" (the relay also gets the tx fields to simulate) or "encrypted" / None (ciphertext only)

Errors

All errors inherit from ClankerError.

Error When Attributes
ClankerError Base class —
NotPairedError request_tx() called before pair() —
TxRejectedError Human rejected the transaction request_id
TxTimeoutError No response within timeout request_id, timeout_ms
TxError Transaction failed on-chain request_id, error
PairingError Invalid pairing data —
InvalidTxError Malformed tx request (also a ValueError); nothing was sent field, reason
RelayError WebSocket connection issues —
from clanker_wallet import TxRejectedError, TxTimeoutError, TxError

try:
    tx_hash = await agent.request_tx(options)
except TxRejectedError:
    print("Human said no")
except TxTimeoutError as e:
    print(f"Timed out after {e.timeout_ms}ms")
except TxError as e:
    print(f"On-chain failure: {e.error}")

Crypto Utilities

Low-level crypto functions are exported for advanced use cases (e.g. building custom protocols on top of the relay).

from clanker_wallet import (
    generate_keypair,      # -> BoxKeyPair (x25519)
    keypair_from_secret,   # bytes -> BoxKeyPair
    encrypt_message,       # (msg, recipient_pub, sender_sk) -> base64
    decrypt_message,       # (b64, sender_pub, recipient_sk) -> str | None
    signing_keypair_from_seed,  # bytes -> SignKeyPair (Ed25519)
    sign_message,          # (msg, sk) -> base64 signature
    verify_signature,      # (msg, b64_sig, pk) -> bool
    to_hex, from_hex,      # bytes <-> hex
    bytes_to_base64, base64_to_bytes,
)

How It Works

  1. Human opens the web app, connects wallet, derives an x25519 keypair, copies a paste-ready prompt (or scans the QR) containing the pairing JSON
  2. Agent calls pair(pairing_json) — stores human's public key + relay URL
  3. Agent calls request_tx() — encrypts a TxRequest with nacl.box, sends via WebSocket relay
  4. Human's web app decrypts, displays tx details, runs simulation/risk checks
  5. Human approves → wallet signs + broadcasts → encrypted TxResponse with tx hash sent back
  6. Agent receives tx hash, returns it from request_tx()

All messages are encrypted end-to-end. The relay server never sees plaintext.

Development

cd python
pip install -e ".[dev]"

# Run tests
pytest -v

# Type checking (strict mode)
mypy clanker_wallet/

# Build package
python -m build

License

MIT

Metadata

Release files for clanker-wallet 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clanker-wallet 0.1.0
File Size Uploaded Provenance Actions
clanker_wallet-0.1.0.tar.gz 19.9 kB Without provenance Details for clanker_wallet-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clanker-wallet 0.1.0
File Interpreter ABI Platform Actions
clanker_wallet-0.1.0-py3-none-any.whl Python 3 none any Details for clanker_wallet-0.1.0-py3-none-any.whl

Total release size: 34.7 kB

Release files / clanker_wallet-0.1.0.tar.gz

Download URL clanker_wallet-0.1.0.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
562d2293bb0ccffdaabd4edb011916099c777b43caa4ac30f998ce64e5e539cf
BLAKE2b-256 checksum
How to use checksums
510be192094692e69bafa62ce8ac7957b93ded4f0481d2f6db3d56fe43864e33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / clanker_wallet-0.1.0-py3-none-any.whl

Download URL clanker_wallet-0.1.0-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51c898b221470e3761f91d1d3279bee8cce4ea15595be1f5b9b985172b34419e
BLAKE2b-256 checksum
How to use checksums
655d86bee8269e9068d28cf6b324033cc7806008813b0f2e2db1de263e585032
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for clanker-wallet 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page