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 (Base Sepolia), 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()

🛠 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

  • 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.
  • 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.2.tar.gz (5.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.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: reap_protocol-0.1.2.tar.gz
  • Upload date:
  • Size: 5.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.2.tar.gz
Algorithm Hash digest
SHA256 1df02d028a0cbb6404775aa1b14a7266c886cfeda30d3d80dda47933df328c5e
MD5 5be9574270bde85f45e86bcb55a135eb
BLAKE2b-256 ae684dd0fc99389c1ddf10fb6211ddf62754118e6cf1008cc63802c09a8d9358

See more details on using hashes here.

File details

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

File metadata

  • Download URL: reap_protocol-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 caad2c54278c22fb0ac04ad3930fb3116e598b8ef202acc93c35e2992ab45b41
MD5 d8cccf584af6ba5378b785104e3c432a
BLAKE2b-256 2396dd7a387bbe343151216cfe960ad58d769c72e21536f31e03995baf5f3d2a

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