Authentication

Claw402 implements a non-custodial security model where AI agents execute transactions without exposing private keys to agent context windows.

Security Architecture

Non-Custodial Design Principles

Claw402's security architecture ensures cryptographic keys never enter AI agent context:

  1. Hardware Security Module (HSM) Isolation - Private keys stored in HSM-backed signing enclaves

  2. Delegated Signing - Agents request signatures without accessing key material

  3. Time-Bounded Delegation - Signing permissions expire after configurable durations

  4. Multi-Party Approval - High-value transactions require human confirmation

Agent Wallet Configuration

Generating Agent Wallets

Create dedicated wallets for agent transaction signing:

# Solana mainnet wallet
solana-keygen new --outfile ~/.config/solana/agent-mainnet.json

# Development/testing wallet
solana-keygen new --outfile ~/.config/solana/agent-devnet.json

Securing Wallet Keypairs

Production Deployment Best Practices:

OpenClaw Provider Configuration

Configure agent wallet through X402Provider:

Approval Policies

Policy Configuration

Approval policies define authorization rules for autonomous agent transactions:

Multi-Tier Approval Workflows

Implement graduated approval requirements based on transaction value:

Policy Enforcement

Claw402 enforces approval policies at the signing service layer:

MCP Server Authentication

Server-to-Agent Authentication

When running standalone MCP server, authenticate agent connections:

Agent Client Configuration

Configure agent to authenticate with MCP server:

mTLS (Mutual TLS) Authentication

For production deployments, enable mutual TLS:

Session Management

Transaction Sessions

Each payment operation creates a unique session with expiration:

Idempotency

Prevent duplicate transactions using idempotency keys:

Audit Logging

Transaction Audit Trails

Claw402 maintains immutable audit logs for all agent transactions:

Audit Log Format

Audit logs contain complete transaction context:

Security Best Practices

1. Key Rotation

Rotate agent wallet keys periodically:

2. Least Privilege Principle

Grant agents minimum required permissions:

3. Anomaly Detection

Enable automated anomaly detection:

4. Network Segmentation

Isolate agent signing infrastructure:

Testing Authentication

Verify Agent Wallet

Test wallet configuration:

Validate Approval Policies

Test policy enforcement:

Authentication Errors

Common Error Codes

Code
Description
Resolution

INVALID_WALLET

Wallet keypair invalid or inaccessible

Verify wallet file path and permissions

INSUFFICIENT_BALANCE

Agent wallet has insufficient funds

Add funds to agent wallet

POLICY_VIOLATION

Transaction violates approval policy

Adjust transaction or update policy

APPROVAL_TIMEOUT

Human approval not received within timeout

Request approval re-submission

SESSION_EXPIRED

Transaction session TTL exceeded

Re-initialize payment session

SIGNATURE_FAILED

HSM signing operation failed

Check HSM connectivity and credentials

Error Handling Example

WebSocket Authentication

For real-time transaction monitoring, WebSocket connections require authentication:

See WebSocket APIarrow-up-right for complete documentation.

Last updated