clawpowers 1.1.4 → 2.2.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/CHANGELOG.md +126 -0
- package/COMPATIBILITY.md +13 -0
- package/KNOWN_LIMITATIONS.md +19 -0
- package/LICENSE +44 -0
- package/LICENSING.md +10 -0
- package/README.md +378 -210
- package/SECURITY.md +52 -0
- package/dist/index.d.ts +1477 -0
- package/dist/index.js +3464 -0
- package/dist/index.js.map +1 -0
- package/native/Cargo.lock +4863 -0
- package/native/Cargo.toml +73 -0
- package/native/crates/canonical/Cargo.toml +24 -0
- package/native/crates/canonical/src/lib.rs +673 -0
- package/native/crates/compression/Cargo.toml +20 -0
- package/native/crates/compression/benches/compression_bench.rs +42 -0
- package/native/crates/compression/src/lib.rs +393 -0
- package/native/crates/evm-eth/Cargo.toml +13 -0
- package/native/crates/evm-eth/src/lib.rs +105 -0
- package/native/crates/fee/Cargo.toml +15 -0
- package/native/crates/fee/src/lib.rs +281 -0
- package/native/crates/index/Cargo.toml +16 -0
- package/native/crates/index/src/lib.rs +277 -0
- package/native/crates/policy/Cargo.toml +17 -0
- package/native/crates/policy/src/lib.rs +614 -0
- package/native/crates/security/Cargo.toml +22 -0
- package/native/crates/security/src/lib.rs +478 -0
- package/native/crates/tokens/Cargo.toml +13 -0
- package/native/crates/tokens/src/lib.rs +534 -0
- package/native/crates/verification/Cargo.toml +23 -0
- package/native/crates/verification/src/lib.rs +333 -0
- package/native/crates/wallet/Cargo.toml +20 -0
- package/native/crates/wallet/src/lib.rs +261 -0
- package/native/crates/x402/Cargo.toml +30 -0
- package/native/crates/x402/src/lib.rs +423 -0
- package/native/ffi/Cargo.toml +34 -0
- package/native/ffi/build.rs +4 -0
- package/native/ffi/index.node +0 -0
- package/native/ffi/src/lib.rs +352 -0
- package/native/ffi/tests/integration.rs +354 -0
- package/native/pyo3/Cargo.toml +26 -0
- package/native/pyo3/pyproject.toml +16 -0
- package/native/pyo3/src/lib.rs +407 -0
- package/native/pyo3/tests/test_smoke.py +180 -0
- package/native/wasm/Cargo.toml +44 -0
- package/native/wasm/pkg/.gitignore +6 -0
- package/native/wasm/pkg/clawpowers_wasm.d.ts +208 -0
- package/native/wasm/pkg/clawpowers_wasm.js +872 -0
- package/native/wasm/pkg/clawpowers_wasm_bg.wasm +0 -0
- package/native/wasm/pkg/clawpowers_wasm_bg.wasm.d.ts +40 -0
- package/native/wasm/pkg/package.json +17 -0
- package/native/wasm/pkg-node/.gitignore +6 -0
- package/native/wasm/pkg-node/clawpowers_wasm.d.ts +143 -0
- package/native/wasm/pkg-node/clawpowers_wasm.js +798 -0
- package/native/wasm/pkg-node/clawpowers_wasm_bg.wasm +0 -0
- package/native/wasm/pkg-node/clawpowers_wasm_bg.wasm.d.ts +40 -0
- package/native/wasm/pkg-node/package.json +13 -0
- package/native/wasm/src/lib.rs +433 -0
- package/package.json +71 -44
- package/src/skills/catalog.ts +435 -0
- package/src/skills/executor.ts +56 -0
- package/src/skills/index.ts +3 -0
- package/src/skills/itp/SKILL.md +112 -0
- package/src/skills/loader.ts +193 -0
- package/.claude-plugin/manifest.json +0 -19
- package/.codex/INSTALL.md +0 -36
- package/.cursor-plugin/manifest.json +0 -21
- package/.opencode/INSTALL.md +0 -52
- package/ARCHITECTURE.md +0 -69
- package/bin/clawpowers.js +0 -625
- package/bin/clawpowers.sh +0 -91
- package/docs/demo/clawpowers-demo.cast +0 -197
- package/docs/demo/clawpowers-demo.gif +0 -0
- package/docs/launch-images/25-skills-breakdown.jpg +0 -0
- package/docs/launch-images/clawpowers-vs-superpowers.jpg +0 -0
- package/docs/launch-images/economic-code-optimization.jpg +0 -0
- package/docs/launch-images/native-vs-bridge-2.jpg +0 -0
- package/docs/launch-images/native-vs-bridge.jpg +0 -0
- package/docs/launch-images/post1-hero-lobster.jpg +0 -0
- package/docs/launch-images/post2-dashboard.jpg +0 -0
- package/docs/launch-images/post3-superpowers.jpg +0 -0
- package/docs/launch-images/post4-before-after.jpg +0 -0
- package/docs/launch-images/post5-install-now.jpg +0 -0
- package/docs/launch-images/ultimate-stack.jpg +0 -0
- package/docs/launch-posts.md +0 -76
- package/docs/quickstart-first-transaction.md +0 -204
- package/gemini-extension.json +0 -32
- package/hooks/session-start +0 -205
- package/hooks/session-start.cmd +0 -43
- package/hooks/session-start.js +0 -163
- package/runtime/demo/README.md +0 -78
- package/runtime/demo/x402-mock-server.js +0 -230
- package/runtime/feedback/analyze.js +0 -621
- package/runtime/feedback/analyze.sh +0 -546
- package/runtime/init.js +0 -210
- package/runtime/init.sh +0 -178
- package/runtime/metrics/collector.js +0 -361
- package/runtime/metrics/collector.sh +0 -308
- package/runtime/payments/ledger.js +0 -305
- package/runtime/payments/ledger.sh +0 -262
- package/runtime/payments/pipeline.js +0 -455
- package/runtime/persistence/store.js +0 -433
- package/runtime/persistence/store.sh +0 -303
- package/skill.json +0 -106
- package/skills/agent-bounties/SKILL.md +0 -553
- package/skills/agent-payments/SKILL.md +0 -479
- package/skills/brainstorming/SKILL.md +0 -233
- package/skills/content-pipeline/SKILL.md +0 -282
- package/skills/cross-project-knowledge/SKILL.md +0 -345
- package/skills/dispatching-parallel-agents/SKILL.md +0 -305
- package/skills/economic-code-optimization/SKILL.md +0 -265
- package/skills/executing-plans/SKILL.md +0 -255
- package/skills/finishing-a-development-branch/SKILL.md +0 -260
- package/skills/formal-verification-lite/SKILL.md +0 -441
- package/skills/learn-how-to-learn/SKILL.md +0 -235
- package/skills/market-intelligence/SKILL.md +0 -323
- package/skills/meta-skill-evolution/SKILL.md +0 -325
- package/skills/prospecting/SKILL.md +0 -454
- package/skills/receiving-code-review/SKILL.md +0 -225
- package/skills/requesting-code-review/SKILL.md +0 -206
- package/skills/security-audit/SKILL.md +0 -353
- package/skills/self-healing-code/SKILL.md +0 -369
- package/skills/subagent-driven-development/SKILL.md +0 -244
- package/skills/systematic-debugging/SKILL.md +0 -355
- package/skills/test-driven-development/SKILL.md +0 -416
- package/skills/using-clawpowers/SKILL.md +0 -160
- package/skills/using-git-worktrees/SKILL.md +0 -261
- package/skills/validator/SKILL.md +0 -281
- package/skills/verification-before-completion/SKILL.md +0 -254
- package/skills/writing-plans/SKILL.md +0 -276
- package/skills/writing-skills/SKILL.md +0 -260
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: agent-payments
|
|
3
|
-
description: Enable agents to transact autonomously across a full multi-chain financial stack — x402 payments, Uniswap V3 swaps, CCTP bridging, ERC-8004 identity, mutual stake escrow, spending policies, and agent-to-agent delegation (AP2). Activate when an agent needs to pay for an API, swap tokens, bridge assets, escrow funds for a task, or establish on-chain identity.
|
|
4
|
-
version: 6.0.0
|
|
5
|
-
requires:
|
|
6
|
-
tools: [bash, node]
|
|
7
|
-
runtime: true
|
|
8
|
-
metrics:
|
|
9
|
-
tracks: [payments_attempted, payments_succeeded, swaps_executed, bridges_initiated, escrows_created, spending_per_session, limit_enforcement_hits]
|
|
10
|
-
improves: [payment_routing, limit_calibration, retry_strategy, swap_routing, bridge_selection]
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
# Agent Payments
|
|
14
|
-
|
|
15
|
-
## When to Use
|
|
16
|
-
|
|
17
|
-
Apply this skill when:
|
|
18
|
-
|
|
19
|
-
- An HTTP request returns `402 Payment Required`
|
|
20
|
-
- You need to call a premium API that requires per-request payment
|
|
21
|
-
- You're accessing a paid AI model, compute resource, or data service
|
|
22
|
-
- You need to purchase a resource (storage, credits, bandwidth) autonomously
|
|
23
|
-
- An agent-to-agent payment or task delegation is required (AP2 protocol)
|
|
24
|
-
- You need to swap tokens across Base, Arbitrum, Optimism, or Polygon
|
|
25
|
-
- You need to bridge USDC between EVM chains or to Solana (CCTP V2)
|
|
26
|
-
- You need to establish or verify on-chain agent identity (ERC-8004)
|
|
27
|
-
- You need to escrow funds for a multi-agent task (mutual stake or optimistic)
|
|
28
|
-
- Gas sponsorship is needed for a gasless user experience
|
|
29
|
-
|
|
30
|
-
**Skip when:**
|
|
31
|
-
- The service requires human authorization for payment (no wallet configured)
|
|
32
|
-
- The payment would exceed the configured spending limit (surface to operator)
|
|
33
|
-
- The service uses subscription billing (not per-request x402)
|
|
34
|
-
- The payment is above threshold for autonomous authorization (see limits)
|
|
35
|
-
|
|
36
|
-
**Decision tree:**
|
|
37
|
-
```
|
|
38
|
-
Is the response HTTP 402?
|
|
39
|
-
├── No → Does the task require swap/bridge/escrow/identity?
|
|
40
|
-
│ ├── No → This skill doesn't apply
|
|
41
|
-
│ └── Yes → Jump to the relevant section below
|
|
42
|
-
└── Yes → Is a wallet configured?
|
|
43
|
-
├── No → Run setup (see Setup section)
|
|
44
|
-
└── Yes → Does this payment fit within spending limits?
|
|
45
|
-
├── No → Queue via agentExecute or request human auth
|
|
46
|
-
└── Yes → Proceed with autonomous payment
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Dry-Run Mode
|
|
50
|
-
|
|
51
|
-
**Default mode is dry-run.** Until you explicitly enable live payments, the agent-payments skill operates in observation mode: it detects payment requirements, evaluates spending policy, and logs what *would* happen — without moving any funds.
|
|
52
|
-
|
|
53
|
-
### What Dry-Run Does
|
|
54
|
-
|
|
55
|
-
- Intercepts HTTP 402 responses and parses x402 payment requirements
|
|
56
|
-
- Evaluates the payment against your configured policy (limits, allowlist, mode)
|
|
57
|
-
- Logs a structured entry to `~/.clawpowers/logs/payments.jsonl` describing the decision
|
|
58
|
-
- Reports the outcome inline: `[dry-run: would pay $0.03 USDC on base-sepolia]`
|
|
59
|
-
- Never submits a transaction or touches a wallet
|
|
60
|
-
|
|
61
|
-
### No Funds Move in Dry-Run
|
|
62
|
-
|
|
63
|
-
Dry-run is safe to leave enabled indefinitely. No wallet is required, no credentials are needed, and no on-chain operations occur. The skill continues to function — it simply skips the actual payment step and logs instead.
|
|
64
|
-
|
|
65
|
-
### Build Confidence Before Going Live
|
|
66
|
-
|
|
67
|
-
After 10+ dry-run cycles, review your payment log:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
npx clawpowers payments log
|
|
71
|
-
npx clawpowers payments summary
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
You'll see exactly which skills are hitting payment gates, which APIs require payment, which chains and assets are involved, and how much you would have spent. When the pattern looks predictable and the amounts look reasonable, enable live payments with confidence.
|
|
75
|
-
|
|
76
|
-
### How to Switch Modes
|
|
77
|
-
|
|
78
|
-
**Interactive wizard (recommended):**
|
|
79
|
-
```bash
|
|
80
|
-
npx clawpowers payments setup
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
**Manual config edit:**
|
|
84
|
-
Edit `~/.clawpowers/config.json`:
|
|
85
|
-
```json
|
|
86
|
-
{
|
|
87
|
-
"payments": {
|
|
88
|
-
"enabled": true,
|
|
89
|
-
"mode": "live",
|
|
90
|
-
"per_tx_limit_usd": 0.10,
|
|
91
|
-
"daily_limit_usd": 5.00
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Example Dry-Run Log Entry
|
|
97
|
-
|
|
98
|
-
```json
|
|
99
|
-
{
|
|
100
|
-
"timestamp": "2026-03-22T21:42:00Z",
|
|
101
|
-
"skill": "agent-payments",
|
|
102
|
-
"type": "decision",
|
|
103
|
-
"url": "https://api.example.com/premium-data",
|
|
104
|
-
"required_amount": "30000",
|
|
105
|
-
"asset": "USDC",
|
|
106
|
-
"chain": "base-sepolia",
|
|
107
|
-
"policy_result": "dry_run",
|
|
108
|
-
"reason": "payments.mode=dry_run",
|
|
109
|
-
"would_have_paid": true
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
`would_have_paid: true` means the payment would have been approved by your policy — only the dry-run mode prevented it from executing.
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## Background: x402 Protocol
|
|
118
|
-
|
|
119
|
-
The x402 protocol is a standard for machine-to-machine payments embedded in HTTP. When a server requires payment it returns:
|
|
120
|
-
|
|
121
|
-
```http
|
|
122
|
-
HTTP/1.1 402 Payment Required
|
|
123
|
-
X-Payment-Required: {"scheme":"exact","network":"base","maxAmountRequired":"1000000","asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","payTo":"0xMERCHANT","resource":"https://api.example.com/premium-endpoint","description":"1 API call"}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
The agent then:
|
|
127
|
-
1. Constructs a payment matching the requirement
|
|
128
|
-
2. Submits the payment (on-chain or via payment channel)
|
|
129
|
-
3. Includes payment proof in the retry request
|
|
130
|
-
4. Server validates and processes the original request
|
|
131
|
-
|
|
132
|
-
Reference implementation: [agentpay-mcp](https://github.com/up2itnow0822/agentpay-mcp) (integrated into NVIDIA NeMo Agent Toolkit)
|
|
133
|
-
|
|
134
|
-
## Setup
|
|
135
|
-
|
|
136
|
-
### Install agentwallet-sdk
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
npm install agentwallet-sdk viem
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Supported Chains
|
|
143
|
-
|
|
144
|
-
Base, Ethereum, Arbitrum, Polygon, Optimism, Avalanche, Unichain, Linea, Sonic, World Chain, Base Sepolia (testnet). Solana is supported for CCTP V2 bridging.
|
|
145
|
-
|
|
146
|
-
## Core Methodology
|
|
147
|
-
|
|
148
|
-
### 1. Create Wallet + Set Spending Policy
|
|
149
|
-
|
|
150
|
-
Non-custodial ERC-6551 token-bound wallets are available on all 11 supported EVM chains. Spending limits are enforced by smart contract — the agent cannot override them.
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
import { createWallet, setSpendPolicy, agentExecute, NATIVE_TOKEN } from 'agentwallet-sdk';
|
|
154
|
-
|
|
155
|
-
const wallet = createWallet({
|
|
156
|
-
accountAddress: '0x...',
|
|
157
|
-
chain: 'base',
|
|
158
|
-
walletClient, // viem WalletClient
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// Set per-token, per-period on-chain spending limits
|
|
162
|
-
await setSpendPolicy(wallet, {
|
|
163
|
-
token: NATIVE_TOKEN,
|
|
164
|
-
perTxLimit: 25000000000000000n, // 0.025 ETH per transaction
|
|
165
|
-
periodLimit: 500000000000000000n, // 0.5 ETH per period
|
|
166
|
-
periodLength: 86400, // 24-hour rolling period
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// agentExecute auto-approves within limits, queues if over
|
|
170
|
-
const result = await agentExecute(wallet, {
|
|
171
|
-
to: '0x...',
|
|
172
|
-
value: 10000000000000000n, // 0.01 ETH
|
|
173
|
-
});
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
**`agentExecute` behavior:**
|
|
177
|
-
- Within limits → executes immediately, returns transaction receipt
|
|
178
|
-
- Over limits → queues the payment, returns queue ID for human review
|
|
179
|
-
- Exceeded daily cap → returns `LIMIT_EXCEEDED` with details
|
|
180
|
-
|
|
181
|
-
### 2. x402 Payments (Multi-Chain)
|
|
182
|
-
|
|
183
|
-
```typescript
|
|
184
|
-
import { createX402Client } from 'agentwallet-sdk';
|
|
185
|
-
|
|
186
|
-
const x402 = createX402Client(wallet, {
|
|
187
|
-
supportedNetworks: ['base:8453', 'arbitrum:42161'],
|
|
188
|
-
globalDailyLimit: 10_000_000n, // 10 USDC daily cap (6 decimals)
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// Auto-detects network, handles 402 → pay → retry transparently
|
|
192
|
-
const response = await x402.fetch('https://api.example.com/premium');
|
|
193
|
-
const data = await response.json();
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
The client automatically:
|
|
197
|
-
- Parses the `X-Payment-Required` header
|
|
198
|
-
- Selects the cheapest supported network
|
|
199
|
-
- Constructs and submits the payment
|
|
200
|
-
- Retries the original request with proof
|
|
201
|
-
|
|
202
|
-
### 3. Token Swaps (Uniswap V3)
|
|
203
|
-
|
|
204
|
-
Available on Base, Arbitrum, Optimism, Polygon. Use the chain-specific token registries: `BASE_TOKENS`, `ARBITRUM_TOKENS`, `OPTIMISM_TOKENS`, `POLYGON_TOKENS`.
|
|
205
|
-
|
|
206
|
-
```typescript
|
|
207
|
-
import { attachSwap } from 'agentwallet-sdk/swap';
|
|
208
|
-
import { BASE_TOKENS } from 'agentwallet-sdk';
|
|
209
|
-
|
|
210
|
-
const swap = attachSwap(wallet, { chain: 'base' });
|
|
211
|
-
|
|
212
|
-
await swap.swap(
|
|
213
|
-
BASE_TOKENS.WETH,
|
|
214
|
-
BASE_TOKENS.USDC,
|
|
215
|
-
amount,
|
|
216
|
-
{ slippageBps: 50 }, // 0.5% slippage tolerance
|
|
217
|
-
);
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
Token registries expose canonical addresses for all major tokens on each chain. Always use registry constants rather than hardcoding addresses.
|
|
221
|
-
|
|
222
|
-
### 4. CCTP V2 Bridge (EVM ↔ EVM and EVM ↔ Solana)
|
|
223
|
-
|
|
224
|
-
Bridge USDC across any supported chain pair, including to/from Solana.
|
|
225
|
-
|
|
226
|
-
```typescript
|
|
227
|
-
import { CCTPBridge } from 'agentwallet-sdk';
|
|
228
|
-
|
|
229
|
-
const bridge = new CCTPBridge({ sourceChain: 'base', walletClient });
|
|
230
|
-
|
|
231
|
-
const { transferId } = await bridge.transfer({
|
|
232
|
-
destinationChain: 'arbitrum', // or 'solana' for cross-ecosystem
|
|
233
|
-
amount: 100_000_000n, // 100 USDC (6 decimals)
|
|
234
|
-
recipient: '0x...',
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
// Poll for settlement
|
|
238
|
-
const status = await bridge.getStatus(transferId);
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### 5. ERC-8004 On-Chain Agent Identity
|
|
242
|
-
|
|
243
|
-
Register and manage verifiable on-chain identity for agents. Three registries: Identity, Reputation, Validation.
|
|
244
|
-
|
|
245
|
-
```typescript
|
|
246
|
-
import { AgentIdentity } from 'agentwallet-sdk';
|
|
247
|
-
|
|
248
|
-
const identity = new AgentIdentity({ chain: 'base', walletClient });
|
|
249
|
-
|
|
250
|
-
// Register agent identity
|
|
251
|
-
const { agentId } = await identity.register({
|
|
252
|
-
name: 'my-agent',
|
|
253
|
-
capabilities: ['payments', 'swaps', 'data-fetch'],
|
|
254
|
-
metadataURI: 'ipfs://...',
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// Verify another agent's identity before task delegation
|
|
258
|
-
const isValid = await identity.validate('0xAgentAddress');
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
### 6. Mutual Stake Escrow
|
|
262
|
-
|
|
263
|
-
Reciprocal collateral for agent-to-agent tasks. Both parties stake before work begins; funds release on verified completion.
|
|
264
|
-
|
|
265
|
-
```typescript
|
|
266
|
-
import { MutualStakeEscrow } from 'agentwallet-sdk';
|
|
267
|
-
|
|
268
|
-
const escrow = new MutualStakeEscrow({ chain: 'base', walletClient });
|
|
269
|
-
|
|
270
|
-
const { escrowId } = await escrow.create({
|
|
271
|
-
counterparty: '0x...',
|
|
272
|
-
token: '0xUSDC',
|
|
273
|
-
stakeAmount: 100_000_000n, // 100 USDC (6 decimals)
|
|
274
|
-
taskHash: '0x...',
|
|
275
|
-
deadline: Math.floor(Date.now() / 1000) + 86400,
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
// Release on verified completion
|
|
279
|
-
await escrow.release(escrowId, proofOfWork);
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### 7. Optimistic Escrow
|
|
283
|
-
|
|
284
|
-
Time-locked escrow with challenge window. Funds release automatically after the lock period unless disputed.
|
|
285
|
-
|
|
286
|
-
```typescript
|
|
287
|
-
import { OptimisticEscrow } from 'agentwallet-sdk';
|
|
288
|
-
|
|
289
|
-
const escrow = new OptimisticEscrow({ chain: 'base', walletClient });
|
|
290
|
-
|
|
291
|
-
const { escrowId } = await escrow.create({
|
|
292
|
-
beneficiary: '0x...',
|
|
293
|
-
token: '0xUSDC',
|
|
294
|
-
amount: 50_000_000n,
|
|
295
|
-
lockPeriod: 3600, // 1-hour challenge window
|
|
296
|
-
taskHash: '0x...',
|
|
297
|
-
});
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
### 8. AP2 Protocol — Agent-to-Agent Task Delegation
|
|
301
|
-
|
|
302
|
-
Delegate tasks to sub-agents with automatic payment on completion.
|
|
303
|
-
|
|
304
|
-
```typescript
|
|
305
|
-
import { AP2Client } from 'agentwallet-sdk';
|
|
306
|
-
|
|
307
|
-
const ap2 = new AP2Client({ chain: 'base', walletClient });
|
|
308
|
-
|
|
309
|
-
const { taskId } = await ap2.delegate({
|
|
310
|
-
agent: '0xSubAgentAddress',
|
|
311
|
-
task: { type: 'data-fetch', params: { url: 'https://...' } },
|
|
312
|
-
maxPayment: 5_000_000n, // 5 USDC ceiling
|
|
313
|
-
escrowType: 'mutual-stake',
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
const result = await ap2.awaitCompletion(taskId);
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
### 9. Gas Sponsorship (ERC-4337 Paymaster)
|
|
320
|
-
|
|
321
|
-
Sponsor gas for agent transactions so end users never hold ETH.
|
|
322
|
-
|
|
323
|
-
```typescript
|
|
324
|
-
import { createWallet } from 'agentwallet-sdk';
|
|
325
|
-
|
|
326
|
-
const wallet = createWallet({
|
|
327
|
-
accountAddress: '0x...',
|
|
328
|
-
chain: 'base',
|
|
329
|
-
walletClient,
|
|
330
|
-
gasSponsorship: {
|
|
331
|
-
enabled: true,
|
|
332
|
-
paymasterUrl: 'https://...', // ERC-4337 paymaster endpoint
|
|
333
|
-
},
|
|
334
|
-
});
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
### 10. Fiat Onramp
|
|
338
|
-
|
|
339
|
-
Opt-in fiat-to-crypto conversion for wallets that need funding without manual crypto transfers.
|
|
340
|
-
|
|
341
|
-
```typescript
|
|
342
|
-
import { FiatOnramp } from 'agentwallet-sdk';
|
|
343
|
-
|
|
344
|
-
const onramp = new FiatOnramp({ chain: 'base', walletClient });
|
|
345
|
-
|
|
346
|
-
const { sessionUrl } = await onramp.createSession({
|
|
347
|
-
targetToken: 'USDC',
|
|
348
|
-
targetAmount: 100, // USD
|
|
349
|
-
walletAddress: wallet.address,
|
|
350
|
-
});
|
|
351
|
-
// Redirect agent operator to sessionUrl for KYC/payment
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
### 11. On-Chain Settlement
|
|
355
|
-
|
|
356
|
-
Finalize multi-party payment flows with cryptographic settlement proof.
|
|
357
|
-
|
|
358
|
-
```typescript
|
|
359
|
-
import { Settlement } from 'agentwallet-sdk';
|
|
360
|
-
|
|
361
|
-
const settlement = new Settlement({ chain: 'base', walletClient });
|
|
362
|
-
|
|
363
|
-
await settlement.finalize({
|
|
364
|
-
taskId: '0x...',
|
|
365
|
-
parties: ['0xAgent1', '0xAgent2'],
|
|
366
|
-
amounts: [80_000_000n, 20_000_000n],
|
|
367
|
-
proofHash: '0x...',
|
|
368
|
-
});
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
## ClawPowers Enhancement
|
|
372
|
-
|
|
373
|
-
When `~/.clawpowers/` runtime is initialized, agent-payments gains persistent tracking across all transaction types.
|
|
374
|
-
|
|
375
|
-
**Persistent Payment Ledger:**
|
|
376
|
-
|
|
377
|
-
```bash
|
|
378
|
-
bash runtime/persistence/store.sh set "ledger:total_spent_today" "$(date +%Y-%m-%d):0.047"
|
|
379
|
-
bash runtime/persistence/store.sh list "payment:*:amount" | awk -F: '{sum += $NF} END {print "Total: $" sum}'
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
**Multi-Metric Session Tracking:**
|
|
383
|
-
|
|
384
|
-
```bash
|
|
385
|
-
bash runtime/metrics/collector.sh record \
|
|
386
|
-
--skill agent-payments \
|
|
387
|
-
--outcome success \
|
|
388
|
-
--notes "payments: 3, swaps: 1, bridges: 0, session_spend: $0.047, limit: $5.00"
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
**Spending Analytics:**
|
|
392
|
-
|
|
393
|
-
`runtime/feedback/analyze.sh` computes:
|
|
394
|
-
- Total spend per day/week/month across all transaction types
|
|
395
|
-
- Most expensive APIs (payment frequency × amount)
|
|
396
|
-
- Swap slippage vs. configured tolerance
|
|
397
|
-
- Bridge utilization and latency
|
|
398
|
-
- Escrow open/close ratio
|
|
399
|
-
- Limit hit rate (how often limits block payments)
|
|
400
|
-
- Payment success rate (failed on-chain transactions)
|
|
401
|
-
|
|
402
|
-
## Security
|
|
403
|
-
|
|
404
|
-
**Private Key Security:**
|
|
405
|
-
- Keys are encrypted at rest via the ERC-6551 NFT-bound wallet
|
|
406
|
-
- Never printed to logs or surfaces
|
|
407
|
-
- Passphrase required to decrypt
|
|
408
|
-
|
|
409
|
-
**Spending Limit Enforcement:**
|
|
410
|
-
- `setSpendPolicy()` writes limits to the smart contract — the agent cannot override them
|
|
411
|
-
- `agentExecute()` queries the contract before submitting any transaction
|
|
412
|
-
- Over-limit transactions are queued, not silently dropped
|
|
413
|
-
|
|
414
|
-
**Audit Trail:**
|
|
415
|
-
- Every transaction generates an on-chain hash
|
|
416
|
-
- Payment logs in `~/.clawpowers/state/` are append-only
|
|
417
|
-
- Session spend is tracked against daily/session limits
|
|
418
|
-
|
|
419
|
-
## Anti-Patterns
|
|
420
|
-
|
|
421
|
-
| Anti-Pattern | Why It Fails | Correct Approach |
|
|
422
|
-
|-------------|-------------|-----------------|
|
|
423
|
-
| No spending limits configured | Unlimited liability, potential wallet drain | Always call `setSpendPolicy()` before `agentExecute()` |
|
|
424
|
-
| Hardcoding token addresses | Chain upgrades break integrations | Use `BASE_TOKENS`, `ARBITRUM_TOKENS`, etc. from the SDK |
|
|
425
|
-
| Skipping identity validation before AP2 delegation | Funds sent to unverified agent | Call `identity.validate()` before delegating tasks |
|
|
426
|
-
| Using optimistic escrow for high-value tasks | Challenge window may be too short | Use mutual stake escrow for tasks above risk threshold |
|
|
427
|
-
| Retrying failed payments without human review | Double-charge or infinite payment loop | Manual review required for any payment failure |
|
|
428
|
-
| Paying without verifying server response | Payment sent, service not rendered | Always check response status after x402 payment |
|
|
429
|
-
| Not logging swap/bridge transactions | No audit trail for reconciliation | Log every transaction hash via runtime persistence |
|
|
430
|
-
| Swapping with default slippage on volatile pairs | Front-run or excessive slippage | Set explicit `slippageBps` based on pair volatility |
|
|
431
|
-
|
|
432
|
-
## Protocol Fees (ClawPowers Only)
|
|
433
|
-
|
|
434
|
-
**These fees apply ONLY when using agent-payments through ClawPowers.** The standalone [agentwallet-sdk](https://www.npmjs.com/package/agentwallet-sdk) on npm is free with zero fees. You always have the choice to use the SDK directly.
|
|
435
|
-
|
|
436
|
-
ClawPowers agent-payments provides auto-configured wallets, guided payment flows, spending analytics, and runtime tracking. A transparent protocol fee applies:
|
|
437
|
-
|
|
438
|
-
| Monthly Volume | Fee |
|
|
439
|
-
|---------------|-----|
|
|
440
|
-
| $0 - $1,000 | 0.77% |
|
|
441
|
-
| $1,001 - $10,000 | 0.50% |
|
|
442
|
-
| $10,001 - $100,000 | 0.25% |
|
|
443
|
-
| $100,000+ | Custom |
|
|
444
|
-
|
|
445
|
-
Fees are:
|
|
446
|
-
- Applied at the protocol level (smart contract), not application level
|
|
447
|
-
- Visible in every transaction before confirmation
|
|
448
|
-
- Competitive with alternatives (MetaMask 0.875%, Stripe 2.9%, Nory 1%)
|
|
449
|
-
- Zero if you don't use agent-payments — the rest of ClawPowers is completely free
|
|
450
|
-
|
|
451
|
-
Fee collector: `0xff86829393C6C26A4EC122bE0Cc3E466Ef876AdD` (all EVM chains)
|
|
452
|
-
|
|
453
|
-
## References
|
|
454
|
-
|
|
455
|
-
- [agentwallet-sdk on npm](https://www.npmjs.com/package/agentwallet-sdk)
|
|
456
|
-
- [agentpay-mcp on GitHub](https://github.com/up2itnow0822/agentpay-mcp)
|
|
457
|
-
- [x402 protocol specification](https://x402.org)
|
|
458
|
-
- [ERC-6551 Token Bound Accounts](https://eips.ethereum.org/EIPS/eip-6551)
|
|
459
|
-
- [ERC-4337 Account Abstraction](https://eips.ethereum.org/EIPS/eip-4337)
|
|
460
|
-
- [CCTP V2 Documentation](https://developers.circle.com/stablecoins/cctp-getting-started)
|
|
461
|
-
- [NVIDIA NeMo Agent Toolkit integration](https://github.com/NVIDIA/NeMo-Agent-Toolkit-Examples/pull/17)
|
|
462
|
-
|
|
463
|
-
## Underlying Infrastructure
|
|
464
|
-
|
|
465
|
-
This skill is powered by [agentwallet-sdk v6.0](https://www.npmjs.com/package/agentwallet-sdk) — full multi-chain agent wallet stack:
|
|
466
|
-
|
|
467
|
-
- **ERC-6551 Non-custodial wallets** — Agent owns its keys via NFT-bound wallet on 11 chains
|
|
468
|
-
- **Smart-contract spending policies** — Per-token, per-period limits enforced at contract level
|
|
469
|
-
- **x402 multi-chain payments** — Auto network detection across Base, Arbitrum, Optimism, and more
|
|
470
|
-
- **Uniswap V3 swaps** — Base, Arbitrum, Optimism, Polygon with chain-specific token registries
|
|
471
|
-
- **CCTP V2 bridge** — EVM↔EVM and EVM↔Solana USDC bridging
|
|
472
|
-
- **ERC-8004 Agent Identity** — Identity, Reputation, and Validation registries
|
|
473
|
-
- **Mutual Stake & Optimistic Escrow** — Reciprocal and time-locked collateral for agent tasks
|
|
474
|
-
- **AP2 Protocol** — Agent-to-agent task delegation and payment
|
|
475
|
-
- **ERC-4337 Gas Sponsorship** — Paymaster integration for gasless transactions
|
|
476
|
-
- **Fiat Onramp** — Opt-in fiat-to-crypto conversion
|
|
477
|
-
- **On-chain Settlement** — Cryptographic finalization of multi-party payment flows
|
|
478
|
-
|
|
479
|
-
Integrated into [NVIDIA's official NeMo Agent Toolkit](https://github.com/NVIDIA/NeMo-Agent-Toolkit-Examples/pull/17).
|