Skip to main content

Official SDK for the Reap Protocol: Agentic Commerce Grid

Project description

Reap Protocol SDK

The official Python SDK for the Reap Protocol: The Agentic Commerce Grid.

The Reap Protocol enables AI Agents to search for products, register them on-chain, and execute atomic purchases without needing to understand smart contract ABIs.

📦 Installation

pip install reap-protocol

🚀 Quick Start

This example demonstrates the full Agentic Commerce Loop: Identity -> Discovery -> Smart Sync -> Settlement.

import os
import time
from reap_protocol.client import ReapClient

# 1. Configuration
# Use a funded testnet wallet (AVAX Fuji, Celo Alfajores, or Base Sepolia)
PRIVATE_KEY = os.getenv("MY_WALLET_KEY") 
CHAIN_RPC = "https://api.avax-test.network/ext/bc/C/rpc" # Example: Avalanche Fuji

def main():
    # Initialize the Agent
    client = ReapClient(
        private_key=PRIVATE_KEY,
        chain_rpc=CHAIN_RPC
    )
    
    # Wait for connection
    time.sleep(1)
    print(f"🤖 Agent Online: {client.account.address}")

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

    # 3. Discovery (Dry Run Mode)
    # Searches Web2 (Reap Deals). We use dry_run=True to get the data
    # without executing the registration transactions immediately.
    print("📦 Browsing for 'Gaming Laptop'...")
    
    result = client.stock_shelf("Gaming Laptop", dry_run=True)
    
    items = result.get('items', [])
    transactions = result.get('transactions', [])
    
    print(f"   🔍 Found {len(items)} items.")

    if not items:
        print("❌ No items found.")
        return

    # 4. Decision Logic
    # Example: Pick the first available item
    target_item = items[0]
    
    # The API returns transactions in the same order as items.
    # We grab the specific registration TX for this item.
    target_tx = transactions[0] 

    print(f"   🎯 Selected: {target_item['name']} (${target_item['price']})")
    print(f"      ID: {target_item['id']}")

    # 5. Smart Sync 
    # The SDK checks if item is stocked.
    # - If found: It skips registration (Zero Gas).
    # - If missing: It runs the registration TX and updates the index.
    print("🧠 Running Smart Sync...")
    client.smart_sync(target_item, [target_tx])

    # 6. 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()

🕵️ Agent Discovery (New)

You can now search for other AI Agents (MCP, x402, A2A).

# 1. Search for Agents
# Registries: 'mcp', 'x402', 'a2a'
agents = client.search_agents("ecommerce", registry="x402")

if agents:
    target_agent = agents[0]
    print(f"Found: {target_agent.get('name')}")

🛠 Configuration

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

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

✨ Features

  • Agent Discovery: Search thousands of AI Agents from MCP, x402, and A2A registries.
  • Agentic Cart: Routes single or multiple items through a batch processor, optimizing gas and handling USDC approvals automatically.
  • JIT 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.
  • 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.3.tar.gz (6.6 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.3-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: reap_protocol-0.1.3.tar.gz
  • Upload date:
  • Size: 6.6 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.3.tar.gz
Algorithm Hash digest
SHA256 db7dfed412395884970189e59e07e99f869218ef6ce7c4de03c10c6d89663114
MD5 b377956dc9ad4de6da8e8e6687dc69c2
BLAKE2b-256 fe163b6f797ce977d9b323815a515df4b51d255df01f6a13ed758620da4a3452

See more details on using hashes here.

File details

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

File metadata

  • Download URL: reap_protocol-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bbc84037de2eaef7ca065f6ed5108f91790455e892d34aaa74c4307f5e3fdc70
MD5 35f90b9c6617bbbb701dc7ee6d29b8be
BLAKE2b-256 10ddf3c02457941dca225decee1b3fcc1c5bbef46b31d7d431ff1afa10386f66

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