Skip to main content

Official SDK for the Reap Protocol: Onchain x402 Commerce Layer

Project description

Reap Protocol

The official Python SDK for the Reap Protocol: The Agentic Commerce Layer.
The Reap Protocol enables AI Agents to search for products, register them on-chain (Base Sepolia), and execute atomic purchases.

📦 Installation

pip install reap-protocol

🚀 Quick Start This example demonstrates the full Agentic Commerce Loop: Identity -> Discovery -> Settlement.

Python import os from reap_protocol.client import ReapClient

1. Configuration

Use a Base Sepolia Wallet with ETH (for gas) and USDC (for purchases)

PRIVATE_KEY = os.getenv("MY_WALLET_KEY")

def main(): # Initialize the Agent (Points to official middleware by default) client = ReapClient(private_key=PRIVATE_KEY)

# 2. Identity (One-time setup)
# Registers your wallet as an authorized Agent on the Protocol
print("🆔 Checking Identity...")
client.register_identity()

# 3. JIT Stocking (Discovery)
# Searches Web2 (Reap Deals), registers items on-chain, and returns inventory
print("📦 Stocking Shelf with 'Gaming Laptop'...")
result = client.stock_shelf("Gaming Laptop")

inventory = result.get('items', [])
print(f"   🔍 Found {len(inventory)} items on-chain.")

if not inventory:
    return

# 4. Decision Logic
# Example: Pick the first available item
target_item = inventory[0]
print(f"   🎯 Selected: {target_item['name']} (${target_item['price']})")
print(f"      ID: {target_item['id']}")

# 5. Agentic Cart (Settlement)
# Handles ERC20 Approvals and Atomic Purchase in one flow
print(f"💸 Buying Item...")
receipt = client.buy_product(target_item['id'])

if receipt:
    print(f"🎉 SUCCESS! Transaction Hash: {receipt['transactionHash'].hex()}")

if name == "main": main()

🛠 Configuration You can override defaults for custom RPCs or self-hosted middleware.

client = ReapClient( private_key="...", chain_rpc="https://base-sepolia.g.alchemy.com/v2/YOUR_KEY", # Faster RPC builder_url="https://api.reap.deals" # Official Middleware )

✨ Features Agentic Cart: Routes single or multiple items through a batch processor, optimizing gas and handling USDC approvals automatically. JIT Product Stocking: "Just-In-Time" inventory system. If an agent searches for an item not yet on the blockchain, the Protocol indexes it in real-time. Self-Custody: Your private key never leaves your local machine. The SDK signs transactions locally. Smart Updates: The Middleware checks on-chain state to prevent redundant transactions.

License MIT

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

reap_protocol-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

reap_protocol-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file reap_protocol-0.1.0.tar.gz.

File metadata

  • Download URL: reap_protocol-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for reap_protocol-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8bb5cd5fcf6b497add90ac8d10ec600082385910646ccc51c54e69611e071e49
MD5 d0dcf3f192c14df8f93678228768f65f
BLAKE2b-256 a0ba16abe801167908ce20e92c65c8515ba6097b8f822599d4a896e2a80df5be

See more details on using hashes here.

File details

Details for the file reap_protocol-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: reap_protocol-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for reap_protocol-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f86801e6821ecbf0fd395239880179aa39d8fc67ad9de4599ec753d644794d64
MD5 2466ec781a336e03a319494eab834044
BLAKE2b-256 4b2107cf5a7760f8e8ebae0f590e16ee580f85a4004c0285e71f8458fd8e4303

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