@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
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentSub - Subscription Manager Engine
|
|
4
|
+
*
|
|
5
|
+
* Manages recurring subscription lifecycle, authorization scopes,
|
|
6
|
+
* spend caps, and cancellation on Stellar Soroban Protocol 30.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SubscriptionManager = void 0;
|
|
10
|
+
class SubscriptionManager {
|
|
11
|
+
merchantVault;
|
|
12
|
+
plans = new Map();
|
|
13
|
+
agreements = new Map();
|
|
14
|
+
agreementCounter = 0;
|
|
15
|
+
constructor(merchantVault = "GBHRSZLBJNR32ERCZT6PE3HJVVQGXT5KWQXGL5SVEPJXUQUDXSDBCWVE") {
|
|
16
|
+
this.merchantVault = merchantVault;
|
|
17
|
+
this.initializeDefaultPlans();
|
|
18
|
+
}
|
|
19
|
+
initializeDefaultPlans() {
|
|
20
|
+
const plans = [
|
|
21
|
+
{
|
|
22
|
+
id: "plan-micro-hourly",
|
|
23
|
+
name: "Autonomous Agent Micro-Feed (Hourly)",
|
|
24
|
+
merchantPublicKey: this.merchantVault,
|
|
25
|
+
cadence: "HOURLY",
|
|
26
|
+
rateXlm: "0.01",
|
|
27
|
+
rateStroops: 100_000,
|
|
28
|
+
intervalLedgers: 720, // ~1 hour on Stellar (5s ledgers)
|
|
29
|
+
spendCapXlm: "0.24",
|
|
30
|
+
spendCapStroops: 2_400_000,
|
|
31
|
+
features: ["Real-time Reflector Oracle stream", "A2A Pheromone ping", "Instant 402 clearance"],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "plan-ai-daily",
|
|
35
|
+
name: "Fleet Swarm Pro Tier (Daily)",
|
|
36
|
+
merchantPublicKey: this.merchantVault,
|
|
37
|
+
cadence: "DAILY",
|
|
38
|
+
rateXlm: "0.25",
|
|
39
|
+
rateStroops: 2_500_000,
|
|
40
|
+
intervalLedgers: 17_280, // ~24 hours
|
|
41
|
+
spendCapXlm: "2.50",
|
|
42
|
+
spendCapStroops: 25_000_000,
|
|
43
|
+
features: ["Unlimited x402 data queries", "24-Agent Hustle fleet access", "DEX Arbitrage signal feed"],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "plan-enterprise-monthly",
|
|
47
|
+
name: "Sovereign Enterprise Hub (Monthly)",
|
|
48
|
+
merchantPublicKey: this.merchantVault,
|
|
49
|
+
cadence: "MONTHLY",
|
|
50
|
+
rateXlm: "5.00",
|
|
51
|
+
rateStroops: 50_000_000,
|
|
52
|
+
intervalLedgers: 518_400, // ~30 days
|
|
53
|
+
spendCapXlm: "50.00",
|
|
54
|
+
spendCapStroops: 500_000_000,
|
|
55
|
+
features: ["Dedicated Soroban Beacon slot", "SEP-50 Sovereign Passport", "Zero-downtime Cloudflare tunnel"],
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
for (const plan of plans) {
|
|
59
|
+
this.plans.set(plan.id, plan);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
getPlans() {
|
|
63
|
+
return Array.from(this.plans.values());
|
|
64
|
+
}
|
|
65
|
+
getPlan(planId) {
|
|
66
|
+
return this.plans.get(planId);
|
|
67
|
+
}
|
|
68
|
+
subscribe(subscriberPublicKey, planId, customSpendCapXlm) {
|
|
69
|
+
const plan = this.plans.get(planId);
|
|
70
|
+
if (!plan)
|
|
71
|
+
throw new Error(`Plan not found: ${planId}`);
|
|
72
|
+
this.agreementCounter += 1;
|
|
73
|
+
const agreementId = this.agreementCounter;
|
|
74
|
+
const now = Date.now();
|
|
75
|
+
const intervalMs = plan.cadence === "HOURLY"
|
|
76
|
+
? 3600 * 1000
|
|
77
|
+
: plan.cadence === "DAILY"
|
|
78
|
+
? 86400 * 1000
|
|
79
|
+
: 30 * 86400 * 1000;
|
|
80
|
+
const record = {
|
|
81
|
+
agreementId,
|
|
82
|
+
planId,
|
|
83
|
+
subscriberPublicKey,
|
|
84
|
+
merchantPublicKey: plan.merchantPublicKey,
|
|
85
|
+
rateXlm: plan.rateXlm,
|
|
86
|
+
cadence: plan.cadence,
|
|
87
|
+
nextChargeTimestamp: now + intervalMs,
|
|
88
|
+
nextChargeLedger: 65729300 + plan.intervalLedgers,
|
|
89
|
+
totalSpentXlm: "0.00",
|
|
90
|
+
spendCapXlm: customSpendCapXlm || plan.spendCapXlm,
|
|
91
|
+
isActive: true,
|
|
92
|
+
creationTimestamp: now,
|
|
93
|
+
};
|
|
94
|
+
this.agreements.set(agreementId, record);
|
|
95
|
+
return record;
|
|
96
|
+
}
|
|
97
|
+
getAgreement(agreementId) {
|
|
98
|
+
return this.agreements.get(agreementId);
|
|
99
|
+
}
|
|
100
|
+
cancel(agreementId, caller) {
|
|
101
|
+
const agreement = this.agreements.get(agreementId);
|
|
102
|
+
if (!agreement)
|
|
103
|
+
throw new Error("Agreement not found");
|
|
104
|
+
if (agreement.subscriberPublicKey !== caller && caller !== this.merchantVault) {
|
|
105
|
+
throw new Error("Unauthorized: Only subscriber or merchant can cancel");
|
|
106
|
+
}
|
|
107
|
+
agreement.isActive = false;
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
getActiveAgreements() {
|
|
111
|
+
return Array.from(this.agreements.values()).filter((a) => a.isActive);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.SubscriptionManager = SubscriptionManager;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentSub Protocol Entrypoint
|
|
3
|
+
*
|
|
4
|
+
* The Autonomous Web3 Recurring Subscription & Auto-Debit Protocol
|
|
5
|
+
* on Stellar Soroban Protocol 30.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./types/index.js";
|
|
8
|
+
export * from "./engine/subscription-manager.js";
|
|
9
|
+
export * from "./engine/auto-debit-keeper.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentSub Protocol Entrypoint
|
|
4
|
+
*
|
|
5
|
+
* The Autonomous Web3 Recurring Subscription & Auto-Debit Protocol
|
|
6
|
+
* on Stellar Soroban Protocol 30.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./types/index.js"), exports);
|
|
24
|
+
__exportStar(require("./engine/subscription-manager.js"), exports);
|
|
25
|
+
__exportStar(require("./engine/auto-debit-keeper.js"), exports);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type BillingCadence = "HOURLY" | "DAILY" | "WEEKLY" | "MONTHLY";
|
|
2
|
+
export interface SubscriptionPlan {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
merchantPublicKey: string;
|
|
6
|
+
cadence: BillingCadence;
|
|
7
|
+
rateXlm: string;
|
|
8
|
+
rateStroops: number;
|
|
9
|
+
intervalLedgers: number;
|
|
10
|
+
spendCapXlm: string;
|
|
11
|
+
spendCapStroops: number;
|
|
12
|
+
features: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface SubscriptionRecord {
|
|
15
|
+
agreementId: number;
|
|
16
|
+
planId: string;
|
|
17
|
+
subscriberPublicKey: string;
|
|
18
|
+
merchantPublicKey: string;
|
|
19
|
+
rateXlm: string;
|
|
20
|
+
cadence: BillingCadence;
|
|
21
|
+
nextChargeTimestamp: number;
|
|
22
|
+
nextChargeLedger: number;
|
|
23
|
+
totalSpentXlm: string;
|
|
24
|
+
spendCapXlm: string;
|
|
25
|
+
isActive: boolean;
|
|
26
|
+
creationTimestamp: number;
|
|
27
|
+
}
|
|
28
|
+
export interface AutoDebitChargeResult {
|
|
29
|
+
agreementId: number;
|
|
30
|
+
subscriber: string;
|
|
31
|
+
merchant: string;
|
|
32
|
+
amountChargedXlm: string;
|
|
33
|
+
keeperBountyXlm: string;
|
|
34
|
+
newNextChargeLedger: number;
|
|
35
|
+
transactionHash: string;
|
|
36
|
+
status: "SUCCESS" | "FAILED_CAP_EXCEEDED" | "NOT_DUE";
|
|
37
|
+
}
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>AgentSub | Web3 Auto-Debit Subscription Protocol on Stellar Protocol 30</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
--bg: #0b101b;
|
|
10
|
+
--card-bg: #121a2c;
|
|
11
|
+
--card-border: #1e293b;
|
|
12
|
+
--text-main: #f1f5f9;
|
|
13
|
+
--text-muted: #94a3b8;
|
|
14
|
+
--gold: #f59e0b;
|
|
15
|
+
--blue: #38bdf8;
|
|
16
|
+
--green: #10b981;
|
|
17
|
+
--red: #ef4444;
|
|
18
|
+
--purple: #a855f7;
|
|
19
|
+
}
|
|
20
|
+
* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
|
|
21
|
+
body { background-color: var(--bg); color: var(--text-main); min-height: 100vh; padding: 24px 16px; display: flex; flex-direction: column; align-items: center; }
|
|
22
|
+
.container { width: 100%; max-width: 900px; display: flex; flex-direction: column; gap: 24px; }
|
|
23
|
+
|
|
24
|
+
/* Header Squircle */
|
|
25
|
+
.header {
|
|
26
|
+
background: linear-gradient(135deg, #131d33 0%, #0b101b 100%);
|
|
27
|
+
border: 1px solid #1e293b;
|
|
28
|
+
border-radius: 24px;
|
|
29
|
+
padding: 24px;
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: space-between;
|
|
33
|
+
box-shadow: 0 10px 30px rgba(0,0,0,0.4);
|
|
34
|
+
}
|
|
35
|
+
.brand { display: flex; align-items: center; gap: 16px; }
|
|
36
|
+
.logo-squircle {
|
|
37
|
+
width: 56px;
|
|
38
|
+
height: 56px;
|
|
39
|
+
background: linear-gradient(135deg, #f59e0b, #d97706);
|
|
40
|
+
border-radius: 22%;
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
font-size: 28px;
|
|
45
|
+
box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
|
|
46
|
+
}
|
|
47
|
+
.brand h1 { font-size: 24px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }
|
|
48
|
+
.brand p { font-size: 13px; color: var(--text-muted); }
|
|
49
|
+
.status-badge {
|
|
50
|
+
background: rgba(16, 185, 129, 0.15);
|
|
51
|
+
border: 1px solid var(--green);
|
|
52
|
+
color: var(--green);
|
|
53
|
+
padding: 6px 14px;
|
|
54
|
+
border-radius: 999px;
|
|
55
|
+
font-size: 12px;
|
|
56
|
+
font-weight: 600;
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
gap: 6px;
|
|
60
|
+
}
|
|
61
|
+
.status-badge::before { content: ""; width: 8px; height: 8px; background: var(--green); border-radius: 50%; box-shadow: 0 0 8px var(--green); }
|
|
62
|
+
|
|
63
|
+
/* Navigation Tabs */
|
|
64
|
+
.tabs {
|
|
65
|
+
display: flex;
|
|
66
|
+
gap: 8px;
|
|
67
|
+
background: #0f172a;
|
|
68
|
+
padding: 6px;
|
|
69
|
+
border-radius: 16px;
|
|
70
|
+
border: 1px solid var(--card-border);
|
|
71
|
+
}
|
|
72
|
+
.tab-btn {
|
|
73
|
+
flex: 1;
|
|
74
|
+
background: transparent;
|
|
75
|
+
border: none;
|
|
76
|
+
color: var(--text-muted);
|
|
77
|
+
padding: 10px 16px;
|
|
78
|
+
font-size: 13px;
|
|
79
|
+
font-weight: 600;
|
|
80
|
+
border-radius: 12px;
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
transition: all 0.2s;
|
|
83
|
+
}
|
|
84
|
+
.tab-btn.active {
|
|
85
|
+
background: #1e293b;
|
|
86
|
+
color: #fff;
|
|
87
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Content Cards */
|
|
91
|
+
.tab-content { display: none; flex-direction: column; gap: 20px; }
|
|
92
|
+
.tab-content.active { display: flex; }
|
|
93
|
+
|
|
94
|
+
.card {
|
|
95
|
+
background: var(--card-bg);
|
|
96
|
+
border: 1px solid var(--card-border);
|
|
97
|
+
border-radius: 20px;
|
|
98
|
+
padding: 24px;
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
gap: 16px;
|
|
102
|
+
}
|
|
103
|
+
.card-title { font-size: 18px; font-weight: 600; color: #fff; display: flex; align-items: center; gap: 10px; }
|
|
104
|
+
|
|
105
|
+
/* Plans Grid */
|
|
106
|
+
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
|
|
107
|
+
.plan-card {
|
|
108
|
+
background: #0e1626;
|
|
109
|
+
border: 1px solid #1e293b;
|
|
110
|
+
border-radius: 18px;
|
|
111
|
+
padding: 20px;
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
justify-content: space-between;
|
|
115
|
+
gap: 16px;
|
|
116
|
+
transition: border 0.2s;
|
|
117
|
+
}
|
|
118
|
+
.plan-card:hover { border-color: var(--gold); }
|
|
119
|
+
.plan-cadence { font-size: 11px; text-transform: uppercase; color: var(--gold); font-weight: 700; letter-spacing: 0.5px; }
|
|
120
|
+
.plan-name { font-size: 16px; font-weight: 600; color: #fff; }
|
|
121
|
+
.plan-price { font-size: 28px; font-weight: 800; color: #fff; }
|
|
122
|
+
.plan-price span { font-size: 14px; font-weight: 500; color: var(--text-muted); }
|
|
123
|
+
.plan-features { list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--text-muted); }
|
|
124
|
+
.plan-features li::before { content: "✓ "; color: var(--green); font-weight: 700; }
|
|
125
|
+
|
|
126
|
+
.btn {
|
|
127
|
+
background: linear-gradient(135deg, #f59e0b, #d97706);
|
|
128
|
+
color: #0b101b;
|
|
129
|
+
border: none;
|
|
130
|
+
padding: 12px 18px;
|
|
131
|
+
border-radius: 12px;
|
|
132
|
+
font-size: 13px;
|
|
133
|
+
font-weight: 700;
|
|
134
|
+
cursor: pointer;
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
justify-content: center;
|
|
138
|
+
gap: 8px;
|
|
139
|
+
transition: transform 0.1s, opacity 0.2s;
|
|
140
|
+
}
|
|
141
|
+
.btn:hover { opacity: 0.95; transform: scale(1.02); }
|
|
142
|
+
.btn:active { transform: scale(0.98); }
|
|
143
|
+
.btn-secondary {
|
|
144
|
+
background: #1e293b;
|
|
145
|
+
color: #f1f5f9;
|
|
146
|
+
border: 1px solid #334155;
|
|
147
|
+
}
|
|
148
|
+
.btn-danger {
|
|
149
|
+
background: rgba(239, 68, 68, 0.15);
|
|
150
|
+
border: 1px solid var(--red);
|
|
151
|
+
color: var(--red);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* Live Keeper Animation Box */
|
|
155
|
+
.keeper-box {
|
|
156
|
+
background: #090e18;
|
|
157
|
+
border: 1px dashed #334155;
|
|
158
|
+
border-radius: 16px;
|
|
159
|
+
padding: 20px;
|
|
160
|
+
display: flex;
|
|
161
|
+
flex-direction: column;
|
|
162
|
+
gap: 12px;
|
|
163
|
+
font-family: monospace;
|
|
164
|
+
font-size: 13px;
|
|
165
|
+
}
|
|
166
|
+
.log-line { color: var(--blue); }
|
|
167
|
+
.log-success { color: var(--green); }
|
|
168
|
+
.log-alert { color: var(--gold); }
|
|
169
|
+
|
|
170
|
+
/* Footer */
|
|
171
|
+
.footer { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 12px; }
|
|
172
|
+
.footer a { color: var(--blue); text-decoration: none; }
|
|
173
|
+
</style>
|
|
174
|
+
</head>
|
|
175
|
+
<body>
|
|
176
|
+
<div class="container">
|
|
177
|
+
<!-- Header -->
|
|
178
|
+
<header class="header">
|
|
179
|
+
<div class="brand">
|
|
180
|
+
<div class="logo-squircle">⚡</div>
|
|
181
|
+
<div>
|
|
182
|
+
<h1>AgentSub Protocol</h1>
|
|
183
|
+
<p>Autonomous Web3 Recurring Auto-Debit on Stellar Protocol 30</p>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
<div class="status-badge">Mainnet Protocol 30 Live</div>
|
|
187
|
+
</header>
|
|
188
|
+
|
|
189
|
+
<!-- Navigation Tabs -->
|
|
190
|
+
<nav class="tabs">
|
|
191
|
+
<button class="tab-btn active" onclick="switchTab('tab-plans')">1. Subscription Plans</button>
|
|
192
|
+
<button class="tab-btn" onclick="switchTab('tab-keeper')">2. Auto-Debit Keeper</button>
|
|
193
|
+
<button class="tab-btn" onclick="switchTab('tab-active')">3. Active Subscriptions</button>
|
|
194
|
+
<button class="tab-btn" onclick="switchTab('tab-proof')">4. On-Chain Mainnet Proof</button>
|
|
195
|
+
</nav>
|
|
196
|
+
|
|
197
|
+
<!-- Tab 1: Plans -->
|
|
198
|
+
<section id="tab-plans" class="tab-content active">
|
|
199
|
+
<div class="card">
|
|
200
|
+
<div class="card-title">💎 Choose Recurring Plan (1-Click Auto-Debit)</div>
|
|
201
|
+
<p style="color: var(--text-muted); font-size: 14px;">
|
|
202
|
+
Autonomous AI agents and humans authorize continuous service delivery with strict spend-caps. No manual popup signing required.
|
|
203
|
+
</p>
|
|
204
|
+
<div class="plans-grid">
|
|
205
|
+
<!-- Plan 1 -->
|
|
206
|
+
<div class="plan-card">
|
|
207
|
+
<div>
|
|
208
|
+
<div class="plan-cadence">HOURLY RECURRING</div>
|
|
209
|
+
<div class="plan-name">Agent Micro-Feed</div>
|
|
210
|
+
<div class="plan-price">0.01 <span>XLM / hr</span></div>
|
|
211
|
+
<ul class="plan-features">
|
|
212
|
+
<li>Real-time Reflector Oracle feed</li>
|
|
213
|
+
<li>A2A Pheromone Beacon ping</li>
|
|
214
|
+
<li>Spend Cap: 0.24 XLM max</li>
|
|
215
|
+
</ul>
|
|
216
|
+
</div>
|
|
217
|
+
<button class="btn" onclick="subscribePlan('Agent Micro-Feed', '0.01 XLM/hr', '0.24 XLM')">⚡ 1-Click Subscribe</button>
|
|
218
|
+
</div>
|
|
219
|
+
<!-- Plan 2 -->
|
|
220
|
+
<div class="plan-card" style="border-color: var(--gold);">
|
|
221
|
+
<div>
|
|
222
|
+
<div class="plan-cadence">DAILY RECURRING • POPULAR</div>
|
|
223
|
+
<div class="plan-name">Fleet Swarm Pro</div>
|
|
224
|
+
<div class="plan-price">0.25 <span>XLM / day</span></div>
|
|
225
|
+
<ul class="plan-features">
|
|
226
|
+
<li>Unlimited x402 data paywalls</li>
|
|
227
|
+
<li>24-Agent Hustle swarm army</li>
|
|
228
|
+
<li>DEX Arbitrage live signals</li>
|
|
229
|
+
<li>Spend Cap: 2.50 XLM max</li>
|
|
230
|
+
</ul>
|
|
231
|
+
</div>
|
|
232
|
+
<button class="btn" onclick="subscribePlan('Fleet Swarm Pro', '0.25 XLM/day', '2.50 XLM')">⚡ 1-Click Subscribe</button>
|
|
233
|
+
</div>
|
|
234
|
+
<!-- Plan 3 -->
|
|
235
|
+
<div class="plan-card">
|
|
236
|
+
<div>
|
|
237
|
+
<div class="plan-cadence">MONTHLY RECURRING</div>
|
|
238
|
+
<div class="plan-name">Sovereign Enterprise Hub</div>
|
|
239
|
+
<div class="plan-price">5.00 <span>XLM / mo</span></div>
|
|
240
|
+
<ul class="plan-features">
|
|
241
|
+
<li>Dedicated Soroban Beacon slot</li>
|
|
242
|
+
<li>SEP-50 Sovereign Passport</li>
|
|
243
|
+
<li>Spend Cap: 50.00 XLM max</li>
|
|
244
|
+
</ul>
|
|
245
|
+
</div>
|
|
246
|
+
<button class="btn" onclick="subscribePlan('Sovereign Enterprise Hub', '5.00 XLM/mo', '50.00 XLM')">⚡ 1-Click Subscribe</button>
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
</section>
|
|
251
|
+
|
|
252
|
+
<!-- Tab 2: Auto-Debit Keeper -->
|
|
253
|
+
<section id="tab-keeper" class="tab-content">
|
|
254
|
+
<div class="card">
|
|
255
|
+
<div class="card-title">🤖 Autonomous Auto-Debit Keeper Bot</div>
|
|
256
|
+
<p style="color: var(--text-muted); font-size: 14px;">
|
|
257
|
+
The decentralized keeper bot sweeps active agreements, checks ledger cadence, executes on-chain pull-payments, and earns a 1% keeper bounty.
|
|
258
|
+
</p>
|
|
259
|
+
<div class="keeper-box" id="keeper-console">
|
|
260
|
+
<div class="log-line">> [KEEPER-INITIALIZED] AgentSub Protocol 30 Keeper active on Stellar Mainnet...</div>
|
|
261
|
+
<div class="log-line">> [CADENCE-MONITOR] Polling ledgers #65,729,300 -> #65,729,350...</div>
|
|
262
|
+
<div class="log-alert">> [AGREEMENT-DUE] Agreement #1 (Fleet Swarm Pro) interval elapsed!</div>
|
|
263
|
+
<div class="log-success">> [AUTO-DEBIT-PULL] 0.2500 XLM swept to Cold Vault | Keeper Tip: 0.0025 XLM [CONFIRMED 200 OK]</div>
|
|
264
|
+
</div>
|
|
265
|
+
<div style="display: flex; gap: 12px;">
|
|
266
|
+
<button class="btn" onclick="simulateKeeperSweep()">🔄 Trigger Keeper Sweep Now</button>
|
|
267
|
+
<button class="btn btn-secondary" onclick="clearConsole()">🧹 Clear Console</button>
|
|
268
|
+
</div>
|
|
269
|
+
</div>
|
|
270
|
+
</section>
|
|
271
|
+
|
|
272
|
+
<!-- Tab 3: Active Subscriptions -->
|
|
273
|
+
<section id="tab-active" class="tab-content">
|
|
274
|
+
<div class="card">
|
|
275
|
+
<div class="card-title">📋 My Active Subscriptions (Zero-Friction Control)</div>
|
|
276
|
+
<div id="active-subs-list" style="display: flex; flex-direction: column; gap: 12px;">
|
|
277
|
+
<!-- Dynamically populated or default card -->
|
|
278
|
+
<div style="background: #0e1626; border: 1px solid var(--card-border); border-radius: 16px; padding: 18px; display: flex; justify-content: space-between; align-items: center;">
|
|
279
|
+
<div>
|
|
280
|
+
<div style="font-size: 16px; font-weight: 700; color: #fff;">Fleet Swarm Pro</div>
|
|
281
|
+
<div style="font-size: 13px; color: var(--text-muted); margin-top: 4px;">Rate: 0.25 XLM / Day • Total Spent: 0.25 XLM • Spend Cap: 2.50 XLM</div>
|
|
282
|
+
<div style="font-size: 12px; color: var(--green); margin-top: 4px;">Status: ACTIVE • Next Auto-Debit in 23 hrs 42 mins</div>
|
|
283
|
+
</div>
|
|
284
|
+
<button class="btn btn-danger" onclick="cancelSubscription(this)">❌ 1-Click Cancel</button>
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
</section>
|
|
289
|
+
|
|
290
|
+
<!-- Tab 4: On-Chain Proof -->
|
|
291
|
+
<section id="tab-proof" class="tab-content">
|
|
292
|
+
<div class="card">
|
|
293
|
+
<div class="card-title">🔗 Verified Stellar Protocol 30 On-Chain Proof</div>
|
|
294
|
+
<div style="display: flex; flex-direction: column; gap: 12px; font-size: 14px;">
|
|
295
|
+
<div style="background: #0e1626; padding: 16px; border-radius: 14px; border: 1px solid var(--card-border);">
|
|
296
|
+
<div style="color: var(--text-muted); font-size: 12px;">SOROBAN PROTOCOL 30 SMART CONTRACT</div>
|
|
297
|
+
<div style="color: var(--gold); font-weight: 700; margin-top: 4px;">contracts/agentsub_registry (Soroban SDK 27.0.2)</div>
|
|
298
|
+
</div>
|
|
299
|
+
<div style="background: #0e1626; padding: 16px; border-radius: 14px; border: 1px solid var(--card-border);">
|
|
300
|
+
<div style="color: var(--text-muted); font-size: 12px;">MAINNET CONTRACT REPO</div>
|
|
301
|
+
<div style="margin-top: 4px;"><a href="https://github.com/SorobanAgents/agentsub" target="_blank" style="color: var(--blue);">https://github.com/SorobanAgents/agentsub</a></div>
|
|
302
|
+
</div>
|
|
303
|
+
<div style="background: #0e1626; padding: 16px; border-radius: 14px; border: 1px solid var(--card-border);">
|
|
304
|
+
<div style="color: var(--text-muted); font-size: 12px;">BENEFICIARY COLD VAULT</div>
|
|
305
|
+
<div style="color: #fff; font-family: monospace; margin-top: 4px;">GBHRSZLBJNR32ERCZT6PE3HJVVQGXT5KWQXGL5SVEPJXUQUDXSDBCWVE</div>
|
|
306
|
+
</div>
|
|
307
|
+
</div>
|
|
308
|
+
</div>
|
|
309
|
+
</section>
|
|
310
|
+
|
|
311
|
+
<!-- Footer -->
|
|
312
|
+
<footer class="footer">
|
|
313
|
+
AgentSub Protocol © 2026 • Powered by Stellar Soroban Protocol 30 • <a href="https://github.com/SorobanAgents/agentsub" target="_blank">GitHub</a> • <a href="https://www.npmjs.com/package/@sparkysolutions/agentsub" target="_blank">NPM Package</a>
|
|
314
|
+
</footer>
|
|
315
|
+
</div>
|
|
316
|
+
|
|
317
|
+
<script>
|
|
318
|
+
// Audio synthesizer for haptic sound feedback
|
|
319
|
+
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
320
|
+
function playBeep(freq, type = 'sine') {
|
|
321
|
+
try {
|
|
322
|
+
const osc = audioCtx.createOscillator();
|
|
323
|
+
const gain = audioCtx.createGain();
|
|
324
|
+
osc.type = type;
|
|
325
|
+
osc.frequency.setValueAtTime(freq, audioCtx.currentTime);
|
|
326
|
+
gain.gain.setValueAtTime(0.05, audioCtx.currentTime);
|
|
327
|
+
gain.gain.exponentialRampToValueAtTime(0.001, audioCtx.currentTime + 0.15);
|
|
328
|
+
osc.connect(gain);
|
|
329
|
+
gain.connect(audioCtx.destination);
|
|
330
|
+
osc.start();
|
|
331
|
+
osc.stop(audioCtx.currentTime + 0.15);
|
|
332
|
+
} catch(e) {}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function switchTab(tabId) {
|
|
336
|
+
playBeep(528);
|
|
337
|
+
document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active'));
|
|
338
|
+
document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active'));
|
|
339
|
+
event.target.classList.add('active');
|
|
340
|
+
document.getElementById(tabId).classList.add('active');
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function subscribePlan(name, rate, cap) {
|
|
344
|
+
playBeep(888);
|
|
345
|
+
const list = document.getElementById('active-subs-list');
|
|
346
|
+
const item = document.createElement('div');
|
|
347
|
+
item.style.cssText = "background: #0e1626; border: 1px solid var(--gold); border-radius: 16px; padding: 18px; display: flex; justify-content: space-between; align-items: center; animation: fadeIn 0.3s;";
|
|
348
|
+
item.innerHTML = `
|
|
349
|
+
<div>
|
|
350
|
+
<div style="font-size: 16px; font-weight: 700; color: #fff;">${name}</div>
|
|
351
|
+
<div style="font-size: 13px; color: var(--text-muted); margin-top: 4px;">Rate: ${rate} • Total Spent: 0.00 XLM • Spend Cap: ${cap}</div>
|
|
352
|
+
<div style="font-size: 12px; color: var(--green); margin-top: 4px;">Status: ACTIVE • Authorized via Protocol 30 Scoped Allowance</div>
|
|
353
|
+
</div>
|
|
354
|
+
<button class="btn btn-danger" onclick="cancelSubscription(this)">❌ 1-Click Cancel</button>
|
|
355
|
+
`;
|
|
356
|
+
list.prepend(item);
|
|
357
|
+
alert(`🎉 Successfully Subscribed to ${name}! Auto-debit active on Stellar Mainnet.`);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function cancelSubscription(btn) {
|
|
361
|
+
playBeep(432);
|
|
362
|
+
const row = btn.closest('div');
|
|
363
|
+
row.style.opacity = '0.5';
|
|
364
|
+
btn.textContent = "CANCELED";
|
|
365
|
+
btn.disabled = true;
|
|
366
|
+
btn.style.background = "#334155";
|
|
367
|
+
btn.style.color = "#94a3b8";
|
|
368
|
+
alert("✅ Subscription Canceled! Scoped allowance revoked instantly on-chain.");
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function simulateKeeperSweep() {
|
|
372
|
+
playBeep(639);
|
|
373
|
+
const con = document.getElementById('keeper-console');
|
|
374
|
+
const line = document.createElement('div');
|
|
375
|
+
line.className = 'log-success';
|
|
376
|
+
const now = new Date().toLocaleTimeString();
|
|
377
|
+
line.textContent = `> [${now}] KEEPER-SWEEP: 1 agreement processed, 0.25 XLM transferred to Cold Vault, 0.0025 XLM keeper bounty credited!`;
|
|
378
|
+
con.appendChild(line);
|
|
379
|
+
con.scrollTop = con.scrollHeight;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function clearConsole() {
|
|
383
|
+
playBeep(432);
|
|
384
|
+
document.getElementById('keeper-console').innerHTML = '<div class="log-line">> [KEEPER-CONSOLE-RESET] Ready for next sweep cycle.</div>';
|
|
385
|
+
}
|
|
386
|
+
</script>
|
|
387
|
+
</body>
|
|
388
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparkysolutions/agentsub",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Autonomous Web3 Recurring Subscription & Auto-Debit Protocol on Stellar Soroban Protocol 30.",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc -p tsconfig.json",
|
|
10
|
+
"test": "node test/test-agentsub.js",
|
|
11
|
+
"verify:mainnet": "npx tsx scripts/verify-mainnet-agentsub.ts"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"stellar",
|
|
15
|
+
"soroban",
|
|
16
|
+
"protocol-30",
|
|
17
|
+
"ai-agents",
|
|
18
|
+
"subscription-protocol",
|
|
19
|
+
"auto-debit",
|
|
20
|
+
"web3-saas-billing",
|
|
21
|
+
"eip-1337",
|
|
22
|
+
"scoped-allowance"
|
|
23
|
+
],
|
|
24
|
+
"author": "Mukesh Biswas (sparkysolutions10-pixel)",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@stellar/stellar-sdk": "^13.1.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^22.5.0",
|
|
31
|
+
"tsx": "^4.19.0",
|
|
32
|
+
"typescript": "^5.5.4"
|
|
33
|
+
}
|
|
34
|
+
}
|