@phantom/openclaw-plugin 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,370 @@
1
+ # Phantom OpenClaw Plugin
2
+
3
+ Direct integration with Phantom wallet for OpenClaw agents. This plugin wraps the Phantom MCP Server to provide seamless wallet operations including address retrieval, message signing, transaction signing, token transfers, and token swaps.
4
+
5
+ ## Overview
6
+
7
+ The Phantom OpenClaw Plugin provides native integration with Phantom wallet functionality. Instead of being a generic MCP bridge, it directly integrates the Phantom MCP Server tools as OpenClaw tools, providing a seamless experience for AI agents.
8
+
9
+ ## Features
10
+
11
+ - **Direct Integration**: Built on top of `@phantom/mcp-server` for reliable wallet operations
12
+ - **Automatic Authentication**: Handles OAuth flow and session management automatically
13
+ - **Type-Safe**: Full TypeScript support with proper type definitions
14
+ - **Simple Setup**: Minimal configuration - just enable the plugin and use
15
+
16
+ ## Prerequisites
17
+
18
+ Before using this plugin, you **must** obtain an App ID from the Phantom Portal:
19
+
20
+ 1. **Visit the Phantom Portal**: Go to [phantom.com/portal](https://phantom.com/portal)
21
+ 2. **Sign in**: Use your Gmail or Apple account to sign in
22
+ 3. **Create an App**: Click "Create App" and fill in the required details
23
+ 4. **Get Your App ID**: Navigate to the "Phantom Connect" tab to find your App ID
24
+ - Your app is automatically approved for development use
25
+ - Copy the App ID for the configuration below
26
+
27
+ **Important:** The email you use to sign in to the Phantom Portal **must match** the email you use when authenticating with the plugin. If these don't match, authentication will fail.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ openclaw plugins install @phantom/openclaw-plugin
33
+ ```
34
+
35
+ ## Configuration
36
+
37
+ Configure the plugin in your OpenClaw configuration file (`~/.openclaw/openclaw.json`):
38
+
39
+ ```json
40
+ {
41
+ "plugins": {
42
+ "enabled": true,
43
+ "entries": {
44
+ "phantom-openclaw-plugin": {
45
+ "enabled": true,
46
+ "config": {
47
+ "PHANTOM_APP_ID": "your_app_id_from_portal"
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ ```
54
+
55
+ ### Configuration Options
56
+
57
+ - **`PHANTOM_APP_ID`** (required): Your App ID from the Phantom Portal
58
+ - **`PHANTOM_CLIENT_SECRET`** (optional): Client secret for confidential clients
59
+ - **`PHANTOM_CALLBACK_PORT`** (optional): OAuth callback port (default: 8080)
60
+ - **`PHANTOM_MCP_DEBUG`** (optional): Enable debug logging (set to "1")
61
+
62
+ **Note:** Most users only need to provide `PHANTOM_APP_ID`. The other options are for advanced use cases.
63
+
64
+ ## Available Tools
65
+
66
+ The plugin exposes the following tools from the Phantom MCP Server:
67
+
68
+ ### `get_wallet_addresses`
69
+
70
+ Retrieve wallet addresses for all supported blockchain chains.
71
+
72
+ **Parameters:**
73
+
74
+ - `derivationIndex` (number, optional): Derivation index for the wallet (default: 0)
75
+
76
+ **Example:**
77
+
78
+ ```json
79
+ {
80
+ "derivationIndex": 0
81
+ }
82
+ ```
83
+
84
+ ### `sign_message`
85
+
86
+ Sign an arbitrary message with the Phantom wallet.
87
+
88
+ **Parameters:**
89
+
90
+ - `message` (string, required): The message to sign
91
+ - `derivationIndex` (number, optional): Derivation index for the wallet (default: 0)
92
+
93
+ **Example:**
94
+
95
+ ```json
96
+ {
97
+ "message": "Hello, Phantom!",
98
+ "derivationIndex": 0
99
+ }
100
+ ```
101
+
102
+ ### `sign_transaction`
103
+
104
+ Sign a blockchain transaction.
105
+
106
+ **Parameters:**
107
+
108
+ - `transaction` (string, required): Base64-encoded transaction data
109
+ - `derivationIndex` (number, optional): Derivation index for the wallet (default: 0)
110
+ - `chain` (string, optional): Blockchain chain identifier
111
+
112
+ **Example:**
113
+
114
+ ```json
115
+ {
116
+ "transaction": "base64-encoded-transaction-data",
117
+ "derivationIndex": 0,
118
+ "chain": "solana"
119
+ }
120
+ ```
121
+
122
+ ### `transfer_tokens`
123
+
124
+ Transfer SOL or SPL tokens on Solana. Builds, signs, and sends the transaction immediately.
125
+
126
+ **Parameters:**
127
+
128
+ - `networkId` (string, required): Solana network identifier (e.g., "solana:mainnet", "solana:devnet")
129
+ - `to` (string, required): Recipient Solana address
130
+ - `amount` (string, required): Transfer amount (e.g., "0.1" or "1000000")
131
+ - `amountUnit` (string, optional): Unit type - `"ui"` for human-readable (SOL/token units) or `"base"` for atomic units (lamports). Default: `"ui"`
132
+ - `tokenMint` (string, optional): SPL token mint address. Omit for SOL transfers
133
+ - `decimals` (number, optional): Token decimals (optional for SPL tokens)
134
+ - `derivationIndex` (number, optional): Derivation index for the wallet (default: 0)
135
+ - `createAssociatedTokenAccount` (boolean, optional): Create destination ATA if missing (default: true)
136
+
137
+ **Example (SOL Transfer):**
138
+
139
+ ```json
140
+ {
141
+ "networkId": "solana:mainnet",
142
+ "to": "H8FpYTgx4Uy9aF9Nk9fCTqKKFLYQ9KfC6UJhMkMDzCBh",
143
+ "amount": "0.1",
144
+ "amountUnit": "ui"
145
+ }
146
+ ```
147
+
148
+ **Example (SPL Token Transfer):**
149
+
150
+ ```json
151
+ {
152
+ "networkId": "solana:devnet",
153
+ "to": "H8FpYTgx4Uy9aF9Nk9fCTqKKFLYQ9KfC6UJhMkMDzCBh",
154
+ "tokenMint": "So11111111111111111111111111111111111111112",
155
+ "amount": "1.5",
156
+ "amountUnit": "ui"
157
+ }
158
+ ```
159
+
160
+ **⚠️ Warning:** This tool submits transactions immediately and irreversibly.
161
+
162
+ ### `buy_token`
163
+
164
+ Fetch a Solana swap quote from Phantom's quotes API. Optionally execute the swap immediately.
165
+
166
+ **Parameters:**
167
+
168
+ - `networkId` (string, optional): Solana network identifier (default: "solana:mainnet")
169
+ - `sellTokenIsNative` (boolean, optional): Set true to sell native SOL (default: true if sellTokenMint not provided)
170
+ - `sellTokenMint` (string, optional): Mint address of the token to sell (omit if selling native SOL)
171
+ - `buyTokenIsNative` (boolean, optional): Set true to buy native SOL (default: false)
172
+ - `buyTokenMint` (string, optional): Mint address of the token to buy (omit if buying native SOL)
173
+ - `amount` (string, required): Sell amount (e.g., "0.5" or "500000000")
174
+ - `amountUnit` (string, optional): Unit type - `"ui"` for token units or `"base"` for atomic units. Default: `"base"`
175
+ - `slippageTolerance` (number, optional): Slippage tolerance in percent (0-100)
176
+ - `execute` (boolean, optional): If true, signs and sends the transaction immediately. Default: false
177
+ - `derivationIndex` (number, optional): Derivation index for the wallet (default: 0)
178
+
179
+ **Example:**
180
+
181
+ ```json
182
+ {
183
+ "networkId": "solana:mainnet",
184
+ "sellTokenIsNative": true,
185
+ "buyTokenMint": "So11111111111111111111111111111111111111112",
186
+ "amount": "0.5",
187
+ "amountUnit": "ui",
188
+ "slippageTolerance": 1,
189
+ "execute": true
190
+ }
191
+ ```
192
+
193
+ **⚠️ Warning:** When `execute: true`, this tool submits transactions immediately and irreversibly.
194
+
195
+ ## Authentication
196
+
197
+ On first use, the plugin will automatically initiate the Phantom OAuth flow:
198
+
199
+ 1. A browser window will open to `https://connect.phantom.app`
200
+ 2. Sign in with your Google or Apple account
201
+ - **Important:** Use the same email you used to sign in to the Phantom Portal
202
+ 3. Authorize the application
203
+ 4. The session will be saved for future use
204
+
205
+ Sessions are stored securely in `~/.phantom-mcp/session.json` with restricted permissions and persist across restarts. The plugin uses stamper keypair authentication which doesn't expire.
206
+
207
+ ## Usage Examples
208
+
209
+ ### Check Wallet Addresses
210
+
211
+ ```text
212
+ User: What are my wallet addresses?
213
+ Agent: Let me check your Phantom wallet addresses.
214
+ [Calls get_wallet_addresses]
215
+ ```
216
+
217
+ ### Sign a Message
218
+
219
+ ```text
220
+ User: Sign this message: "Verify ownership of my wallet"
221
+ Agent: I'll sign that message for you using your Phantom wallet.
222
+ [Calls sign_message with the message]
223
+ ```
224
+
225
+ ### Sign a Transaction
226
+
227
+ ```text
228
+ User: Sign this Solana transaction: [transaction data]
229
+ Agent: I'll sign that transaction with your Phantom wallet.
230
+ [Calls sign_transaction with the transaction data]
231
+ ```
232
+
233
+ ## Architecture
234
+
235
+ ```text
236
+ phantom-openclaw-plugin/
237
+ ├── src/
238
+ │ ├── index.ts # Plugin entry point
239
+ │ ├── session.ts # Session management wrapper
240
+ │ ├── client/
241
+ │ │ └── types.ts # OpenClaw API types
242
+ │ └── tools/
243
+ │ └── register-tools.ts # Tool registration logic
244
+ ├── skills/
245
+ │ └── phantom-wallet/ # Wallet operations skill
246
+ └── openclaw.plugin.json # Plugin manifest
247
+ ```
248
+
249
+ ## Development
250
+
251
+ For contributors or those testing unreleased versions.
252
+
253
+ ### Prerequisites
254
+
255
+ - Node.js 18+
256
+ - yarn
257
+ - Phantom wallet account for testing
258
+ - App ID from [Phantom Portal](https://phantom.com/portal)
259
+
260
+ ### Local Installation
261
+
262
+ 1. Clone and build the plugin:
263
+
264
+ ```bash
265
+ # From the phantom-connect-sdk repository root
266
+ yarn install
267
+ yarn workspace @phantom/mcp-server build
268
+ yarn workspace @phantom/openclaw-plugin build
269
+ ```
270
+
271
+ 2. Install locally into OpenClaw:
272
+
273
+ ```bash
274
+ openclaw plugins install -l ./packages/phantom-openclaw-plugin
275
+ ```
276
+
277
+ 3. Configure in `~/.openclaw/openclaw.json`:
278
+
279
+ ```json
280
+ {
281
+ "plugins": {
282
+ "enabled": true,
283
+ "entries": {
284
+ "phantom-openclaw-plugin": {
285
+ "enabled": true,
286
+ "config": {
287
+ "PHANTOM_APP_ID": "your_app_id_from_portal"
288
+ }
289
+ }
290
+ }
291
+ }
292
+ }
293
+ ```
294
+
295
+ 4. Verify installation:
296
+
297
+ ```bash
298
+ openclaw plugins list
299
+ ```
300
+
301
+ 5. Test with an agent:
302
+ ```bash
303
+ openclaw chat
304
+ > What are my Phantom wallet addresses?
305
+ ```
306
+
307
+ ### Build Commands
308
+
309
+ ```bash
310
+ # Build the plugin
311
+ yarn build
312
+
313
+ # Development mode with watch
314
+ yarn dev
315
+
316
+ # Type checking
317
+ yarn check-types
318
+
319
+ # Linting
320
+ yarn lint
321
+
322
+ # Format code
323
+ yarn prettier
324
+ ```
325
+
326
+ ## Troubleshooting
327
+
328
+ ### Plugin Not Loading
329
+
330
+ - Verify the plugin is enabled in `openclaw.json`
331
+ - Check that the build completed successfully (`dist/` directory exists)
332
+ - Ensure both the plugin and `@phantom/mcp-server` are built
333
+
334
+ ### Authentication Fails
335
+
336
+ - Check your internet connection
337
+ - Ensure you have a Phantom wallet account
338
+ - Try clearing the session cache: `rm -rf ~/.phantom-mcp/session.json`
339
+ - Check the console logs for specific error messages
340
+
341
+ ### Tool Execution Errors
342
+
343
+ - Ensure you're authenticated (the plugin will prompt if not)
344
+ - Verify the tool parameters match the expected schema
345
+ - Check that the Phantom wallet supports the requested operation
346
+
347
+ ## Related Projects
348
+
349
+ - [@phantom/mcp-server](../mcp-server) - The underlying MCP server providing wallet functionality
350
+ - [Phantom Wallet](https://phantom.app) - The Phantom wallet application
351
+
352
+ ## Contributing
353
+
354
+ Contributions are welcome! Please ensure:
355
+
356
+ - TypeScript types are properly defined
357
+ - Code follows the existing style (run `yarn prettier`)
358
+ - All builds pass (`yarn build`)
359
+ - Type checking passes (`yarn check-types`)
360
+
361
+ ## License
362
+
363
+ MIT
364
+
365
+ ## Support
366
+
367
+ For issues or questions:
368
+
369
+ - GitHub Issues: https://github.com/phantom/phantom-connect-sdk/issues
370
+ - Phantom Support: https://help.phantom.app
@@ -0,0 +1,5 @@
1
+ {
2
+ "id": "phantom-openclaw-plugin",
3
+ "name": "Phantom Wallet Plugin",
4
+ "description": "Direct integration with Phantom wallet for blockchain operations - get addresses, sign messages, and sign transactions."
5
+ }
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@phantom/openclaw-plugin",
3
+ "version": "0.1.0",
4
+ "description": "OpenClaw plugin that bridges tool calls to Phantom's MCP server for wallet operations.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/phantom/phantom-connect-sdk",
8
+ "directory": "packages/phantom-openclaw-plugin"
9
+ },
10
+ "main": "dist/index.js",
11
+ "module": "dist/index.mjs",
12
+ "types": "dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/index.mjs",
16
+ "require": "./dist/index.js",
17
+ "types": "./dist/index.d.ts"
18
+ }
19
+ },
20
+ "openclaw": {
21
+ "extensions": [
22
+ "./dist/index.js"
23
+ ]
24
+ },
25
+ "scripts": {
26
+ "?pack-release": "When https://github.com/changesets/changesets/issues/432 has a solution we can remove this trick",
27
+ "pack-release": "rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
28
+ "build": "rimraf ./dist && tsup",
29
+ "dev": "tsup --watch",
30
+ "clean": "rimraf dist",
31
+ "lint": "tsc --noEmit && eslint --cache . --ext .ts,.tsx",
32
+ "check-types": "tsc --noEmit",
33
+ "prettier": "prettier --write \"src/**/*.{ts,tsx}\""
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^20.11.0",
37
+ "eslint": "8.53.0",
38
+ "prettier": "^3.5.2",
39
+ "rimraf": "^6.0.1",
40
+ "tsup": "^6.7.0",
41
+ "typescript": "^5.0.4"
42
+ },
43
+ "dependencies": {
44
+ "@phantom/mcp-server": "workspace:^",
45
+ "@sinclair/typebox": "^0.32.0"
46
+ },
47
+ "files": [
48
+ "dist",
49
+ "openclaw.plugin.json",
50
+ "README.md"
51
+ ],
52
+ "publishConfig": {
53
+ "directory": "_release/package"
54
+ }
55
+ }