safehands-pharos 1.2.5 → 1.3.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.
@@ -0,0 +1,147 @@
1
+ # SafeHands-Pharos — Live Docs & Testnet Verification Report
2
+
3
+ > **Date:** 2026-06-12
4
+ > **Version:** 1.2.0
5
+
6
+ ---
7
+
8
+ ## 1. Files Changed
9
+
10
+ | File | Change |
11
+ |------|--------|
12
+ | `src/lib/constants.ts` | USDT, WBTC, WETH, WPHRS verification upgraded from `PROJECT_CONFIGURED` → `DOCS_VERIFIED` after confirming against official Pharos Token Registry |
13
+ | `src/tools/tokenRegistryStatus.ts` | Handler now reads `verificationStatus` from registry entries directly |
14
+ | `src/lib/testRpcLive.ts` | **NEW** — Live RPC verification with structured output |
15
+ | `src/lib/testLiveSafehands.ts` | **NEW** — 7-point live CLI verification |
16
+ | `src/lib/testX402Live.ts` | **NEW** — x402 behavior verification (local server) |
17
+ | `src/lib/testDodoLive.ts` | **NEW** — DODO/FaroSwap live verification with clean skip |
18
+ | `package.json` | Added 4 new npm scripts |
19
+ | `README.md` | Added Real Testnet Verification section + updated Tests section |
20
+ | `OFFICIAL_DOCS_ALIGNMENT_REPORT.md` | **NEW** — Full docs alignment table |
21
+
22
+ ## 2. Official Docs Checked
23
+
24
+ | Source | Fetched |
25
+ |--------|---------|
26
+ | https://docs.pharos.xyz/getting-started/network/atlantic-testnet | ✅ |
27
+ | https://docs.pharos.xyz/getting-started/token-registry | ✅ |
28
+ | https://docs.pharos.xyz/getting-started/canonical-contracts | ✅ |
29
+ | https://docs.pharos.xyz/developer-guide/x402 | ✅ |
30
+ | https://docs.pharos.xyz/tooling-and-infrastructure/pharos-skill-engine-guide | ✅ |
31
+ | https://developers.circle.com/stablecoins/usdc-contract-addresses | ✅ |
32
+ | https://docs.faroswap.xyz/en/introduction | ❌ HTTP 307 |
33
+
34
+ ## 3. Docs Alignment Summary
35
+
36
+ - **13 DOCS_VERIFIED** — Environment, Chain ID, RPC, Explorer, Native Token, USDC, USDT, WBTC, WETH, WPHRS, x402 behavior, Skill Engine structure, Testnet scope
37
+ - **1 DOCS_DEMO_NON_OFFICIAL** — x402 demo token
38
+ - **4 PROJECT_CONFIGURED** — DODO Approve, DODO Route Proxy, Position Manager, RiskRegistry
39
+ - **0 CONFLICT**
40
+
41
+ ## 4. Real RPC Test Result
42
+
43
+ ```
44
+ npm run test:rpc:live
45
+ ```
46
+
47
+ | Check | Result |
48
+ |-------|--------|
49
+ | RPC reachable | ✅ yes |
50
+ | Chain ID | 688689 ✅ match |
51
+ | Latest block | 24023029 |
52
+ | Wallet balance | SKIPPED_NO_WALLET_ADDRESS |
53
+ | **Status** | **PASS** |
54
+
55
+ ## 5. Real SafeHands CLI Check Result
56
+
57
+ ```
58
+ npm run test:live:safehands
59
+ ```
60
+
61
+ | # | Check | Result |
62
+ |---|-------|--------|
63
+ | 1 | wallet_health_no_wallet | ✅ PASS |
64
+ | 2 | token_registry_canonical_usdc (DOCS_VERIFIED) | ✅ PASS |
65
+ | 3 | token_registry_x402_demo (DOCS_DEMO_NON_OFFICIAL) | ✅ PASS |
66
+ | 4 | token_registry_usdt_docs_verified | ✅ PASS |
67
+ | 5 | preflight_block_unlimited_approval | ✅ PASS |
68
+ | 6 | preflight_block_mainnet | ✅ PASS |
69
+ | 7 | preflight_allow_testnet | ✅ PASS |
70
+ | **Status** | **7/7 PASS** |
71
+
72
+ ## 6. Real x402 Behavior Result
73
+
74
+ ```
75
+ npm run test:x402:live
76
+ ```
77
+
78
+ **Label: LOCAL_X402_SERVER_DOCS_BEHAVIOR_TEST**
79
+
80
+ | # | Check | Result |
81
+ |---|-------|--------|
82
+ | 1 | /supported without private key | ✅ 200 OK |
83
+ | 2 | /health without private key | ✅ 200 OK |
84
+ | 3 | Paid endpoint without config → structured 503 | ✅ |
85
+ | 4 | No crash on missing config | ✅ |
86
+ | 5 | x402 token matches docs (USDC on eip155:688689) | ✅ |
87
+ | **Status** | **5/5 PASS** |
88
+
89
+ ## 7. DODO/FaroSwap Real Verification Result
90
+
91
+ ```
92
+ npm run test:dodo:live
93
+ ```
94
+
95
+ | # | Check | Result |
96
+ |---|-------|--------|
97
+ | 1 | DODO API route check | ⏭️ SKIPPED_MISSING_DODO_API_KEY |
98
+ | 2 | DODO Approve address verification | ✅ PROJECT_CONFIGURED |
99
+ | 3 | DODO Route Proxy verification | ✅ PROJECT_CONFIGURED |
100
+ | **Status** | **2/3 PASS, 1 SKIPPED** |
101
+
102
+ ## 8. Address Metadata Changes
103
+
104
+ | Token | Before | After | Source |
105
+ |-------|--------|-------|--------|
106
+ | USDC | DOCS_VERIFIED | DOCS_VERIFIED | Token Registry + Circle |
107
+ | TUSDC | DOCS_DEMO_NON_OFFICIAL | DOCS_DEMO_NON_OFFICIAL | x402 docs |
108
+ | USDT | (no verificationStatus) | **DOCS_VERIFIED** | Token Registry |
109
+ | WBTC | (no verificationStatus) | **DOCS_VERIFIED** | Token Registry |
110
+ | WETH | (no verificationStatus) | **DOCS_VERIFIED** | Token Registry |
111
+ | WPHRS | (no verificationStatus) | **DOCS_VERIFIED** | Token Registry |
112
+ | DODO addresses | PROJECT_CONFIGURED | PROJECT_CONFIGURED | FaroSwap docs unavailable |
113
+ | RiskRegistry | PROJECT_CONFIGURED | PROJECT_CONFIGURED | Not in canonical contracts |
114
+
115
+ ## 9. Commands Run and Results
116
+
117
+ | Command | Exit Code |
118
+ |---------|-----------|
119
+ | `npm run build` | 0 ✅ |
120
+ | `npx tsc -p tsconfig.all.json --pretty false` | 0 ✅ |
121
+ | `npm audit --omit=dev --audit-level=high` | 0 ✅ (0 vulnerabilities) |
122
+ | `npm pack --dry-run` | 0 ✅ (210 files, 128.4 kB) |
123
+ | `npm run test:all` | 0 ✅ (37/37 passed) |
124
+ | `npm run demo` | 0 ✅ |
125
+ | `npm run test:rpc:live` | 0 ✅ (PASS) |
126
+ | `npm run test:live:safehands` | 0 ✅ (7/7) |
127
+ | `npm run test:x402:live` | 0 ✅ (5/5) |
128
+ | `npm run test:dodo:live` | 0 ✅ (2/3, 1 skipped) |
129
+
130
+ ## 10. Remaining Docs-Unverified Values
131
+
132
+ | Value | Status | Reason |
133
+ |-------|--------|--------|
134
+ | DODO Approve Address `0x4Cf3…` | PROJECT_CONFIGURED | FaroSwap docs HTTP 307 |
135
+ | DODO Route Proxy `0x8198…` | PROJECT_CONFIGURED | FaroSwap docs HTTP 307 |
136
+ | Position Manager `0x1c43…` | PROJECT_CONFIGURED | FaroSwap docs HTTP 307 |
137
+ | RiskRegistry `0x71fc…` | PROJECT_CONFIGURED | Custom project deployment |
138
+
139
+ ## 11. Real Transactions Broadcast
140
+
141
+ **None.** Zero transactions were signed or broadcast during this verification pass. All tests are read-only RPC calls, deterministic preflight policy checks, or local server behavior tests.
142
+
143
+ ## 12. Final Status
144
+
145
+ **Status: Ready for DoraHacks Phase 1 submission with real docs/live verification**
146
+
147
+ All 13 docs-verifiable values match official Pharos documentation. Live RPC confirms chain ID 688689 and block production. 37 smoke tests + 7 CLI checks + 5 x402 checks pass. DODO skips cleanly. Zero vulnerabilities. No overclaimed addresses.
@@ -0,0 +1,85 @@
1
+ # SafeHands-Pharos — Official Pharos Skill Engine Alignment Report
2
+
3
+ > **Date:** 2026-06-12
4
+ > **Version:** 1.2.0
5
+
6
+ ---
7
+
8
+ ## 1. Files Changed
9
+ | File | Change |
10
+ |------|--------|
11
+ | `src/lib/constants.ts` | Upgraded `0xE0BE08c7...` to primary `USDC_ADDRESS`, relabeled `0xcfC8330f...` as `CIRCLE_USDC_ADDRESS`. |
12
+ | `src/tools/tokenRegistryStatus.ts` | Rewrote classification to output `SKILL_ENGINE_CANONICAL_TOKEN` or `ALTERNATE_SOURCE_TOKEN` based on new registry metadata. |
13
+ | `skill/SKILL.md` | **NEW** — Created official SKILL.md file adhering to Pharos Skill Engine formatting standards with YAML frontmatter. |
14
+ | `skill/references/safehands.md` | **NEW** — Copied over the CLI reference guide into the required skill package structure. |
15
+ | `skill/assets/safehands/*` | **NEW** — Policy defaults and example actions migrated. Example actions now strictly use `0xE0BE08c7...`. |
16
+ | `src/lib/testTools.ts` | Added 6 new smoke tests covering the `skill/` package structure and exact token metadata values. |
17
+ | `src/lib/testLiveSafehands.ts` | Updated live CLI checks to verify new USDC classification. |
18
+ | `src/index.ts` | Fixed the `--demo` exit path bug to ensure test pipelines exit cleanly without starting the MCP server inadvertently. |
19
+ | `package.json` | Appended the `skill` directory and new alignment reports to the npm `files` array for proper packaging. |
20
+ | `README.md` | Added the "Official Pharos Skill Engine Alignment" section and updated token addresses in the context table. |
21
+ | `OFFICIAL_DOCS_ALIGNMENT_REPORT.md` | Updated docs alignment tables and summaries to reflect the Skill Engine metadata. |
22
+
23
+ ## 2. Official Pharos Skill Engine Zip Findings
24
+ Inspection of `pharos-skill-engine-0.1.0.zip` revealed:
25
+ - **Structure:** `SKILL.md`, `references/`, and `assets/`.
26
+ - **Token Metadata:** The file `assets/tokens.json` officially defines the Atlantic Testnet USDC address as **`0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8`**.
27
+ - **Role:** The official skill handles execution (`cast`/`forge`), confirming SafeHands' positioning as a complementary preflight guardrail rather than an execution wrapper.
28
+
29
+ ## 3. Token Metadata Changes
30
+ - **Primary USDC (`0xE0BE08c7...`)**: The official Pharos Skill Engine token (previously treated as a docs demo token) has been promoted to the canonical testnet USDC default.
31
+ - **Status:** `SKILL_ENGINE_CANONICAL_TOKEN`
32
+ - **Verification:** `DOCS_VERIFIED_FROM_PHAROS_SKILL_ENGINE`
33
+ - **Alternate USDC (`0xcfC8330f...`)**: The USDC address sourced from Circle's official documentation is preserved but deprioritized to avoid conflicts.
34
+ - **Status:** `ALTERNATE_SOURCE_TOKEN`
35
+ - **Verification:** `CIRCLE_REFERENCED_USDC`
36
+
37
+ Both tokens are handled gracefully by `token_registry_status`, ensuring the agent receives factual provenance.
38
+
39
+ ## 4. Skill Package Structure Created
40
+ The `skill/` directory was generated successfully, mirroring the PiggyBank template layout:
41
+ ```text
42
+ skill/
43
+ ├── SKILL.md (with YAML frontmatter, Capability Index, Pre-checks)
44
+ ├── references/
45
+ │ └── safehands.md
46
+ └── assets/
47
+ └── safehands/
48
+ ├── policy-defaults.json
49
+ └── example-actions.json
50
+ ```
51
+ The package allows an AI agent to dynamically invoke `safehands_preflight_check` using official Pharos patterns.
52
+
53
+ ## 5. Tests Added/Updated
54
+ - **`skill_package_skill_md_exists`**: Confirms presence of `SKILL.md`.
55
+ - **`skill_package_yaml_frontmatter`**: Ensures exact match for `name: safehands-pharos-guard` in frontmatter.
56
+ - **`skill_package_references_exist`**: Verifies presence of the `references/safehands.md` guide.
57
+ - **`skill_package_assets_exist`**: Verifies presence of the JSON assets.
58
+ - **`skill_package_example_uses_skill_engine_usdc`**: Blocks regressions to the `0xcfC8...` address within example configs.
59
+ - **`token_registry_circle_usdc_alternate`**: Ensures `0xcfC8...` retains its explicit alternate status.
60
+ - **`demo_runs_or_fails_gracefully`**: Fixed to properly handle the exit code when the demo runs successfully.
61
+
62
+ ## 6. Commands Run and Results
63
+ | Command | Result |
64
+ |---------|--------|
65
+ | `npm ci` | 0 ✅ |
66
+ | `npm run build` | 0 ✅ |
67
+ | `npx tsc -p tsconfig.all.json --pretty false` | 0 ✅ |
68
+ | `npm run test:all` | 0 ✅ (43/43 smoke tests passed) |
69
+ | `npm audit --omit=dev --audit-level=high` | 0 ✅ (0 vulnerabilities) |
70
+ | `npm run demo` | 0 ✅ (Clean exit, output identical to previous demo) |
71
+
72
+ ## 7. npm pack Safety Result
73
+ ```bash
74
+ npm pack --dry-run
75
+ ```
76
+ - Includes the new `skill/` directory and `OFFICIAL_DOCS_ALIGNMENT_REPORT.md`.
77
+ - **Secret scan**: Passed (0 exposed variables found).
78
+ - **Total files:** 215 files (135.9 kB).
79
+
80
+ ## 8. Remaining Risks/TODOs
81
+ - **DODO / FaroSwap Router Addresses:** Currently `PROJECT_CONFIGURED`. This remains unverified due to the FaroSwap documentation returning an HTTP 307 redirect. This cannot be fixed without live docs.
82
+ - **RiskRegistry Contract:** A project-deployed contract (`PROJECT_CONFIGURED`) used to simulate risk scores. Expected hackathon behavior.
83
+
84
+ ## 9. Final Status
85
+ **Status: Ready for DoraHacks Phase 1 submission with official Pharos Skill Engine alignment**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safehands-pharos",
3
- "version": "1.2.5",
3
+ "version": "1.3.0",
4
4
  "description": "Pharos Skill Engine-compatible transaction safety firewall for AI agents.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,6 +18,8 @@
18
18
  "skill",
19
19
  "README.md",
20
20
  ".env.example",
21
+ "docs",
22
+ ".agents",
21
23
  "LICENSE"
22
24
  ],
23
25
  "scripts": {
package/skill/SKILL.md CHANGED
@@ -1,127 +1,133 @@
1
- ---
2
- name: safehands-pharos-guard
3
- description: >
4
- REQUIRED before any Pharos AI agent write action involving token approvals, payments, swaps,
5
- x402 paid requests, or custom contract calls. SafeHands runs policy-based preflight checks
6
- and returns ALLOW, WARN, BLOCK, REQUIRE_CONFIRMATION, REQUIRE_FUNDING, or REQUIRE_TOKEN_REVIEW
7
- before execution. Use this skill as a safety firewall before invoking Pharos Skill Engine
8
- write operations.
9
- version: 1.2.0
10
- requires:
11
- anyBins:
12
- - npx
13
- ---
14
-
15
- # SafeHands Pharos Guard
16
-
17
- Transaction Safety Firewall / Guardrail Skill for Pharos AI agents. SafeHands checks whether an action is safe before execution on Pharos Atlantic Testnet.
18
-
19
- SafeHands complements the official `pharos-skill-engine`. It is not a replacement. The official Skill Engine provides general on-chain capabilities (queries, transactions, contract deployments). SafeHands answers: **"Is this action safe to execute?"**
20
-
21
- ```text
22
- User intent
23
- → SafeHands preflight (ALLOW / WARN / BLOCK / REQUIRE_CONFIRMATION)
24
- → Pharos Skill Engine or MCP execution (only if safe)
25
- → SafeHands risk report
26
- ```
27
-
28
- ## Prerequisites
29
-
30
- 1. **Install SafeHands** (via npx, no global install required):
31
- ```bash
32
- npx safehands-pharos --help
33
- ```
34
- If `npx safehands-pharos` is not available, install globally:
35
- ```bash
36
- npm install -g safehands-pharos
37
- ```
38
-
39
- 2. **No private key required** for safety checks. Private keys are only needed for write execution (which is disabled by default).
40
-
41
- ## Network Configuration
42
-
43
- SafeHands reads network configuration from its built-in constants. Default network: **Atlantic Testnet**.
44
-
45
- | Field | Value |
46
- |-------|-------|
47
- | Environment | `atlantic-testnet` |
48
- | Chain ID | `688689` |
49
- | RPC URL | `https://atlantic.dplabs-internal.com` |
50
- | Native Token | `PHRS` |
51
- | Primary USDC | `0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8` |
52
- | Mainnet | `false` |
53
-
54
- Token addresses are sourced from the official Pharos Skill Engine `assets/tokens.json`.
55
-
56
- ## Safety Model
57
-
58
- SafeHands enforces these guardrails by default:
59
-
60
- - **Block** mainnet actions
61
- - **Block** chain ID mismatch
62
- - **Block** unlimited token approvals
63
- - **Block** SSRF-sensitive x402 URLs (localhost, private IPs)
64
- - **Block** payments above configured limits
65
- - **Block** x402 payments above `MAX_X402_PAYMENT_USDC`
66
- - **Warn** when token is custom or non-registry
67
- - **Warn** when token security provider is unavailable
68
- - **Require confirmation** for medium-risk actions
69
- - **Allow** low-risk Pharos Atlantic Testnet actions
70
-
71
- Write tools are disabled by default (`WRITE_TOOLS_ENABLED=false`).
72
-
73
- ## Capability Index
74
-
75
- Load the corresponding reference file based on user needs to get full command templates.
76
-
77
- | User Need | Capability | Detailed Instructions |
78
- |-----------|------------|----------------------|
79
- | Check whether an on-chain action is safe before execution | SafeHands Preflight Check | → `references/safehands.md#safehands-preflight-check` |
80
- | Check whether an x402 paid endpoint is safe to pay | SafeHands x402 Preflight | → `references/safehands.md#safehands-x402-preflight` |
81
- | Check whether an agent wallet is ready to act | SafeHands Wallet Health | → `references/safehands.md#safehands-wallet-health` |
82
- | Check whether a token address is canonical or custom | Token Registry Status | → `references/safehands.md#token-registry-status` |
83
- | Explain why an action was blocked or warned | Explain Risk | `references/safehands.md#explain-risk` |
84
- | Generate a human-readable safety report | SafeHands Risk Report | → `references/safehands.md#safehands-risk-report` |
85
-
86
- ## General Error Handling
87
-
88
- Before executing commands, the Agent should perform pre-checks; when commands fail, provide user-friendly error messages based on the structured JSON output.
89
-
90
- | Error Scenario | Error Code | Handling |
91
- |---------------|-----------|----------|
92
- | Invalid address format | `INVALID_TOKEN_ADDRESS` / `INVALID_WALLET_ADDRESS` | Prompt to check address format (0x + 40 hex characters) |
93
- | Write tools disabled | `WRITE_TOOLS_DISABLED` | Inform user that write tools are disabled by default |
94
- | SSRF blocked URL | `SSRF_BLOCKED` | Do not fetch or pay; inform user the URL is blocked |
95
- | Mainnet action attempted | `MAINNET_NOT_SUPPORTED` | Do not execute; SafeHands is testnet-only |
96
- | Chain ID mismatch | `CHAIN_ID_MISMATCH` | Switch to Pharos Atlantic Testnet (688689) |
97
- | Signer not available | `NO_SIGNER_AVAILABLE` | Ask user to configure wallet mode |
98
- | Invalid input JSON | `INVALID_INPUT_JSON` | Fix the JSON input and retry |
99
- | Policy blocked | `POLICY_BLOCKED` | Explain reasons to the user; do not execute |
100
-
101
- See `references/safehands.md` for detailed error handling tables for each operation.
102
-
103
- ## Security Reminders
104
-
105
- - **No private key required** for read-only safety checks (preflight, token registry, wallet health, explain risk).
106
- - **Write tools are disabled by default.** Set `WRITE_TOOLS_ENABLED=true` only for trusted testnet execution.
107
- - **Private keys are never returned** in CLI or MCP responses.
108
- - **Unlimited approvals are blocked** unless explicitly allowed via `ALLOW_UNLIMITED_APPROVAL=true`.
109
- - **SSRF protection** blocks localhost and private IP x402 URLs by default.
110
- - **Testnet only.** SafeHands is not audited for mainnet production use.
111
-
112
- ## Write Operation Pre-checks (Required for All Write Operations)
113
-
114
- For all write operations, the Agent must run SafeHands preflight first:
115
-
116
- ```bash
117
- npx safehands-pharos skill safehands_preflight_check --input-json '<action_json>'
118
- ```
119
-
120
- 1. If `decision` is `BLOCK`, **stop execution**.
121
- 2. If `decision` is `WARN`, explain the risk and ask for user confirmation.
122
- 3. If `decision` is `REQUIRE_CONFIRMATION`, ask for explicit user approval.
123
- 4. If `decision` is `REQUIRE_FUNDING`, ask user to fund the wallet.
124
- 5. If `decision` is `REQUIRE_TOKEN_REVIEW`, ask user to verify the token contract.
125
- 6. If `decision` is `ALLOW`, proceed with the Pharos Skill Engine write operation.
126
-
127
- For full command templates, parameters, output parsing, and error handling, see [`references/safehands.md`](references/safehands.md).
1
+ ---
2
+ name: safehands-pharos-guard
3
+ description: >
4
+ REQUIRED before any Pharos AI agent write action involving token approvals, payments, swaps,
5
+ x402 paid requests, or custom contract calls. SafeHands runs policy-based preflight checks
6
+ and returns ALLOW, WARN, BLOCK, REQUIRE_CONFIRMATION, REQUIRE_FUNDING, or REQUIRE_TOKEN_REVIEW
7
+ before execution. Use this skill as a safety firewall before invoking Pharos Skill Engine
8
+ write operations.
9
+ version: 1.3.0
10
+ requires:
11
+ anyBins:
12
+ - npx
13
+ ---
14
+
15
+ # SafeHands Pharos Guard
16
+
17
+ Transaction Safety Firewall / Guardrail Skill for Pharos AI agents. SafeHands checks whether an action is safe before execution on Pharos Atlantic Testnet.
18
+
19
+ SafeHands complements the official `pharos-skill-engine`. It is not a replacement. The official Skill Engine provides general on-chain capabilities (queries, transactions, contract deployments). SafeHands answers: **"Is this action safe to execute?"**
20
+
21
+ ```text
22
+ User intent
23
+ → SafeHands preflight (ALLOW / WARN / BLOCK / REQUIRE_CONFIRMATION)
24
+ → Pharos Skill Engine or MCP execution (only if safe)
25
+ → SafeHands risk report
26
+ ```
27
+
28
+ ## Real-World Use Cases
29
+
30
+ 1. **Anti-Drain Protection:** An AI Agent is tricked by a prompt injection to approve `999999 USDC` to a hacker's contract. SafeHands intercepts the action, detects an unlimited approval, and returns `BLOCK`.
31
+ 2. **SSRF Payment Prevention:** A malicious website asks the AI Agent to pay `0.001 USDC` to an x402 URL pointing to `http://localhost:8080/admin`. SafeHands detects the private IP address, blocks the HTTP request, and returns `BLOCK` preventing server compromise.
32
+ 3. **Fake Token Detection:** An AI Agent decides to buy a token named "Official Pharos Coin" on the testnet. SafeHands checks the `token_registry_status`, realizes it's a fake token not listed in the official docs, and returns `WARN` to ask the human for confirmation before swapping.
33
+
34
+ ## Prerequisites
35
+
36
+ 1. **Install SafeHands** (via npx, no global install required):
37
+ ```bash
38
+ npx safehands-pharos --help
39
+ ```
40
+ If `npx safehands-pharos` is not available, install globally:
41
+ ```bash
42
+ npm install -g safehands-pharos
43
+ ```
44
+
45
+ 2. **No private key required** for safety checks. Private keys are only needed for write execution (which is disabled by default).
46
+
47
+ ## Network Configuration
48
+
49
+ SafeHands reads network configuration from its built-in constants. Default network: **Atlantic Testnet**.
50
+
51
+ | Field | Value |
52
+ |-------|-------|
53
+ | Environment | `atlantic-testnet` |
54
+ | Chain ID | `688689` |
55
+ | RPC URL | `https://atlantic.dplabs-internal.com` |
56
+ | Native Token | `PHRS` |
57
+ | Primary USDC | `0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8` |
58
+ | Mainnet | `false` |
59
+
60
+ Token addresses are sourced from the official Pharos Skill Engine `assets/tokens.json`.
61
+
62
+ ## Safety Model
63
+
64
+ SafeHands enforces these guardrails by default:
65
+
66
+ - **Block** mainnet actions
67
+ - **Block** chain ID mismatch
68
+ - **Block** unlimited token approvals
69
+ - **Block** SSRF-sensitive x402 URLs (localhost, private IPs)
70
+ - **Block** payments above configured limits
71
+ - **Block** x402 payments above `MAX_X402_PAYMENT_USDC`
72
+ - **Warn** when token is custom or non-registry
73
+ - **Warn** when token security provider is unavailable
74
+ - **Require confirmation** for medium-risk actions
75
+ - **Allow** low-risk Pharos Atlantic Testnet actions
76
+
77
+ Write tools are disabled by default (`WRITE_TOOLS_ENABLED=false`).
78
+
79
+ ## Capability Index
80
+
81
+ Load the corresponding reference file based on user needs to get full command templates.
82
+
83
+ | User Need | Capability | Detailed Instructions |
84
+ |-----------|------------|----------------------|
85
+ | Check whether an on-chain action is safe before execution | SafeHands Preflight Check | → `references/safehands.md#safehands-preflight-check` |
86
+ | Check whether an x402 paid endpoint is safe to pay | SafeHands x402 Preflight | → `references/safehands.md#safehands-x402-preflight` |
87
+ | Check whether an agent wallet is ready to act | SafeHands Wallet Health | → `references/safehands.md#safehands-wallet-health` |
88
+ | Check whether a token address is canonical or custom | Token Registry Status | `references/safehands.md#token-registry-status` |
89
+ | Explain why an action was blocked or warned | Explain Risk | → `references/safehands.md#explain-risk` |
90
+ | Generate a human-readable safety report | SafeHands Risk Report | `references/safehands.md#safehands-risk-report` |
91
+
92
+ ## General Error Handling
93
+
94
+ Before executing commands, the Agent should perform pre-checks; when commands fail, provide user-friendly error messages based on the structured JSON output.
95
+
96
+ | Error Scenario | Error Code | Handling |
97
+ |---------------|-----------|----------|
98
+ | Invalid address format | `INVALID_TOKEN_ADDRESS` / `INVALID_WALLET_ADDRESS` | Prompt to check address format (0x + 40 hex characters) |
99
+ | Write tools disabled | `WRITE_TOOLS_DISABLED` | Inform user that write tools are disabled by default |
100
+ | SSRF blocked URL | `SSRF_BLOCKED` | Do not fetch or pay; inform user the URL is blocked |
101
+ | Mainnet action attempted | `MAINNET_NOT_SUPPORTED` | Do not execute; SafeHands is testnet-only |
102
+ | Chain ID mismatch | `CHAIN_ID_MISMATCH` | Switch to Pharos Atlantic Testnet (688689) |
103
+ | Signer not available | `NO_SIGNER_AVAILABLE` | Ask user to configure wallet mode |
104
+ | Invalid input JSON | `INVALID_INPUT_JSON` | Fix the JSON input and retry |
105
+ | Policy blocked | `POLICY_BLOCKED` | Explain reasons to the user; do not execute |
106
+
107
+ See `references/safehands.md` for detailed error handling tables for each operation.
108
+
109
+ ## Security Reminders
110
+
111
+ - **No private key required** for read-only safety checks (preflight, token registry, wallet health, explain risk).
112
+ - **Write tools are disabled by default.** Set `WRITE_TOOLS_ENABLED=true` only for trusted testnet execution.
113
+ - **Private keys are never returned** in CLI or MCP responses.
114
+ - **Unlimited approvals are blocked** unless explicitly allowed via `ALLOW_UNLIMITED_APPROVAL=true`.
115
+ - **SSRF protection** blocks localhost and private IP x402 URLs by default.
116
+ - **Testnet only.** SafeHands is not audited for mainnet production use.
117
+
118
+ ## Write Operation Pre-checks (Required for All Write Operations)
119
+
120
+ For all write operations, the Agent must run SafeHands preflight first:
121
+
122
+ ```bash
123
+ npx safehands-pharos skill safehands_preflight_check --input-json '<action_json>'
124
+ ```
125
+
126
+ 1. If `decision` is `BLOCK`, **stop execution**.
127
+ 2. If `decision` is `WARN`, explain the risk and ask for user confirmation.
128
+ 3. If `decision` is `REQUIRE_CONFIRMATION`, ask for explicit user approval.
129
+ 4. If `decision` is `REQUIRE_FUNDING`, ask user to fund the wallet.
130
+ 5. If `decision` is `REQUIRE_TOKEN_REVIEW`, ask user to verify the token contract.
131
+ 6. If `decision` is `ALLOW`, proceed with the Pharos Skill Engine write operation.
132
+
133
+ For full command templates, parameters, output parsing, and error handling, see [`references/safehands.md`](references/safehands.md).