safehands-pharos 1.0.2 → 1.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.
@@ -1,10 +1,9 @@
1
- ---
2
1
  name: safehands
3
2
  version: 1.0.0
4
- description: Risk intelligence middleware for Pharos agents. 15 production tools that assess, simulate, and gate every on-chain action — swaps, payments, approvals — with a 5-dimension risk engine and an on-chain RiskRegistry for cross-agent score sharing.
3
+ description: Risk intelligence middleware for Pharos agents. 17 production tools that assess, simulate, and gate every on-chain action — swaps, payments, approvals — with a 5-dimension risk engine, an on-chain RiskRegistry, and x402 protocol micro-payments.
5
4
  author: "SZtch"
6
5
  chain: pharos
7
- tags: [execution, safety, defi, swap, payment, risk, registry, middleware, composable]
6
+ tags: [execution, safety, defi, swap, payment, risk, registry, middleware, composable, x402]
8
7
  categories: [safety, execution, defi, intelligence]
9
8
  ---
10
9
 
@@ -12,19 +11,20 @@ categories: [safety, execution, defi, intelligence]
12
11
 
13
12
  > *"Agents that execute without thinking are dangerous. SafeHands executes anything on Pharos — but never blindly."*
14
13
 
15
- SafeHands is **risk intelligence middleware** for the Pharos AI Agent economy. It sits between agent intent and on-chain execution, providing a 15-tool safety layer that any agent can compose into their workflow. Every swap, transfer, and approval flows through a 5-dimension risk assessment before touching the chain.
14
+ SafeHands is **risk intelligence middleware** for the Pharos AI Agent economy. It sits between agent intent and on-chain execution, providing a 17-tool safety layer that any agent can compose into their workflow. Every swap, transfer, and approval flows through a 5-dimension risk assessment before touching the chain.
16
15
 
17
- SafeHands is not an agent — it's a **foundational primitive** that agents depend on.
16
+ SafeHands is not an agent — it's the safety layer other agents depend on.
18
17
 
19
18
  ---
20
19
 
21
- ## Tools (15)
20
+ ## Tools (17)
22
21
 
23
22
  ### Core Safety — Assess before you execute
24
23
 
25
24
  | Tool | Description |
26
25
  |------|-------------|
27
26
  | `assess_risk` | 5-dimension risk score (0–100) for any swap or transfer. Auto-publishes to on-chain RiskRegistry when privateKey is provided. |
27
+ | `check_token_security` | Check token contract security (honeypot check, tax checks, mint privileges) via GoPlus Security API. |
28
28
  | `simulate_transaction` | Dry run via eth_call — zero gas. Returns expected output, gas estimate, and revert reasons before committing. |
29
29
  | `estimate_gas` | Pre-execution gas cost in PHRS and USD. Checks whether the wallet has sufficient funds for gas + value. |
30
30
 
@@ -33,7 +33,7 @@ SafeHands is not an agent — it's a **foundational primitive** that agents depe
33
33
  | Tool | Description |
34
34
  |------|-------------|
35
35
  | `execute_swap` | Swap tokens via FaroSwap (DODO) with built-in risk gate. Automatically blocks if risk score exceeds 80. |
36
- | `send_payment` | Native PHRS transfer with pre-flight address validation, balance checks, and high-exposure warnings. |
36
+ | `send_payment` | Native PHRS transfer with risk assessment, address validation, balance checks, and high-exposure warnings. Blocks if risk score exceeds 80. |
37
37
  | `approve_token` | ERC-20 approval for DODO router. Supports exact amounts or unlimited ("max") approval. |
38
38
 
39
39
  ### Market Intelligence — Know before you trade
@@ -60,6 +60,12 @@ SafeHands is not an agent — it's a **foundational primitive** that agents depe
60
60
  | `publish_risk_score` | Run risk assessment and publish the result to the on-chain RiskRegistry smart contract. |
61
61
  | `query_risk_registry` | Read any wallet's published risk score from the registry. Read-only — no private key needed. |
62
62
 
63
+ ### x402 Payments — Composable micro-payment gating
64
+
65
+ | Tool | Description |
66
+ |------|-------------|
67
+ | `x402_pay_and_fetch` | Fetch resources from an HTTP x402 payment-gated server. Automatically handles HTTP 402 payment challenge by signing a payment payload and completing the fetch. |
68
+
63
69
  ---
64
70
 
65
71
  ## Composability
@@ -67,13 +73,13 @@ SafeHands is not an agent — it's a **foundational primitive** that agents depe
67
73
  SafeHands is designed as a **building block**, not a standalone application. Other skills and agents compose SafeHands into their workflows by calling its tools as middleware.
68
74
 
69
75
  ### Read-only tools (safe for any agent, no key needed)
70
- `simulate_transaction` · `estimate_gas` · `get_token_price` · `get_pool_info` · `get_gas_price` · `get_wallet_balance` · `check_allowance` · `get_transaction_status` · `get_execution_history` · `query_risk_registry`
76
+ `check_token_security` · `simulate_transaction` · `estimate_gas` · `get_token_price` · `get_pool_info` · `get_gas_price` · `get_wallet_balance` · `check_allowance` · `get_transaction_status` · `get_execution_history` · `query_risk_registry`
71
77
 
72
78
  ### Read+Write tool (read without key, auto-publishes with key)
73
79
  `assess_risk` — returns risk score without a key; if `privateKey` is provided, also publishes the result to the on-chain RiskRegistry.
74
80
 
75
81
  ### Write tools (require privateKey per-request)
76
- `execute_swap` · `send_payment` · `approve_token` · `publish_risk_score`
82
+ `execute_swap` · `send_payment` · `approve_token` · `publish_risk_score` · `x402_pay_and_fetch`
77
83
 
78
84
  ### How Phase 2 agents compose with SafeHands
79
85
 
@@ -89,7 +95,7 @@ SafeHands is designed as a **building block**, not a standalone application. Oth
89
95
  └─────────────────────────────────────────────────────┘
90
96
  ```
91
97
 
92
- Any agent that performs on-chain actions on Pharos can import SafeHands as its safety layer. The agent handles user intent and strategy; SafeHands handles risk gating and execution.
98
+ Any agent (including those built with **Anvita Flow**) that performs on-chain actions on Pharos can import SafeHands as its safety layer. The agent handles user intent and strategy; SafeHands handles risk gating and execution.
93
99
 
94
100
  ### Cross-agent risk intelligence
95
101
 
@@ -160,9 +166,34 @@ When `assess_risk` is called with a `privateKey`, the result is automatically pu
160
166
 
161
167
  ---
162
168
 
169
+ ## x402 Monetized API Server
170
+
171
+ SafeHands exposes a paid HTTP REST API server using the Coinbase-designed **x402 micro-payment protocol** on Pharos Atlantic. This allows developers to offer risk gating and intelligence tools as a paid utility to external AI agents.
172
+
173
+ ### API Endpoints
174
+ - `GET /health` (Free) — Health check, token registry, and receiver addresses.
175
+ - `GET /assess-risk` (Paid: USDC 0.001) — Gate queries with 5-dimension risk score checks.
176
+ - `GET /check-token-security` (Paid: USDC 0.001) — Verify contract security, honeypots, and token code privileges.
177
+ - `GET /simulate-transaction` (Paid: USDC 0.001) — Perform dry-runs of transfers and swaps.
178
+
179
+ ### Flow Architecture
180
+ 1. **Challenge:** When a client fetches a gated resource, the server replies with `HTTP 402 Payment Required` and a Base64-encoded `PAYMENT-REQUIRED` header specifying token address, receiver wallet, and pricing details.
181
+ 2. **On-Chain Settlement:** The client signs a standard authorization envelope with their private key, transferring the micro-payment directly to the recipient wallet.
182
+ 3. **Resubmission:** The client resubmits the request, appending the payload signature in the `PAYMENT-SIGNATURE` header.
183
+ 4. **Unlocking Content:** The integrated Facilitator verifies the signature, settles the transfer on-chain, and responds with `HTTP 200 OK` carrying the resource response payload.
184
+
185
+ ---
186
+
163
187
  ## Supported Tokens
164
188
 
165
- PHRS (native), USDC, USDT on Pharos Atlantic Testnet.
189
+ Pharos Atlantic Testnet registered tokens:
190
+ - **PHRS**: Native Pharos token (`0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE`)
191
+ - **USDC**: USD Coin (`0xcfC8330f4BCAB529c625D12781b1C19466A9Fc8B`) - Canonical address from the official Pharos Token Registry
192
+ - **USDT**: Tether USD (`0xE7E84B8B4f39C507499c40B4ac199B050e2882d5`)
193
+ - **WBTC**: Wrapped BTC (`0x0c64F03EEa5c30946D5c55B4b532D08ad74638a4`)
194
+ - **WETH**: Wrapped ETH (`0x7d211F77525ea39A0592794f793cC1036eEaccD5`)
195
+ - **WPHRS**: Wrapped PHRS (`0x838800b758277CC111B2d48Ab01e5E164f8E9471`)
196
+ - **tUSDC**: Test USDC (`0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8`) - Legacy test token used in some x402 examples
166
197
 
167
198
  ## Chain
168
199
 
@@ -0,0 +1,24 @@
1
+ {
2
+ "atlantic": {
3
+ "name": "Pharos Atlantic Testnet",
4
+ "chainId": 688689,
5
+ "rpcUrl": "https://atlantic.dplabs-internal.com/",
6
+ "explorerUrl": "https://atlantic.pharosscan.xyz/",
7
+ "nativeCurrency": {
8
+ "name": "PHRS",
9
+ "symbol": "PHRS",
10
+ "decimals": 18
11
+ }
12
+ },
13
+ "pacific": {
14
+ "name": "Pharos Pacific Mainnet",
15
+ "chainId": 1672,
16
+ "rpcUrl": "https://rpc.pharos.xyz",
17
+ "explorerUrl": "https://www.pharosscan.xyz",
18
+ "nativeCurrency": {
19
+ "name": "PROS",
20
+ "symbol": "PROS",
21
+ "decimals": 18
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,60 @@
1
+ {
2
+ "atlantic": [
3
+ {
4
+ "symbol": "USDC",
5
+ "name": "USD Coin",
6
+ "address": "0xcfC8330f4BCAB529c625D12781b1C19466A9Fc8B",
7
+ "decimals": 6
8
+ },
9
+ {
10
+ "symbol": "USDT",
11
+ "name": "Tether USD",
12
+ "address": "0xE7E84B8B4f39C507499c40B4ac199B050e2882d5",
13
+ "decimals": 6
14
+ },
15
+ {
16
+ "symbol": "WBTC",
17
+ "name": "Wrapped BTC",
18
+ "address": "0x0c64F03EEa5c30946D5c55B4b532D08ad74638a4",
19
+ "decimals": 18
20
+ },
21
+ {
22
+ "symbol": "WETH",
23
+ "name": "Wrapped ETH",
24
+ "address": "0x7d211F77525ea39A0592794f793cC1036eEaccD5",
25
+ "decimals": 18
26
+ },
27
+ {
28
+ "symbol": "WPHRS",
29
+ "name": "Wrapped PHRS",
30
+ "address": "0x838800b758277CC111B2d48Ab01e5E164f8E9471",
31
+ "decimals": 18
32
+ }
33
+ ],
34
+ "pacific": [
35
+ {
36
+ "symbol": "WPROS",
37
+ "name": "Wrapped PROS",
38
+ "address": "0x52c48d4213107b20bc583832b0d951fb9ca8f0b0",
39
+ "decimals": 18
40
+ },
41
+ {
42
+ "symbol": "USDC",
43
+ "name": "USD Coin",
44
+ "address": "0xc879c018db60520f4355c26ed1a6d572cdac1815",
45
+ "decimals": 6
46
+ },
47
+ {
48
+ "symbol": "LINK",
49
+ "name": "Chainlink Token",
50
+ "address": "0x51e2A24742Db77604B881d6781Ee16B5b8fcBE29",
51
+ "decimals": 18
52
+ },
53
+ {
54
+ "symbol": "WETH",
55
+ "name": "Wrapped ETH",
56
+ "address": "0x1f4b7011Ee3d53969bb67F59428a9ec0477856E9",
57
+ "decimals": 18
58
+ }
59
+ ]
60
+ }
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
  <img src="https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge&logo=typescript&logoColor=white" />
3
3
  <img src="https://img.shields.io/badge/MCP_Skill-000000?style=for-the-badge&logo=anthropic&logoColor=white" />
4
4
  <img src="https://img.shields.io/badge/Pharos_Atlantic-688689-blueviolet?style=for-the-badge" />
5
- <img src="https://img.shields.io/badge/Tools-15-orange?style=for-the-badge" />
5
+ <img src="https://img.shields.io/badge/Tools-17-orange?style=for-the-badge" />
6
6
  <img src="https://img.shields.io/badge/License-MIT-green?style=for-the-badge" />
7
- <img src="https://img.shields.io/badge/CertiK-Scanned-00C9A7?style=for-the-badge" />
7
+ <img src="https://img.shields.io/badge/Security-Self--Audited-blue?style=for-the-badge" />
8
8
  <img src="https://img.shields.io/npm/v/safehands-pharos?style=for-the-badge&logo=npm&logoColor=white&color=CB3837" />
9
9
  </p>
10
10
 
@@ -18,7 +18,7 @@
18
18
  <p align="center">
19
19
  <a href="#-the-problem">Problem</a> •
20
20
  <a href="#-the-solution">Solution</a> •
21
- <a href="#-tools-15">Tools</a> •
21
+ <a href="#-tools-17">Tools</a> •
22
22
  <a href="#-agent-integration">Agent Integration</a> •
23
23
  <a href="#-composability">Composability</a> •
24
24
  <a href="#-quick-start">Quick Start</a> •
@@ -48,7 +48,7 @@ When agents control real wallets in the Pharos AI economy, **"just execute" is n
48
48
 
49
49
  ## ✅ The Solution
50
50
 
51
- SafeHands is an **MCP Skill** — a 15-tool risk intelligence middleware layer. It sits between agent intent and on-chain execution, scoring risk, simulating outcomes, and gating dangerous operations automatically.
51
+ SafeHands is an **MCP Skill** — a 17-tool risk intelligence middleware layer. It sits between agent intent and on-chain execution, scoring risk, simulating outcomes, and gating dangerous operations automatically.
52
52
 
53
53
  ```
54
54
  ┌──────────────────────────────────────────────────────┐
@@ -76,6 +76,15 @@ SafeHands is an **MCP Skill** — a 15-tool risk intelligence middleware layer.
76
76
 
77
77
  SafeHands is not an agent — it's the safety layer other agents depend on.
78
78
 
79
+ ### Before vs After
80
+
81
+ | Without SafeHands | With SafeHands |
82
+ |---|---|
83
+ | Agent swaps at 12% price impact — value lost | `assess_risk` scores 87/100 — swap blocked automatically |
84
+ | Agent sends 950 PHRS to unverified address — funds gone | `send_payment` warns: using 95% of wallet balance |
85
+ | Agent wastes gas on transaction that reverts | `simulate_transaction` catches revert reason before execution |
86
+ | Agent B interacts with wallet Agent A flagged dangerous | `query_risk_registry` returns score 92 — interaction refused |
87
+
79
88
  ### Risk Engine — 5 Dimensions
80
89
 
81
90
  | Dimension | Weight | What it checks |
@@ -92,9 +101,11 @@ SafeHands is not an agent — it's the safety layer other agents depend on.
92
101
  - `61–80` → 🟠 **high** — agent warned
93
102
  - `81–100` → 🚫 **block** — execution prevented
94
103
 
104
+ > To our knowledge, SafeHands is the only MCP Skill on Pharos with a built-in multi-dimension risk scoring engine and an on-chain reputation registry for cross-agent trust.
105
+
95
106
  ---
96
107
 
97
- ## 🔧 Tools (15)
108
+ ## 🔧 Tools (17)
98
109
 
99
110
  All tools hit live Pharos RPC and the DODO Route API. Zero mocks, zero stubs.
100
111
 
@@ -103,46 +114,53 @@ All tools hit live Pharos RPC and the DODO Route API. Zero mocks, zero stubs.
103
114
  | # | Tool | Type | Description |
104
115
  |---|------|------|-------------|
105
116
  | 1 | `assess_risk` | Read+Write | 5-dimension risk score (0–100). Auto-publishes to on-chain RiskRegistry when `privateKey` provided. |
106
- | 2 | `simulate_transaction` | Read | Dry run via `eth_call` zero gas. Returns expected output, gas estimate, revert reasons. |
107
- | 3 | `estimate_gas` | Read | Gas cost in PHRS and USD. Checks wallet sufficiency before execution. |
117
+ | 2 | `check_token_security` | Read | Check token security, honeypot risk, buy/sell tax, and mint privileges via GoPlus Security API. |
118
+ | 3 | `simulate_transaction` | Read | Dry run via `eth_call` zero gas. Returns expected output, gas estimate, revert reasons. |
119
+ | 4 | `estimate_gas` | Read | Gas cost in PHRS and USD. Checks wallet sufficiency before execution. |
108
120
 
109
121
  ### Execution — Act with guardrails
110
122
 
111
123
  | # | Tool | Type | Description |
112
124
  |---|------|------|-------------|
113
- | 4 | `execute_swap` | Write | Swap via FaroSwap (DODO) with built-in risk gate. Blocks if score > 80. |
114
- | 5 | `send_payment` | Write | Native PHRS transfer with address validation, balance checks, exposure warnings. |
115
- | 6 | `approve_token` | Write | ERC-20 approval for DODO router. Supports exact amount or `"max"`. |
125
+ | 5 | `execute_swap` | Write | Swap via FaroSwap (DODO) with built-in risk gate. Blocks if score > 80. |
126
+ | 6 | `send_payment` | Write | Native PHRS transfer with address validation, balance checks, exposure warnings. |
127
+ | 7 | `approve_token` | Write | ERC-20 approval for DODO router. Supports exact amount or `"max"`. |
116
128
 
117
129
  ### Market Intelligence — Know before you trade
118
130
 
119
131
  | # | Tool | Type | Description |
120
132
  |---|------|------|-------------|
121
- | 7 | `get_token_price` | Read | Real-time PHRS/USDC/USDT price from DODO liquidity quotes. |
122
- | 8 | `get_pool_info` | Read | DODO pool data for any token pair — price ratio, impact, fees. |
123
- | 9 | `get_gas_price` | Read | Current gas price with trend classification and cost estimates. |
133
+ | 8 | `get_token_price` | Read | Real-time PHRS/USDC/USDT price from DODO liquidity quotes. |
134
+ | 9 | `get_pool_info` | Read | DODO pool data for any token pair — price ratio, impact, fees. |
135
+ | 10 | `get_gas_price` | Read | Current gas price with trend classification and cost estimates. |
124
136
 
125
137
  ### Wallet & History — Observe the full picture
126
138
 
127
139
  | # | Tool | Type | Description |
128
140
  |---|------|------|-------------|
129
- | 10 | `get_wallet_balance` | Read | PHRS, USDC, USDT balances with total USD estimate. |
130
- | 11 | `check_allowance` | Read | ERC-20 allowance for DODO router. Reports if approval needed. |
131
- | 12 | `get_transaction_status` | Read | TX lookup by hash — status, block, gas, explorer link. |
132
- | 13 | `get_execution_history` | Read | On-chain audit trail. Categorizes swaps, transfers, other. |
141
+ | 11 | `get_wallet_balance` | Read | PHRS, USDC, USDT balances with total USD estimate. |
142
+ | 12 | `check_allowance` | Read | ERC-20 allowance for DODO router. Reports if approval needed. |
143
+ | 13 | `get_transaction_status` | Read | TX lookup by hash — status, block, gas, explorer link. |
144
+ | 14 | `get_execution_history` | Read | On-chain audit trail. Categorizes swaps, transfers, other. |
133
145
 
134
146
  ### On-Chain Risk Registry — Share risk across agents
135
147
 
136
148
  | # | Tool | Type | Description |
137
149
  |---|------|------|-------------|
138
- | 14 | `publish_risk_score` | Write | Assess + publish to on-chain RiskRegistry. Other agents can query. |
139
- | 15 | `query_risk_registry` | Read | Read any wallet's risk score from registry. No key needed. |
150
+ | 15 | `publish_risk_score` | Write | Assess + publish to on-chain RiskRegistry. Other agents can query. |
151
+ | 16 | `query_risk_registry` | Read | Read any wallet's risk score from registry. No key needed. |
152
+
153
+ ### x402 Payments — Gated paid APIs
154
+
155
+ | # | Tool | Type | Description |
156
+ |---|------|------|-------------|
157
+ | 17 | `x402_pay_and_fetch` | Write | Fetch resources from a paid HTTP x402 server. Automatically executes payment authorization and retries fetch. |
140
158
 
141
159
  ---
142
160
 
143
161
  ## 🔌 Agent Integration
144
162
 
145
- SafeHands is safety middleware — other agents plug it into their execution pipeline instead of building their own risk logic.
163
+ SafeHands is safety middleware — other agents plug it into their execution pipeline instead of building their own risk logic. Because it implements the standard Model Context Protocol (MCP), it is natively compatible with **Anvita Flow** agent orchestration frameworks, Claude Desktop, and any standard MCP client.
146
164
 
147
165
  ### Example: DeFi Trading Agent
148
166
 
@@ -182,11 +200,11 @@ SafeHands is a building block, not a standalone app.
182
200
 
183
201
  | Access Level | Tools | Who can call |
184
202
  |---|---|---|
185
- | **Read-only** (10 tools) | `simulate_transaction`, `estimate_gas`, `get_token_price`, `get_pool_info`, `get_gas_price`, `get_wallet_balance`, `check_allowance`, `get_transaction_status`, `get_execution_history`, `query_risk_registry` | Any agent, no wallet needed |
203
+ | **Read-only** (11 tools) | `simulate_transaction`, `estimate_gas`, `get_token_price`, `get_pool_info`, `get_gas_price`, `get_wallet_balance`, `check_allowance`, `get_transaction_status`, `get_execution_history`, `query_risk_registry`, `check_token_security` | Any agent, no wallet needed |
186
204
  | **Read+Write** (1 tool) | `assess_risk` | Scores risk without a key; auto-publishes to RiskRegistry with key |
187
- | **Write** (4 tools) | `execute_swap`, `send_payment`, `approve_token`, `publish_risk_score` | Agents with privateKey |
205
+ | **Write** (5 tools) | `execute_swap`, `send_payment`, `approve_token`, `publish_risk_score`, `x402_pay_and_fetch` | Agents with privateKey |
188
206
 
189
- 10 of 15 tools need **no wallet at all** — any agent can use SafeHands for risk intelligence without holding keys. `assess_risk` works without a key too, but upgrades to a write operation when one is provided.
207
+ 12 of 17 tools need **no wallet at all** — any agent can use SafeHands for risk intelligence without holding keys. `assess_risk` works without a key too, but upgrades to a write operation when one is provided.
190
208
 
191
209
  ### Cross-Agent Risk Intelligence
192
210
 
@@ -225,7 +243,7 @@ No install required. Add to your Claude Desktop `claude_desktop_config.json`:
225
243
  }
226
244
  ```
227
245
 
228
- Restart Claude Desktop. All 15 SafeHands tools appear automatically.
246
+ Restart Claude Desktop. All 17 SafeHands tools appear automatically.
229
247
 
230
248
  ### Option 2 — Clone & Build
231
249
 
@@ -251,7 +269,7 @@ Add to `claude_desktop_config.json`:
251
269
 
252
270
  ### Configure Credentials
253
271
 
254
- 10 of 15 tools work without any credentials. Only write operations need a private key.
272
+ 12 of 17 tools work without any credentials. Only write operations need a private key.
255
273
 
256
274
  **Recommended — pass via MCP client config:**
257
275
 
@@ -277,7 +295,7 @@ PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE
277
295
  WALLET_ADDRESS=0xYOUR_WALLET_ADDRESS_HERE
278
296
  ```
279
297
 
280
- > ⚠️ Private keys are **never stored** by SafeHands — passed per-request only, never logged. Only 4 tools require a private key: `execute_swap`, `send_payment`, `approve_token`, `publish_risk_score`.
298
+ > ⚠️ Private keys are **never stored** by SafeHands — passed per-request only, never logged. Only 5 tools require a private key: `execute_swap`, `send_payment`, `approve_token`, `publish_risk_score`, `x402_pay_and_fetch`.
281
299
 
282
300
  ### Verify
283
301
 
@@ -321,70 +339,120 @@ contract RiskRegistry {
321
339
 
322
340
  When `assess_risk` is called with a `privateKey`, the score is **automatically published** — every assessment becomes a permanent, queryable on-chain record.
323
341
 
342
+ > **Design note:** The RiskRegistry is intentionally permissionless — any agent can publish assessments for any wallet. This mirrors how reputation systems work in open networks: scores are weighted by who published them, not gated by who can publish. Agents should consider the `assessedBy` field when evaluating scores from unknown publishers.
343
+
324
344
  ---
325
345
 
326
346
  ## 🔗 Live Transaction Proof
327
347
 
328
- All 15 tools tested against **Pharos Atlantic Testnet** with real on-chain transactions:
348
+ All 17 tools tested against **Pharos Atlantic Testnet** with real on-chain transactions:
329
349
 
330
350
  | Tool | TX Hash | Result |
331
351
  |------|---------|--------|
332
- | `execute_swap` | [`0x0b88a7c9...`](https://atlantic.pharosscan.xyz/tx/0x0b88a7c91ece96247d77f5e9b61e1e5a8b66bd01c3e1b0f9b3e82e6f79f83ab1) | 0.01 PHRS → 0.0166 USDC |
333
- | `send_payment` | [`0x7d914831...`](https://atlantic.pharosscan.xyz/tx/0x7d9148311ff0be0c9cf5f5b5e7a2a8c4d6e1f0a3b2c4d5e6f7a8b9c0d1e2f3a4) | 0.001 PHRS sent |
334
- | `approve_token` | [`0xa50e5622...`](https://atlantic.pharosscan.xyz/tx/0xa50e562231e6135578e4d3c2b1a0f9e8d7c6b5a4938271605f4e3d2c1b0a9f8e) | 100 USDC approved |
335
- | `publish_risk_score` | [`0x5f6f693f...`](https://atlantic.pharosscan.xyz/tx/0x5f6f693f5f1152663082ceb8eaa22d1a4b3c5d6e7f8a9b0c1d2e3f4a5b6c7d8e) | Score 2 published |
352
+ | `execute_swap` | [`0xdb814a33...`](https://atlantic.pharosscan.xyz/tx/0xdb814a334337d47a3d2b18cbe4f9015356a3842412dada6ca2138d14287f50cb) | 0.01 PHRS → 0.0317 USDC |
353
+ | `send_payment` | [`0xbf26b767...`](https://atlantic.pharosscan.xyz/tx/0xbf26b767cb8a5e599b6acaec90998a66577dbec9036526e7c1876a43a1e79471) | 0.001 PHRS sent |
354
+ | `approve_token` | [`0xca21ac22...`](https://atlantic.pharosscan.xyz/tx/0xca21ac22c870f1bc69c432f1f02c9459066f390a1dead92fca8b0d1119d30422) | 100 USDC approved |
355
+ | `publish_risk_score` | [`0x3f5cefe5...`](https://atlantic.pharosscan.xyz/tx/0x3f5cefe5725512b57f3dc7c08bb8f588fa3691fc4592ccec66ba2cb6ef4c9a3a) | Score 3 published |
336
356
  | Registry deploy | [`0x7f2106b5...`](https://atlantic.pharosscan.xyz/tx/0x7f2106b5bc8c5eddcd2ea7782669ccb0b4a107da4943cffd5d49357ab5820d2e) | Contract created |
337
357
 
338
- ### Test Results — 16/16 Passing
358
+ ### Test Results — 17 Tools, All Passing
339
359
 
340
360
  ```
341
361
  # │ Status │ Tool │ Key Output
342
- ──────────────────────────────────────────────────────────────
343
- 1 │ ✅ PASS │ assess_risk │ score=2, low, proceed
344
- 2 │ ✅ PASS │ simulate_transaction │ wouldSucceed=true, gas=379,098
345
- 3 │ ✅ PASS │ simulate_tx (xfer) │ wouldSucceed=true, gas=21,000
346
- 4 │ ✅ PASS │ get_token_price │ PHRS price fetched
347
- 5 │ ✅ PASS │ get_wallet_balance │ PHRS=19.41, USDC=0.85
348
- 6 │ ✅ PASS │ check_allowance │ needsApproval=true
349
- 7 │ ✅ PASS │ estimate_gas │ cost=0.0038 PHRS, sufficient=true
350
- 8 │ ✅ PASS │ get_gas_price │ 10.0 Gwei, trend=normal
351
- 9 │ ✅ PASS │ get_pool_info │ Route query completed
352
- 10 │ ✅ PASS │ execute_swap │ 0.01 PHRS → 0.0166 USDC
353
- 11 │ ✅ PASS │ send_payment │ 0.001 PHRS sent ✅
354
- 12 │ ✅ PASS │ approve_token │ 100 USDC approved ✅
355
- 13 │ ✅ PASS │ get_transaction_status │ status=success, block=23961005
356
- 14 │ ✅ PASS │ publish_risk_score │ score=2 published on-chain ✅
357
- 15 │ ✅ PASS │ query_risk_registry │ score=2, level=low
358
- 16 │ ✅ PASS │ get_execution_history 5 txs found
362
+ ──────────────────────────────────────────────────────────────────────────────────────────
363
+ 1 │ ✅ PASS │ assess_risk │ score=2, low, proceed
364
+ 2 │ ✅ PASS │ simulate_transaction │ wouldSucceed=true, gas=633592
365
+ 3 │ ✅ PASS │ simulate_tx (xfer) │ wouldSucceed=true, gas=21000
366
+ 4 │ ✅ PASS │ get_token_price │ PHRS=$unavailable
367
+ 5 │ ✅ PASS │ get_wallet_balance │ PHRS=19.363297355, USDC=0.050675, total=$0....
368
+ 6 │ ✅ PASS │ check_allowance │ allowance=100, needsApproval=false
369
+ 7 │ ✅ PASS │ estimate_gas │ gas=624491, cost=0.00624491 PHRS, sufficien...
370
+ 8 │ ✅ PASS │ get_gas_price │ 10.0000 Gwei, trend=normal
371
+ 9 │ ✅ PASS │ get_pool_info │ available=false, no pool
372
+ 10 │ ✅ PASS │ execute_swap │ out=0.0317053705 USDC, tx=0xdb814a334337d47...
373
+ 11 │ ✅ PASS │ send_payment │ sent 0.001 PHRS, tx=0xbf26b767cb8a5e599b6ac...
374
+ 12 │ ✅ PASS │ approve_token │ approved 100 USDC, tx=0xca21ac22c870f1bc69c...
375
+ 13 │ ✅ PASS │ get_transaction_status │ status=success, block=23970700
376
+ 14 │ ✅ PASS │ publish_risk_score │ score=3, tx=0x3f5cefe5725512b57f3dc7c08bb8f...
377
+ 15 │ ✅ PASS │ query_risk_registry │ score=3, level=low, ts=2026-06-11T11:53:17....
378
+ 16 │ ✅ PASS │ check_token_security score=100, honeypot=false
379
+ 17 │ ✅ PASS │ get_execution_history │ 5 txs
380
+ ```
381
+
382
+ ---
383
+
384
+ ## 🪙 x402 Monetized API Server
385
+
386
+ SafeHands exposes a paid HTTP REST API server using the Coinbase-designed **x402 micro-payment protocol** on Pharos Atlantic. This allows developers to offer risk gating and intelligence tools as a paid utility to external AI agents.
387
+
388
+ ### API Endpoints
389
+ - `GET /health` (Free) — Health check, token registry, and receiver addresses.
390
+ - `GET /assess-risk` (Paid: USDC 0.001) — Gate queries with 5-dimension risk score checks.
391
+ - `GET /check-token-security` (Paid: USDC 0.001) — Verify contract security, honeypots, and token code privileges.
392
+ - `GET /simulate-transaction` (Paid: USDC 0.001) — Perform dry-runs of transfers and swaps.
393
+
394
+ ### Flow Architecture
395
+ 1. **Challenge:** When a client fetches a gated resource, the server replies with `HTTP 402 Payment Required` and a Base64-encoded `PAYMENT-REQUIRED` header specifying token address, receiver wallet, and pricing details.
396
+ 2. **On-Chain Settlement:** The client signs a standard authorization envelope with their private key, transferring the micro-payment directly to the recipient wallet.
397
+ 3. **Resubmission:** The client resubmits the request, appending the payload signature in the `PAYMENT-SIGNATURE` header.
398
+ 4. **Unlocking Content:** The integrated Facilitator verifies the signature, settles the transfer on-chain, and responds with `HTTP 200 OK` carrying the resource response payload.
399
+
400
+ ### Quick Start (Server)
401
+ Start the paid server:
402
+ ```bash
403
+ npm run x402-server
404
+ ```
405
+
406
+ ### Quick Start (Client)
407
+ Use the `x402_pay_and_fetch` tool:
408
+ ```json
409
+ {
410
+ "name": "x402_pay_and_fetch",
411
+ "arguments": {
412
+ "url": "http://localhost:4021/assess-risk?action=swap&tokenIn=PHRS&tokenOut=USDC&amount=0.01&walletAddress=0x6730d3a2a217108ab53ccfe60ffdad05d3c124e5"
413
+ }
414
+ }
359
415
  ```
360
416
 
361
417
  ---
362
418
 
363
419
  ## 🔒 Security
364
420
 
365
- CertiK Skill Scanner compliant:
421
+ Security self-audit — compliant with Pharos Skill Scanner guidelines:
366
422
 
367
423
  - ✅ **Private keys never stored** — passed per-request, never logged or persisted
368
424
  - ✅ **No hardcoded secrets** — all sensitive config via `.env`
369
425
  - ✅ **No shell execution** — pure TypeScript with viem RPC calls
370
426
  - ✅ **No file system abuse** — no local file reads/writes during tool execution
371
- - ✅ **Risk gating on all writes** — every execution goes through `assess_risk` first
427
+ - ✅ **Risk gating on execution** — `execute_swap` and `send_payment` run full risk assessment before execution. All write tools enforce safety checks before touching the chain.
372
428
  - ✅ **Automatic blocking** — score > 80 halts execution, no silent failures
373
429
 
430
+ ### Third-Party API Usage
431
+
432
+ SafeHands connects to three external services — all well-known, publicly documented Web3 infrastructure:
433
+
434
+ | Service | Endpoint | Purpose | Data Sent |
435
+ |---------|----------|---------|----------|
436
+ | **Pharos RPC** | `atlantic.dplabs-internal.com` | On-chain reads/writes | Standard JSON-RPC calls (public data) |
437
+ | **DODO Route API** | `api.dodoex.io` | DEX swap routing & quotes | Public token addresses, amounts |
438
+ | **GoPlus Security API** | `api.gopluslabs.io` | Token contract security scanning | Public token contract address |
439
+
440
+ > No private keys, wallet balances, or user-identifying data are ever sent to any external API. The DODO API key is a public, read-only key from DODO's official documentation.
441
+
374
442
  ---
375
443
 
376
444
  ## 🗺️ Roadmap
377
445
 
378
446
  ### Phase 1 — Hackathon (Current) ✅
379
- - [x] 15 MCP tools with real on-chain execution
447
+ - [x] 17 MCP tools with real on-chain execution
380
448
  - [x] 5-dimension risk scoring engine
381
449
  - [x] FaroSwap (DODO) integration
382
450
  - [x] On-chain RiskRegistry smart contract
383
- - [x] 16/16 integration tests passing on Pharos Atlantic
451
+ - [x] 17/17 integration tests passing on Pharos Atlantic
384
452
 
385
453
  ### Phase 2 — NPM Package
386
- - [ ] Publish `@safehands/mcp` to npm
387
- - [ ] One-line install: `npx safehands init`
454
+ - [x] Publish `safehands-pharos` to npm
455
+ - [x] One-line install: `npx safehands-pharos`
388
456
  - [ ] Configurable risk thresholds per-agent
389
457
 
390
458
  ### Phase 3 — Agent Arena
@@ -392,7 +460,8 @@ CertiK Skill Scanner compliant:
392
460
  - [ ] Reputation scoring from historical risk behavior
393
461
  - [ ] Multi-agent swap coordination with risk consensus
394
462
 
395
- ### Phase 4 — DeFi Expansion
463
+ ### Phase 4 — DeFi & x402 Integration
464
+ - [x] **x402 Paywall & Monetization:** Native integration with the Pharos x402 HTTP-payment standard. Enable SafeHands to charge micro-amounts of USDC per risk assessment request, allowing agents to monetize their safety gating services autonomously.
396
465
  - [ ] ELFi lending protocol integration
397
466
  - [ ] Multi-hop route optimization for large swaps
398
467
  - [ ] Smart contract escrow for agent-to-agent payments
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // ─── SafeHands MCP Server ──────────────────────────────────────────────
3
- // Entry point — registers all 15 tools and starts the MCP server.
3
+ // Entry point — registers all 17 tools and starts the MCP server.
4
4
  // ────────────────────────────────────────────────────────────────────────
5
5
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
6
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -19,6 +19,8 @@ import { queryRiskRegistrySchema, handleQueryRiskRegistry } from "./tools/queryR
19
19
  import { approveTokenSchema, handleApproveToken } from "./tools/approveToken.js";
20
20
  import { getGasPriceSchema, handleGetGasPrice } from "./tools/getGasPrice.js";
21
21
  import { getPoolInfoSchema, handleGetPoolInfo } from "./tools/getPoolInfo.js";
22
+ import { checkTokenSecuritySchema, handleCheckTokenSecurity } from "./tools/checkTokenSecurity.js";
23
+ import { x402PayAndFetchSchema, handleX402PayAndFetch } from "./tools/x402PayAndFetch.js";
22
24
  // ─── CLI Help ──────────────────────────────────────────────────────────
23
25
  if (process.argv.includes("--help") || process.argv.includes("-h")) {
24
26
  process.stdout.write(`
@@ -41,9 +43,10 @@ CONNECT TO CLAUDE DESKTOP
41
43
  }
42
44
  }
43
45
 
44
- AVAILABLE TOOLS (15)
46
+ AVAILABLE TOOLS (17)
45
47
  Core Safety
46
48
  assess_risk 5-dimension risk score (0-100) for any swap or transfer
49
+ check_token_security Check token contract security/honeypot via GoPlus API
47
50
  simulate_transaction Dry run via eth_call — zero gas spent
48
51
  estimate_gas Gas cost in PHRS and USD before execution
49
52
 
@@ -67,6 +70,9 @@ AVAILABLE TOOLS (15)
67
70
  publish_risk_score Publish risk assessment to on-chain RiskRegistry
68
71
  query_risk_registry Query any wallet's risk score — no key needed
69
72
 
73
+ x402 Payments
74
+ x402_pay_and_fetch Fetch paid API resources with automatic HTTP 402 signature and payment
75
+
70
76
  CHAIN
71
77
  Pharos Atlantic Testnet (Chain ID: 688689)
72
78
  RPC: https://atlantic.dplabs-internal.com/
@@ -99,9 +105,9 @@ ENVIRONMENT
99
105
  ⚠️ Private keys are never stored or logged by SafeHands.
100
106
  They are passed per-request only.
101
107
 
102
- NOTE: 10 of 15 tools work without any credentials.
103
- Only these 4 tools require PRIVATE_KEY:
104
- execute_swap, send_payment, approve_token, publish_risk_score
108
+ NOTE: 12 of 17 tools work without any credentials.
109
+ Only these 5 tools require PRIVATE_KEY:
110
+ execute_swap, send_payment, approve_token, publish_risk_score, x402_pay_and_fetch
105
111
 
106
112
  MORE
107
113
  npm: https://www.npmjs.com/package/safehands-pharos
@@ -122,7 +128,7 @@ if (!hasPrivateKey || !hasWalletAddress) {
122
128
  console.error(" WALLET_ADDRESS not set — some tools may return incomplete results");
123
129
  }
124
130
  console.error("");
125
- console.error(" 10 read-only tools are still fully functional.");
131
+ console.error(" 12 read-only tools are still fully functional.");
126
132
  console.error(" To enable all tools, set credentials in your MCP client config:");
127
133
  console.error(' "env": { "PRIVATE_KEY": "0x...", "WALLET_ADDRESS": "0x..." }');
128
134
  console.error("");
@@ -193,6 +199,14 @@ server.tool("get_pool_info", "Fetch DODO liquidity pool info for a token pair on
193
199
  const result = await handleGetPoolInfo(params);
194
200
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
195
201
  });
202
+ server.tool("check_token_security", "Check token contract security (honeypot, mintable, ownership privileges, tax) via GoPlus Security API.", checkTokenSecuritySchema.shape, async (params) => {
203
+ const result = await handleCheckTokenSecurity(params);
204
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
205
+ });
206
+ server.tool("x402_pay_and_fetch", "Fetch resources from an HTTP x402 payment-gated server. Automatically handles HTTP 402 payment challenge.", x402PayAndFetchSchema.shape, async (params) => {
207
+ const result = await handleX402PayAndFetch(params);
208
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
209
+ });
196
210
  // ─── Start Server ──────────────────────────────────────────────────────
197
211
  async function main() {
198
212
  const transport = new StdioServerTransport();