Skip to main content

Machine-to-machine payments for AI agents — x402 protocol on Base L2

Project description

x402-agentpay

Machine-to-machine payments for AI agents — x402 protocol on Base L2

pip install x402-agentpay

x402 micropayments (EIP-3009 USDC on Base L2)

from agentpay.x402 import X402Client

client = X402Client(private_key="0xYOUR_AGENT_WALLET_KEY")

# Fetch any x402-protected endpoint — payment handled automatically
data = client.fetch("https://agentworld.me/api/agentworld/economy")

# Pay directly to any wallet
receipt = client.pay(to="0xRecipient", amount_usdc=0.001)
print(receipt["txHash"])  # verifiable on BaseScan

AgentPay marketplace (API key, agent-to-agent)

from agentpay import AgentPay

ap = AgentPay(api_key="your-key", agent_id="my-agent")
entry = ap.pay(to="ai-lawyer", capability="contract-review", amount=0.05)
print(entry.basescan_url)

How x402 works

  1. Agent calls client.fetch(url)
  2. If server returns 402 Payment Required, reads paymentRequirements
  3. Client signs EIP-3009 TransferWithAuthorization with agent wallet
  4. Signed payload sent to AgentPay facilitator → settled on Base L2
  5. Original endpoint retried with payment proof — returns data

Facilitator

Default: https://x402-agent-pay.com — free, no fees on Base L2, sub-second settlement.

Links

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

x402_agentpay-1.1.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

x402_agentpay-1.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file x402_agentpay-1.1.0.tar.gz.

File metadata

  • Download URL: x402_agentpay-1.1.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for x402_agentpay-1.1.0.tar.gz
Algorithm Hash digest
SHA256 d35cb12f4a150471ee6d0fa5222a246601c6803e0373e55784a5bef0096e4e50
MD5 2ec8043eb4ec9d2e39b9adb316107036
BLAKE2b-256 3361b468ac7515d276e81885292f83204f6121878f9e9f265d6a6847025aa194

See more details on using hashes here.

File details

Details for the file x402_agentpay-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: x402_agentpay-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for x402_agentpay-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a40993629ed7f362877f52d4bb786fb29bb533ae9e0ec57b031e3791a1acebd8
MD5 8568c5beab85229fe466a4b710934c07
BLAKE2b-256 db1b9933e26248277c1231d7e4398e60d281a896a4bd978f73f05b69e987cacf

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