Skip to main content

claw401

Python SDK for the Claw401 X401 wallet authentication protocol.

Install

pip install claw401

Overview

Implements the X401 challenge-response authentication flow for Solana Ed25519 wallet keys.

Usage

Generate and verify a challenge

from claw401 import generate_challenge, verify_signature, InMemoryNonceCache
from claw401.types import SignedChallenge

nonce_cache = InMemoryNonceCache()

# Server: generate challenge
challenge = generate_challenge(domain="app.example.com")

# Client signs challenge_signing_bytes(challenge) with their Ed25519 key
# ...

# Server: verify
signed = SignedChallenge(
    challenge=challenge,
    signature="<base64-signature>",
    public_key="<base58-public-key>",
)
result = verify_signature(signed, "app.example.com", nonce_cache)

if result.valid:
    print(result.public_key)  # authenticated wallet address

Create a session

from claw401 import create_session, verify_session

session = create_session(
    public_key=result.public_key,
    domain="app.example.com",
    nonce=challenge.nonce,
    scopes=["read", "write"],
)

# Later: verify session
result = verify_session(session, "app.example.com", required_scopes=["write"])

Agent attestation

from claw401 import create_agent_attestation, verify_agent_attestation

attestation = create_agent_attestation(
    agent_key=agent_pubkey,
    operator_key=operator_pubkey,
    operator_secret_key=operator_signing_key,
    agent_id="my-agent-001",
    actions=["read:orders", "submit:tx"],
    mcp_tools=["get_order", "submit_settlement"],
    ttl_ms=24 * 60 * 60 * 1000,
)

result = verify_agent_attestation(attestation, expected_operator_key=operator_pubkey)

License

Apache-2.0

Release files for claw401 0.1.0

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

Built distribution (wheel)

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

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

Download URL claw401-0.1.0-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73e8b00a479090be08e4afd1166817029c25dfdef16b2145269346fb0e6582f7
BLAKE2b-256 checksum
How to use checksums
db321b906cf35b551046955218eec4b7eff84a478b2b57365c04c5d5acbbf78a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.13.6 Windows/11

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

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