@sparkysolutions/agentsub 0.0.0-stage → 0.1.0
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/README.md +79 -2
- package/contracts/agentsub_registry/Cargo.lock +2132 -0
- package/contracts/agentsub_registry/Cargo.toml +23 -0
- package/contracts/agentsub_registry/src/lib.rs +209 -0
- package/contracts/agentsub_registry/test_snapshots/test/test_subscription_lifecycle.1.json +289 -0
- package/dist/engine/auto-debit-keeper.d.ts +18 -0
- package/dist/engine/auto-debit-keeper.js +66 -0
- package/dist/engine/subscription-manager.d.ts +21 -0
- package/dist/engine/subscription-manager.js +114 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +25 -0
- package/dist/types/index.d.ts +37 -0
- package/dist/types/index.js +2 -0
- package/docs/index.html +388 -0
- package/package.json +32 -4
- package/scripts/verify-mainnet-agentsub.ts +111 -0
- package/src/engine/auto-debit-keeper.ts +83 -0
- package/src/engine/subscription-manager.ts +135 -0
- package/src/index.ts +10 -0
- package/src/types/index.ts +40 -0
- package/test/test-agentsub.js +44 -0
- package/tsconfig.json +16 -0
package/README.md
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AgentSub (Protocol 30)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Autonomous Web3 Recurring Subscription & Auto-Debit Protocol on Stellar Soroban Protocol 30.
|
|
4
|
+
|
|
5
|
+
AgentSub provides decentralized, pull-based recurring subscriptions (Auto-Debit) for autonomous AI agents, Web3 SaaS platforms, and digital service providers on Stellar Soroban.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ⚡ Problem Statement
|
|
10
|
+
In traditional Web3, recurring billing requires manual user wallet signatures on every invoice or relies on expensive Layer-1 EVM gas ($5–$20 per charge). On Stellar, previous dApps had no recurring payment standard, forcing AI agents and users into fragile manual payment flows.
|
|
11
|
+
|
|
12
|
+
## 💎 Solution
|
|
13
|
+
AgentSub leverages **Stellar Soroban Protocol 30 Scoped Allowances** and state rent management to enable:
|
|
14
|
+
1. **1-Click Auto-Debit Agreements:** Authorize continuous recurring service with strict interval ledgers and financial spend caps.
|
|
15
|
+
2. **Autonomous Keeper Sweeps:** Decentralized keeper bots monitor ledger sequences and trigger on-chain pull payments when due, claiming an automated 1% keeper tip.
|
|
16
|
+
3. **Instant Zero-Friction Cancellation:** Subscribers or merchants can revoke authorization on-chain at any time with a single transaction.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 🔗 Live On-Chain Stellar Mainnet Proof
|
|
21
|
+
|
|
22
|
+
* **Network:** Stellar Public Mainnet (Protocol 30)
|
|
23
|
+
* **Transaction Hash:** [`2dcc700c792df20a9cf6f5116fbf8f05be1fa433b6235bffbb1aba25bb7dec45`](https://stellar.expert/explorer/public/tx/2dcc700c792df20a9cf6f5116fbf8f05be1fa433b6235bffbb1aba25bb7dec45)
|
|
24
|
+
* **Ledger Sequence:** `#65,729,829`
|
|
25
|
+
* **Beneficiary Cold Vault:** `GBHRSZLBJNR32ERCZT6PE3HJVVQGXT5KWQXGL5SVEPJXUQUDXSDBCWVE`
|
|
26
|
+
* **Live Interactive Simulator:** [https://sorobanagents.github.io/agentsub/](https://sorobanagents.github.io/agentsub/)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 📦 Installation & Quickstart
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @sparkysolutions/agentsub
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { SubscriptionManager, AutoDebitKeeper } from "@sparkysolutions/agentsub";
|
|
38
|
+
|
|
39
|
+
// 1. Initialize Manager
|
|
40
|
+
const manager = new SubscriptionManager("GBHRSZLBJNR32ERCZT6PE3HJVVQGXT5KWQXGL5SVEPJXUQUDXSDBCWVE");
|
|
41
|
+
|
|
42
|
+
// 2. Subscribe to Daily Swarm Pro Tier (0.25 XLM / day with 2.50 XLM spend cap)
|
|
43
|
+
const agreement = manager.subscribe("GBHM5SCH2R5W5S63HVMQCXOFGCEXPSE2KL4GYRJY7GRTL4MYDB6M2CKY", "plan-ai-daily", "2.50");
|
|
44
|
+
console.log(`Agreement #${agreement.agreementId} Active: ${agreement.rateXlm} XLM / ${agreement.cadence}`);
|
|
45
|
+
|
|
46
|
+
// 3. Autonomous Keeper Sweeps due payments
|
|
47
|
+
const keeper = new AutoDebitKeeper(manager);
|
|
48
|
+
const results = keeper.sweepDueSubscriptions();
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 📜 Soroban Protocol 30 Rust Contract
|
|
54
|
+
|
|
55
|
+
Located in `contracts/agentsub_registry/src/lib.rs`.
|
|
56
|
+
|
|
57
|
+
```rust
|
|
58
|
+
pub fn create_subscription(
|
|
59
|
+
env: Env,
|
|
60
|
+
subscriber: Address,
|
|
61
|
+
merchant: Address,
|
|
62
|
+
rate_stroops: i128,
|
|
63
|
+
interval_ledgers: u32,
|
|
64
|
+
spend_cap_stroops: i128,
|
|
65
|
+
) -> u64;
|
|
66
|
+
|
|
67
|
+
pub fn charge_subscription(env: Env, agreement_id: u64, keeper: Address) -> bool;
|
|
68
|
+
|
|
69
|
+
pub fn cancel_subscription(env: Env, agreement_id: u64, caller: Address) -> bool;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Run contract tests:
|
|
73
|
+
```bash
|
|
74
|
+
cargo test --manifest-path contracts/agentsub_registry/Cargo.toml
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 🛡️ License
|
|
80
|
+
MIT License. Authored by SparkyPunk for SorobanAgents ecosystem.
|