httpcat-cli 0.0.6 → 0.0.9
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 +356 -10
- package/dist/commands/balance.d.ts.map +1 -0
- package/dist/commands/balance.js +112 -0
- package/dist/commands/balance.js.map +1 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +1369 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/mcp-server.d.ts.map +1 -0
- package/dist/commands/mcp-server.js +12 -0
- package/dist/commands/mcp-server.js.map +1 -0
- package/dist/config.js +4 -4
- package/dist/config.js.map +1 -1
- package/dist/index.js +226 -109
- package/dist/index.js.map +1 -1
- package/dist/interactive/shell.d.ts.map +1 -1
- package/dist/interactive/shell.js +7 -0
- package/dist/interactive/shell.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +42 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +292 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +3 -0
- package/dist/mcp/types.js.map +1 -0
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ httpcat is a full-featured CLI tool that provides both interactive (with ASCII a
|
|
|
8
8
|
|
|
9
9
|
- 🎨 **Interactive Shell** - Beautiful REPL with ASCII art cats and colored output
|
|
10
10
|
- 🤖 **Headless Mode** - JSON output for scripting and LLM/agent integration
|
|
11
|
+
- 🔌 **MCP Server** - Built-in Model Context Protocol server for AI assistant integration
|
|
11
12
|
- 💳 **x402 Payments** - Automatic payment handling via x402 protocol
|
|
12
13
|
- 🔐 **Secure Config** - Local configuration storage in `~/.config/httpcat`
|
|
13
14
|
- 🌐 **Multi-Network** - Support for Base Sepolia (testnet) and Base (mainnet)
|
|
@@ -73,19 +74,21 @@ $ httpcat
|
|
|
73
74
|
> ^ < Your agent for token operations
|
|
74
75
|
|
|
75
76
|
🔗 Connected to: base-sepolia
|
|
76
|
-
🌐 Agent: https://agent.
|
|
77
|
+
🌐 Agent: https://agent.402.cat
|
|
77
78
|
|
|
78
79
|
httpcat> help
|
|
79
80
|
Available Commands:
|
|
80
81
|
|
|
81
82
|
create <name> <symbol> Create a new token
|
|
82
|
-
buy <
|
|
83
|
-
sell <
|
|
84
|
-
info <
|
|
83
|
+
buy <id|name|symbol> <amount> Buy tokens ($0.05, $0.10, or $0.20)
|
|
84
|
+
sell <id|name|symbol> <amount|all> Sell tokens
|
|
85
|
+
info <id|name|symbol> Get token information
|
|
85
86
|
list [--sort mcap|created] List all tokens
|
|
87
|
+
chat [token] Start streaming chat (optional: token symbol/name/address)
|
|
88
|
+
balance Check wallet balance (ETH and USDC)
|
|
86
89
|
health Check agent health
|
|
87
90
|
config [--show|--set|--reset] Manage configuration
|
|
88
|
-
network
|
|
91
|
+
network Show current network
|
|
89
92
|
help Show this help message
|
|
90
93
|
exit Exit the shell
|
|
91
94
|
|
|
@@ -274,6 +277,34 @@ httpcat list --page 3 --sort name
|
|
|
274
277
|
|
|
275
278
|
**Cost:** $0.0001 USDC
|
|
276
279
|
|
|
280
|
+
### Check Balance
|
|
281
|
+
|
|
282
|
+
Check your wallet's ETH and USDC balances.
|
|
283
|
+
|
|
284
|
+
**Interactive:**
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
httpcat> balance
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**CLI:**
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
httpcat balance
|
|
294
|
+
httpcat balance --private-key 0x...
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
**Output:**
|
|
298
|
+
|
|
299
|
+
- Wallet address
|
|
300
|
+
- ETH balance (for gas fees)
|
|
301
|
+
- USDC balance (for trading)
|
|
302
|
+
- Low balance warnings if applicable
|
|
303
|
+
|
|
304
|
+
**Cost:** Free (no payment required)
|
|
305
|
+
|
|
306
|
+
**Note:** If no private key is configured, you'll be prompted to enter it interactively (same as other commands).
|
|
307
|
+
|
|
277
308
|
### Health Check
|
|
278
309
|
|
|
279
310
|
Check if the agent is running.
|
|
@@ -292,6 +323,37 @@ httpcat health
|
|
|
292
323
|
|
|
293
324
|
**Cost:** $0.0001 USDC (or 402 response)
|
|
294
325
|
|
|
326
|
+
### Chat
|
|
327
|
+
|
|
328
|
+
Start streaming chat with the httpcat community. Join general chat or token-specific discussions.
|
|
329
|
+
|
|
330
|
+
**Interactive:**
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
httpcat> chat # Join general chat
|
|
334
|
+
httpcat> chat MTK # Join chat for token with symbol "MTK"
|
|
335
|
+
httpcat> chat "My Token" # Join chat for token with name "My Token"
|
|
336
|
+
httpcat> chat 0x1234... # Join chat for token at address
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
**CLI:**
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
httpcat chat
|
|
343
|
+
httpcat chat MTK
|
|
344
|
+
httpcat chat "My Token"
|
|
345
|
+
httpcat chat 0x1234...
|
|
346
|
+
httpcat --json chat MTK
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
**Token Identifier:**
|
|
350
|
+
|
|
351
|
+
- Token symbol: `MTK` (case-insensitive)
|
|
352
|
+
- Token name: `"My Token"` (use quotes if it contains spaces)
|
|
353
|
+
- Token address: `0x1234...`
|
|
354
|
+
|
|
355
|
+
**Cost:** $0.01 USDC to join, $0.0001 USDC per message, 10 minute lease
|
|
356
|
+
|
|
295
357
|
### Configuration
|
|
296
358
|
|
|
297
359
|
Manage your httpcat configuration.
|
|
@@ -312,6 +374,40 @@ httpcat config --show # Show current config (JSON)
|
|
|
312
374
|
httpcat config --set network=base # Update a setting
|
|
313
375
|
```
|
|
314
376
|
|
|
377
|
+
### MCP Server
|
|
378
|
+
|
|
379
|
+
Start the Model Context Protocol server for AI assistant integration.
|
|
380
|
+
|
|
381
|
+
**CLI:**
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
httpcat mcp-server
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Description:**
|
|
388
|
+
|
|
389
|
+
Starts an MCP server that exposes all httpcat CLI commands as MCP tools. The server communicates via stdio and can be used with MCP clients like Cursor or Claude Desktop.
|
|
390
|
+
|
|
391
|
+
**Configuration:**
|
|
392
|
+
|
|
393
|
+
Add to your MCP client config:
|
|
394
|
+
|
|
395
|
+
```json
|
|
396
|
+
{
|
|
397
|
+
"mcpServers": {
|
|
398
|
+
"httpcat": {
|
|
399
|
+
"command": "npx",
|
|
400
|
+
"args": ["-y", "httpcat-cli", "mcp-server"],
|
|
401
|
+
"env": {
|
|
402
|
+
"HTTPCAT_PRIVATE_KEY": "0x..." // Optional
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
See the [MCP Server section](#mcp-server-model-context-protocol) for detailed documentation.
|
|
410
|
+
|
|
315
411
|
## Headless Mode (JSON Output)
|
|
316
412
|
|
|
317
413
|
Perfect for scripting, automation, or LLM/agent integration.
|
|
@@ -479,7 +575,19 @@ All commands with `--json` flag return structured JSON responses. The output fol
|
|
|
479
575
|
{
|
|
480
576
|
"status": "ok",
|
|
481
577
|
"timestamp": "2025-11-22T10:30:00.000Z",
|
|
482
|
-
"agent": "https://agent.
|
|
578
|
+
"agent": "https://agent.402.cat"
|
|
579
|
+
}
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
**Balance (`balance`)**
|
|
583
|
+
|
|
584
|
+
```json
|
|
585
|
+
{
|
|
586
|
+
"address": "0x...",
|
|
587
|
+
"ethBalance": "1000000000000000000",
|
|
588
|
+
"usdcBalance": "5000000",
|
|
589
|
+
"ethFormatted": "1.0 ETH",
|
|
590
|
+
"usdcFormatted": "5.00 USDC"
|
|
483
591
|
}
|
|
484
592
|
```
|
|
485
593
|
|
|
@@ -488,7 +596,7 @@ All commands with `--json` flag return structured JSON responses. The output fol
|
|
|
488
596
|
```json
|
|
489
597
|
{
|
|
490
598
|
"name": "httpcat-cli",
|
|
491
|
-
"version": "0.
|
|
599
|
+
"version": "0.0.8"
|
|
492
600
|
}
|
|
493
601
|
```
|
|
494
602
|
|
|
@@ -535,6 +643,231 @@ if (( $(echo "$PNL > 0" | bc -l) )); then
|
|
|
535
643
|
fi
|
|
536
644
|
```
|
|
537
645
|
|
|
646
|
+
## MCP Server (Model Context Protocol)
|
|
647
|
+
|
|
648
|
+
httpcat includes a built-in MCP server that exposes all CLI commands as MCP tools, enabling seamless integration with AI assistants like Claude (via Claude Desktop) or Cursor.
|
|
649
|
+
|
|
650
|
+
### Quick Start
|
|
651
|
+
|
|
652
|
+
**Start the MCP server:**
|
|
653
|
+
|
|
654
|
+
```bash
|
|
655
|
+
httpcat mcp-server
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
**Or use npx (no installation needed):**
|
|
659
|
+
|
|
660
|
+
```bash
|
|
661
|
+
npx httpcat-cli mcp-server
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
### MCP Client Configuration
|
|
665
|
+
|
|
666
|
+
Add the httpcat MCP server to your MCP client configuration:
|
|
667
|
+
|
|
668
|
+
#### For Cursor
|
|
669
|
+
|
|
670
|
+
Add to your Cursor settings (`.cursor/mcp.json` or settings UI):
|
|
671
|
+
|
|
672
|
+
```json
|
|
673
|
+
{
|
|
674
|
+
"mcpServers": {
|
|
675
|
+
"httpcat": {
|
|
676
|
+
"command": "npx",
|
|
677
|
+
"args": ["-y", "httpcat-cli", "mcp-server"],
|
|
678
|
+
"env": {
|
|
679
|
+
"HTTPCAT_PRIVATE_KEY": "0x..." // Optional - can also pass via tool params
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
#### For Claude Desktop
|
|
687
|
+
|
|
688
|
+
Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
|
|
689
|
+
|
|
690
|
+
```json
|
|
691
|
+
{
|
|
692
|
+
"mcpServers": {
|
|
693
|
+
"httpcat": {
|
|
694
|
+
"command": "npx",
|
|
695
|
+
"args": ["-y", "httpcat-cli", "mcp-server"],
|
|
696
|
+
"env": {
|
|
697
|
+
"HTTPCAT_PRIVATE_KEY": "0x..."
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
#### Using Global Install
|
|
705
|
+
|
|
706
|
+
If you've installed httpcat globally:
|
|
707
|
+
|
|
708
|
+
```json
|
|
709
|
+
{
|
|
710
|
+
"mcpServers": {
|
|
711
|
+
"httpcat": {
|
|
712
|
+
"command": "httpcat",
|
|
713
|
+
"args": ["mcp-server"],
|
|
714
|
+
"env": {
|
|
715
|
+
"HTTPCAT_PRIVATE_KEY": "0x..."
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
### Available MCP Tools
|
|
723
|
+
|
|
724
|
+
The MCP server exposes the following tools:
|
|
725
|
+
|
|
726
|
+
#### `create_token`
|
|
727
|
+
|
|
728
|
+
Create a new token on the bonding curve.
|
|
729
|
+
|
|
730
|
+
**Parameters:**
|
|
731
|
+
|
|
732
|
+
- `name` (string, required) - Token name (e.g., "My Token")
|
|
733
|
+
- `symbol` (string, required) - Token symbol/ticker (3-10 characters)
|
|
734
|
+
- `photoUrl` (string, optional) - Photo URL for token logo
|
|
735
|
+
- `bannerUrl` (string, optional) - Banner image URL
|
|
736
|
+
- `websiteUrl` (string, optional) - Website URL
|
|
737
|
+
- `privateKey` (string, optional) - Private key (overrides config/env)
|
|
738
|
+
|
|
739
|
+
**Cost:** $0.01 USDC
|
|
740
|
+
|
|
741
|
+
#### `buy_token`
|
|
742
|
+
|
|
743
|
+
Buy tokens from the bonding curve.
|
|
744
|
+
|
|
745
|
+
**Parameters:**
|
|
746
|
+
|
|
747
|
+
- `identifier` (string, required) - Token ID (UUID), name, or symbol
|
|
748
|
+
- `amount` (string, required) - Amount: "0.05", "0.10", or "0.20" (testnet) | "50", "100", or "200" (mainnet)
|
|
749
|
+
- `privateKey` (string, optional) - Private key (overrides config/env)
|
|
750
|
+
|
|
751
|
+
**Cost:** Amount + 1% fee
|
|
752
|
+
|
|
753
|
+
#### `sell_token`
|
|
754
|
+
|
|
755
|
+
Sell tokens back to the bonding curve.
|
|
756
|
+
|
|
757
|
+
**Parameters:**
|
|
758
|
+
|
|
759
|
+
- `identifier` (string, required) - Token ID (UUID), name, or symbol
|
|
760
|
+
- `amount` (string, required) - Amount: number (e.g., "1000"), percentage (e.g., "50%"), or "all"
|
|
761
|
+
- `privateKey` (string, optional) - Private key (overrides config/env)
|
|
762
|
+
|
|
763
|
+
**Cost:** 1% fee deducted from proceeds
|
|
764
|
+
|
|
765
|
+
#### `token_info`
|
|
766
|
+
|
|
767
|
+
Get detailed information about a token.
|
|
768
|
+
|
|
769
|
+
**Parameters:**
|
|
770
|
+
|
|
771
|
+
- `identifier` (string, required) - Token ID (UUID), name, or symbol
|
|
772
|
+
- `privateKey` (string, optional) - Private key (overrides config/env)
|
|
773
|
+
|
|
774
|
+
**Returns:** Token details, price, market cap, graduation progress, and your position (if you own tokens)
|
|
775
|
+
|
|
776
|
+
**Cost:** $0.0001 USDC
|
|
777
|
+
|
|
778
|
+
#### `list_tokens`
|
|
779
|
+
|
|
780
|
+
List all tokens with pagination and sorting.
|
|
781
|
+
|
|
782
|
+
**Parameters:**
|
|
783
|
+
|
|
784
|
+
- `page` (number, optional) - Page number (default: 1)
|
|
785
|
+
- `limit` (number, optional) - Items per page (default: 20, max: 100)
|
|
786
|
+
- `sort` (string, optional) - Sort by: "mcap", "created", or "name" (default: "mcap")
|
|
787
|
+
- `privateKey` (string, optional) - Private key (overrides config/env)
|
|
788
|
+
|
|
789
|
+
**Cost:** $0.0001 USDC
|
|
790
|
+
|
|
791
|
+
#### `check_balance`
|
|
792
|
+
|
|
793
|
+
Check wallet balance (ETH and USDC).
|
|
794
|
+
|
|
795
|
+
**Parameters:**
|
|
796
|
+
|
|
797
|
+
- `privateKey` (string, optional) - Private key (overrides config/env)
|
|
798
|
+
|
|
799
|
+
**Cost:** Free (no payment required)
|
|
800
|
+
|
|
801
|
+
#### `health_check`
|
|
802
|
+
|
|
803
|
+
Check if the httpcat agent is running and healthy.
|
|
804
|
+
|
|
805
|
+
**Parameters:**
|
|
806
|
+
|
|
807
|
+
- `privateKey` (string, optional) - Private key (overrides config/env)
|
|
808
|
+
|
|
809
|
+
**Cost:** $0.0001 USDC
|
|
810
|
+
|
|
811
|
+
### Private Key Configuration
|
|
812
|
+
|
|
813
|
+
Private keys can be configured in three ways (priority order):
|
|
814
|
+
|
|
815
|
+
1. **Tool parameter** - Pass `privateKey` in each tool call (highest priority)
|
|
816
|
+
2. **Environment variable** - Set `HTTPCAT_PRIVATE_KEY` in the MCP client config
|
|
817
|
+
3. **Config file** - Use `httpcat config` to set up `~/.config/httpcat/config.json`
|
|
818
|
+
|
|
819
|
+
**Security Recommendation:** Use the environment variable in your MCP client config rather than passing it in each tool call.
|
|
820
|
+
|
|
821
|
+
### Example MCP Tool Usage
|
|
822
|
+
|
|
823
|
+
Once configured, AI assistants can use the tools like this:
|
|
824
|
+
|
|
825
|
+
```
|
|
826
|
+
create_token(name="Moon Token", symbol="MOON", websiteUrl="https://moon.com")
|
|
827
|
+
buy_token(identifier="abc123-...", amount="0.20")
|
|
828
|
+
token_info(identifier="MOON")
|
|
829
|
+
list_tokens(sort="mcap", limit=10)
|
|
830
|
+
check_balance()
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
### Response Format
|
|
834
|
+
|
|
835
|
+
All MCP tools return structured JSON responses matching the CLI's JSON output format:
|
|
836
|
+
|
|
837
|
+
**Success:**
|
|
838
|
+
|
|
839
|
+
```json
|
|
840
|
+
{
|
|
841
|
+
"success": true,
|
|
842
|
+
"operation": "tool_name",
|
|
843
|
+
"data": {
|
|
844
|
+
// Tool-specific data
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
**Error:**
|
|
850
|
+
|
|
851
|
+
```json
|
|
852
|
+
{
|
|
853
|
+
"success": false,
|
|
854
|
+
"operation": "tool_name",
|
|
855
|
+
"error": {
|
|
856
|
+
"message": "Error message",
|
|
857
|
+
"code": 1,
|
|
858
|
+
"details": {}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
### Benefits
|
|
864
|
+
|
|
865
|
+
- **No Shell Access Required** - AI assistants can interact with httpcat without needing shell/terminal access
|
|
866
|
+
- **Structured Responses** - Consistent JSON output format for reliable parsing
|
|
867
|
+
- **Secure** - Private keys can be managed via environment variables or config
|
|
868
|
+
- **Always Up-to-Date** - Using `npx` ensures you always get the latest version
|
|
869
|
+
- **Zero Configuration** - Works out of the box with standard MCP clients
|
|
870
|
+
|
|
538
871
|
## Advanced Usage
|
|
539
872
|
|
|
540
873
|
### Environment Management
|
|
@@ -578,7 +911,7 @@ httpcat env use production
|
|
|
578
911
|
#### Predefined Environments
|
|
579
912
|
|
|
580
913
|
- **local** - `http://localhost:8787` (base-sepolia)
|
|
581
|
-
- **sepolia** - `https://agent.
|
|
914
|
+
- **sepolia** - `https://agent.402.cat` (base-sepolia)
|
|
582
915
|
|
|
583
916
|
#### Environment Priority
|
|
584
917
|
|
|
@@ -645,7 +978,7 @@ Config is stored at `~/.config/httpcat/config.json`:
|
|
|
645
978
|
{
|
|
646
979
|
"privateKey": "0x...",
|
|
647
980
|
"network": "base-sepolia",
|
|
648
|
-
"agentUrl": "https://agent.
|
|
981
|
+
"agentUrl": "https://agent.402.cat",
|
|
649
982
|
"facilitatorUrl": "https://facilitators.x402scan.com",
|
|
650
983
|
"defaultMaxPayment": "10.00",
|
|
651
984
|
"preferences": {
|
|
@@ -734,6 +1067,16 @@ Check your config:
|
|
|
734
1067
|
httpcat config --show
|
|
735
1068
|
```
|
|
736
1069
|
|
|
1070
|
+
### Check Wallet Balance
|
|
1071
|
+
|
|
1072
|
+
Use the balance command to check your wallet's ETH and USDC balances:
|
|
1073
|
+
|
|
1074
|
+
```bash
|
|
1075
|
+
httpcat balance
|
|
1076
|
+
```
|
|
1077
|
+
|
|
1078
|
+
This will show your wallet address, ETH balance (for gas fees), and USDC balance (for trading), with warnings if balances are low.
|
|
1079
|
+
|
|
737
1080
|
## Examples
|
|
738
1081
|
|
|
739
1082
|
### Complete Workflow
|
|
@@ -742,6 +1085,9 @@ httpcat config --show
|
|
|
742
1085
|
# Setup
|
|
743
1086
|
httpcat config
|
|
744
1087
|
|
|
1088
|
+
# Check your wallet balance
|
|
1089
|
+
httpcat balance
|
|
1090
|
+
|
|
745
1091
|
# Create a token
|
|
746
1092
|
httpcat create "Moon Cat" "MOON" --website https://mooncat.io
|
|
747
1093
|
|
|
@@ -805,5 +1151,5 @@ MIT
|
|
|
805
1151
|
## Support
|
|
806
1152
|
|
|
807
1153
|
- Report issues: https://github.com/hathbanger/httpcat-cli/issues
|
|
808
|
-
- httpcat agent: https://agent.
|
|
1154
|
+
- httpcat agent: https://agent.402.cat
|
|
809
1155
|
- x402 protocol: https://x402.org
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../src/commands/balance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAShC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,UAAU,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,CA8GzE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAGzD"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
3
|
+
import { formatEther } from "viem";
|
|
4
|
+
import { getUSDCBalance } from "x402/shared/evm";
|
|
5
|
+
import { evm } from "x402/types";
|
|
6
|
+
import { printCat } from "../interactive/art.js";
|
|
7
|
+
import { formatAddress, printWarning } from "../utils/formatting.js";
|
|
8
|
+
import inquirer from "inquirer";
|
|
9
|
+
/**
|
|
10
|
+
* Checks and displays wallet balances for a given private key.
|
|
11
|
+
* This mimics the behavior of promptForPrivateKey but without saving to config.
|
|
12
|
+
*/
|
|
13
|
+
export async function checkBalance(privateKey) {
|
|
14
|
+
let pk = privateKey;
|
|
15
|
+
// If no private key provided, prompt for it (same as other commands)
|
|
16
|
+
if (!pk) {
|
|
17
|
+
console.log();
|
|
18
|
+
// Show wizard cat
|
|
19
|
+
printCat("wizard");
|
|
20
|
+
console.log(chalk.bold.cyan("🔐 Checking wallet balance...\n"));
|
|
21
|
+
// Prompt for private key with password masking
|
|
22
|
+
const answers = await inquirer.prompt([
|
|
23
|
+
{
|
|
24
|
+
type: "password",
|
|
25
|
+
name: "privateKey",
|
|
26
|
+
message: "Enter your private key:",
|
|
27
|
+
mask: "•",
|
|
28
|
+
validate: (input) => {
|
|
29
|
+
if (!input) {
|
|
30
|
+
return "Private key is required";
|
|
31
|
+
}
|
|
32
|
+
if (!input.startsWith("0x")) {
|
|
33
|
+
return "Private key must start with 0x";
|
|
34
|
+
}
|
|
35
|
+
if (input.length !== 66) {
|
|
36
|
+
return "Private key must be 66 characters long (0x + 64 hex chars)";
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
]);
|
|
42
|
+
pk = answers.privateKey;
|
|
43
|
+
console.log(chalk.green("✓ Private key validated!\n"));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// If private key provided, still show the wizard cat and header
|
|
47
|
+
console.log();
|
|
48
|
+
printCat("wizard");
|
|
49
|
+
console.log(chalk.bold.cyan("🔐 Checking wallet balance...\n"));
|
|
50
|
+
}
|
|
51
|
+
// Derive wallet address
|
|
52
|
+
console.log(chalk.dim("📍 Deriving wallet address..."));
|
|
53
|
+
const account = privateKeyToAccount(pk);
|
|
54
|
+
const address = account.address;
|
|
55
|
+
console.log(chalk.dim(" Wallet:"), chalk.cyan(formatAddress(address, 12)));
|
|
56
|
+
console.log();
|
|
57
|
+
// Check balances
|
|
58
|
+
console.log(chalk.dim("💰 Checking balances on Base Sepolia...\n"));
|
|
59
|
+
try {
|
|
60
|
+
// Create signer to check balances
|
|
61
|
+
const signer = evm.createSignerSepolia(pk);
|
|
62
|
+
// Check ETH balance
|
|
63
|
+
const ethBalance = await signer.getBalance({ address });
|
|
64
|
+
const ethFormatted = formatEther(ethBalance);
|
|
65
|
+
// Check USDC balance
|
|
66
|
+
const usdcBalance = await getUSDCBalance(signer, address);
|
|
67
|
+
const usdcFormatted = (Number(usdcBalance) / 10 ** 6).toFixed(2);
|
|
68
|
+
// Display balances
|
|
69
|
+
console.log(chalk.dim(" ETH: "), chalk.yellow(`${ethFormatted} ETH`));
|
|
70
|
+
console.log(chalk.dim(" USDC:"), chalk.green(`$${usdcFormatted} USDC`));
|
|
71
|
+
console.log();
|
|
72
|
+
// Show warnings if balances are low
|
|
73
|
+
const ethNum = Number(ethFormatted);
|
|
74
|
+
const usdcNum = Number(usdcFormatted);
|
|
75
|
+
if (ethNum < 0.001 && usdcNum < 1) {
|
|
76
|
+
printWarning("Low balances detected!");
|
|
77
|
+
console.log(chalk.dim(" You need Base Sepolia ETH for gas fees"));
|
|
78
|
+
console.log(chalk.dim(" You need Base Sepolia USDC for trading\n"));
|
|
79
|
+
}
|
|
80
|
+
else if (ethNum < 0.001) {
|
|
81
|
+
printWarning("Low ETH balance - you may not have enough for gas fees\n");
|
|
82
|
+
}
|
|
83
|
+
else if (usdcNum < 1) {
|
|
84
|
+
printWarning("Low USDC balance - you may not have enough for trades\n");
|
|
85
|
+
}
|
|
86
|
+
// Always show reminder about requirements
|
|
87
|
+
console.log(chalk.yellow("⚠️ Important:"));
|
|
88
|
+
console.log(chalk.dim(" Ensure you have Base Sepolia ETH (for gas fees)"));
|
|
89
|
+
console.log(chalk.dim(" and Base Sepolia USDC (for trading) in this wallet!\n"));
|
|
90
|
+
return {
|
|
91
|
+
address,
|
|
92
|
+
ethBalance: ethBalance.toString(),
|
|
93
|
+
usdcBalance: usdcBalance.toString(),
|
|
94
|
+
ethFormatted,
|
|
95
|
+
usdcFormatted,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
// If balance check fails, just warn but continue
|
|
100
|
+
console.log(chalk.yellow("⚠️ Could not check balances (network may be slow)"));
|
|
101
|
+
console.log(chalk.dim(" Make sure you have Base Sepolia ETH and USDC!\n"));
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Display balance information (for JSON output)
|
|
107
|
+
*/
|
|
108
|
+
export function displayBalance(balance) {
|
|
109
|
+
// This is mainly for JSON mode, but we already display in checkBalance
|
|
110
|
+
// So this is a no-op for interactive mode
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=balance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/commands/balance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OA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