@reap-protocol/sdk 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@reap-protocol/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
7
7
  "build": "tsc"
8
8
  },
9
9
  "dependencies": {
10
- "axios": "^1.6.0",
10
+ "axios": "^1.13.2",
11
11
  "ethers": "^6.0.0"
12
12
  },
13
13
  "devDependencies": {
@@ -15,5 +15,9 @@
15
15
  },
16
16
  "publishConfig": {
17
17
  "access": "public"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/Apriloracle/Reap-protocol-sdk.git"
18
22
  }
19
23
  }
package/src/README.md CHANGED
@@ -1,58 +1,66 @@
1
- Reap Protocol
1
+ # @reap-protocol/sdk
2
2
 
3
- The official TypeScript/Node.js SDK for the **Reap Protocol**: The Agentic Commerce Layer.
4
- Enable Autonomous Agents to buy and sell on-chain with zero smart contract knowledge.
3
+ **The official TypeScript/Node.js SDK for the Reap Protocol: The Agentic Commerce Grid.**
5
4
 
5
+ 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. It acts as the bridge between Web2 products data and Web3 commerce settlement.
6
6
 
7
-
8
- 📦 Installation
9
-
7
+ ## 📦 Installation
8
+ ```bash
10
9
  npm install @reap-protocol/sdk ethers axios
10
+ ```
11
11
 
12
+ ## 🚀 Quick Start
12
13
 
14
+ This example demonstrates the full Agentic Commerce Loop: Identity -> Discovery -> Settlement.
13
15
 
14
- 🚀 Quick Start
16
+ ### 1. Setup
15
17
 
16
- 1. Setup
17
18
  If using TypeScript, ensure your tsconfig.json targets ES2020 or higher.
18
19
 
19
- 2. The Agent Code
20
-
21
- TypeScript
20
+ ### 2. The Agent Code (agent.ts)
21
+ ```typescript
22
22
  import { ReapClient } from "@reap-protocol/sdk";
23
23
 
24
- // Use a Base Sepolia Wallet
24
+ // Load your private key securely
25
25
  const PRIVATE_KEY = process.env.MY_WALLET_KEY || "";
26
26
 
27
27
  async function main() {
28
- // 1. Initialize
28
+ // 1. Initialize the Agent
29
+ // (Points to official middleware by default)
29
30
  const client = new ReapClient(PRIVATE_KEY);
30
31
  console.log("🤖 Agent Online");
31
32
 
32
33
  try {
33
- // 2. Identity
34
- // Ensures this wallet is registered to trade
34
+ // 2. Identity (One-time setup)
35
+ // Registers your wallet as an authorized Agent on the Protocol
36
+ console.log("🆔 Checking Identity...");
35
37
  await client.registerIdentity();
36
38
 
37
- // 3. Discovery (Stocking)
38
- // Fetches data, registers it on Base Sepolia, and returns the list
39
- console.log("📦 Stocking Shelf...");
40
- const result = await client.stockShelf("Tonnino Tuna");
39
+ // 3. JIT Stocking (Discovery)
40
+ // Searches Web2 (Reap Deals), registers items on-chain, and returns inventory
41
+ console.log("📦 Stocking Shelf with 'Gaming Laptop'...");
42
+ const result = await client.stockShelf("Gaming Laptop");
41
43
 
42
44
  const inventory = result.items;
43
- console.log(` 🔍 Found ${inventory.length} items.`);
45
+ console.log(` 🔍 Found ${inventory.length} items on-chain.`);
44
46
 
45
47
  if (inventory.length > 0) {
46
- // 4. Decision Engine
48
+ // 4. Decision Logic
49
+ // Example: Pick the first available item
47
50
  const target = inventory[0];
48
- console.log(` 🎯 Target: ${target.name} ($${target.price})`);
51
+ console.log(` 🎯 Selected: ${target.name} ($${target.price})`);
52
+ console.log(` ID: ${target.id}`);
49
53
 
50
- // 5. Settlement (Agentic Cart)
51
- // Automatically approves USDC and executes the purchase
52
- console.log("💸 Purchasing...");
54
+ // 5. Agentic Cart (Settlement)
55
+ // Automatically approves USDC and executes the atomic purchase
56
+ console.log("💸 Buying Item...");
53
57
  const receipt = await client.buyProduct(target.id);
54
58
 
55
- console.log(`🎉 SUCCESS! Tx: ${receipt.hash}`);
59
+ if (receipt) {
60
+ console.log(`🎉 SUCCESS! Transaction Hash: ${receipt.hash}`);
61
+ }
62
+ } else {
63
+ console.log("❌ No items found.");
56
64
  }
57
65
 
58
66
  } catch (e: any) {
@@ -61,26 +69,35 @@ async function main() {
61
69
  }
62
70
 
63
71
  main();
72
+ ```
64
73
 
74
+ ### 3. Run It
75
+ ```bash
76
+ # Install execution tools if you haven't already
77
+ npm install --save-dev ts-node typescript @types/node
65
78
 
79
+ # Run
80
+ npx ts-node agent.ts
81
+ ```
66
82
 
67
- Features
68
- Typed Interfaces: Full TypeScript support for Product Data and Transactions.
69
- Agentic Cart: Automatically routes purchases through the Protocol's batch processor.
70
- Protocol Negotiation: Built-in support for HTTP 402 Payment Negotiation loops.
71
- Gas Optimized: Checks on-chain state before sending registration transactions.
83
+ ## 🔧 Configuration
72
84
 
73
-
74
- 🔧 Configuration
75
- code
76
- TypeScript
85
+ You can override defaults for custom RPCs or self-hosted middleware.
86
+ ```typescript
77
87
  const client = new ReapClient(
78
88
  "YOUR_PRIVATE_KEY",
79
- "https://sepolia.base.org", // Custom RPC
89
+ "https://base-sepolia.g.alchemy.com/v2/YOUR_KEY", // Custom RPC
80
90
  "https://api.reap.deals" // Middleware URL
81
91
  );
92
+ ```
93
+
94
+ ## ✨ Features
82
95
 
96
+ * **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.
97
+ * **Agentic Cart**: Automatically routes purchases through the Protocol's batch processor.
98
+ * **Protocol Negotiation**: Built-in support for HTTP 402 Payment Negotiation loops.
99
+ * **Gas Optimized**: Checks on-chain state before sending registration transactions.
83
100
 
101
+ ## License
84
102
 
85
- License
86
103
  MIT
package/src/index.ts CHANGED
@@ -8,7 +8,7 @@ export class ReapClient {
8
8
 
9
9
  constructor(
10
10
  privateKey: string,
11
- chainRpc: string = "https://sepolia.base.org",
11
+ chainRpc: string = "https://avalanche-fuji.drpc.org",
12
12
  builderUrl: string = "https://api.reap.deals"
13
13
  ) {
14
14
  this.provider = new ethers.JsonRpcProvider(chainRpc);