@moonpay/cli 0.3.2 → 0.3.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moonpay/cli",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,8 +21,13 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@solana/web3.js": "^1.98.4",
24
+ "@x402/axios": "^2.4.0",
25
+ "@x402/core": "^2.4.0",
26
+ "@x402/svm": "^2.4.0",
27
+ "axios": "^1.13.5",
24
28
  "bs58": "^6.0.0",
25
29
  "commander": "^12.1.0",
30
+ "tweetnacl": "^1.0.3",
26
31
  "zod": "^3.25.76"
27
32
  },
28
33
  "devDependencies": {
@@ -1,14 +1,25 @@
1
1
  ---
2
2
  name: moonpay-auth
3
- description: Authenticate and manage local wallets with MoonPay CLI. Use when you need to log in, check auth state, or manage wallets for signing transactions.
3
+ description: Set up the MoonPay CLI, authenticate, and manage local wallets. Use when commands fail, for login, or to create/import wallets.
4
4
  tags: [setup]
5
5
  ---
6
6
 
7
- # MoonPay auth
7
+ # MoonPay auth and setup
8
8
 
9
- ## Goal
9
+ ## Install
10
10
 
11
- Set up authentication and local wallet management for the MoonPay CLI (`mp`).
11
+ ```bash
12
+ npm i -g @moonpay/cli
13
+ ```
14
+
15
+ This installs the `mp` (and `moonpay`) binary globally.
16
+
17
+ ## Verify installation
18
+
19
+ ```bash
20
+ mp --version
21
+ mp --help
22
+ ```
12
23
 
13
24
  ## Auth commands
14
25
 
@@ -39,7 +50,6 @@ mp wallet list
39
50
 
40
51
  # Get wallet details (by name or address)
41
52
  mp wallet retrieve --wallet "my-wallet"
42
- mp wallet retrieve --wallet <address>
43
53
 
44
54
  # Delete a wallet (irreversible)
45
55
  mp wallet delete --wallet "my-wallet" --confirm
@@ -52,13 +62,37 @@ mp wallet delete --wallet "my-wallet" --confirm
52
62
  3. Run `mp wallet list` to see local wallets.
53
63
  4. If no wallets, create one: `mp wallet create --name "default"`.
54
64
 
55
- ## Notes
65
+ ## Config locations
66
+
67
+ - **Credentials:** `~/.config/moonpay/credentials.json` (OAuth tokens)
68
+ - **Config:** `~/.config/moonpay/config.json` (base URL, client ID)
69
+ - **Wallets:** `~/.config/moonpay/wallets/` (local keypairs, 0600 permissions)
70
+
71
+ ## Output formats
72
+
73
+ ```bash
74
+ mp -f json wallet list # Pretty JSON (default)
75
+ mp -f compact wallet list # Single-line JSON
76
+ mp -f table wallet list # ASCII table
77
+ ```
78
+
79
+ ## Environment for scripts/agents
80
+
81
+ If running `mp` from a script or agent subprocess, ensure PATH includes the npm global bin:
82
+
83
+ ```bash
84
+ export PATH="$(npm config get prefix)/bin:$PATH"
85
+ mp --version
86
+ ```
87
+
88
+ ## Troubleshooting
56
89
 
57
- - Credentials: `~/.config/moonpay/credentials.json`
58
- - Wallets: `~/.config/moonpay/wallets/`
90
+ - **"command not found"** — `npm i -g @moonpay/cli` and check PATH.
91
+ - **401 / auth errors** — Run `mp login`.
92
+ - **"fetch failed"** — Check network connectivity to agents.moonpay.com.
59
93
  - Tokens auto-refresh on expiry. If refresh fails, run `mp login` again.
60
94
 
61
95
  ## Related skills
62
96
 
63
- - **moonpay-env** — Environment and PATH setup.
64
97
  - **moonpay-swap-tokens** — Swap tokens using local wallets.
98
+ - **moonpay-check-wallet** — Check wallet balances.
@@ -28,7 +28,7 @@ mp buy \
28
28
 
29
29
  1. User: "I want to buy 1 SOL with my credit card."
30
30
  2. Run: `mp buy --token sol --amount 1 --wallet <address> --email user@example.com`
31
- 3. Return the checkout URL for the user to open in their browser.
31
+ 3. Open the returned checkout URL in the user's browser so they can complete the purchase.
32
32
 
33
33
  ## Notes
34
34
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: moonpay-check-wallet
3
- description: Check wallet balances and holdings. Use for "what's in my wallet", portfolio breakdown, token balances, and USD values.
3
+ description: Check wallet balances and holdings. Use for "what's in my wallet", portfolio breakdown, token balances, allocation percentages, and USD values.
4
4
  tags: [portfolio]
5
5
  ---
6
6
 
@@ -8,7 +8,7 @@ tags: [portfolio]
8
8
 
9
9
  ## Goal
10
10
 
11
- List all token balances held in a wallet with current USD values.
11
+ List all token balances in a wallet with USD values, allocation breakdown, and total portfolio value.
12
12
 
13
13
  ## Commands
14
14
 
@@ -19,27 +19,39 @@ mp token balance list --wallet <address> --chain solana
19
19
  # List balances for an EVM wallet
20
20
  mp token balance list --wallet 0x... --chain ethereum
21
21
  mp token balance list --wallet 0x... --chain base
22
+
23
+ # Find wallet address
24
+ mp wallet list
22
25
  ```
23
26
 
24
27
  ## Supported chains
25
28
 
26
29
  `solana`, `ethereum`, `base`, `polygon`, `arbitrum`, `optimism`
27
30
 
28
- ## Output handling
31
+ ## Workflow
29
32
 
30
- - Summarize top holdings by USD value.
31
- - Call out small dust balances separately.
32
- - Sum `balance.value` across items for total portfolio value.
33
+ 1. Run `mp wallet list` to find the user's wallet address.
34
+ 2. Run `mp token balance list --wallet <address> --chain solana`.
35
+ 3. Sort holdings by USD value descending.
36
+ 4. Calculate allocation percentages (each holding's USD / total USD).
37
+ 5. Present: top holdings, dust balances, total value.
33
38
 
34
39
  ## Example flow
35
40
 
36
- 1. User: "What's in my wallet?"
37
- 2. Run `mp wallet list` to find the user's wallet address.
38
- 3. Run `mp token balance list --wallet <address> --chain solana`.
39
- 4. Present holdings sorted by value.
41
+ 1. User: "What's in my wallet?" or "Generate a portfolio report."
42
+ 2. Run: `mp token balance list --wallet <address> --chain solana`
43
+ 3. Present:
44
+ - **Total value:** $168.05
45
+ - **SOL** — 0.61 ($51.87) — 30.9%
46
+ - **WBTC** — 0.00127 ($85.48) — 50.9%
47
+ - **USDC** — 29.81 ($29.81) — 17.7%
48
+ - **Dust:** none
49
+
50
+ ## Output formats
51
+
52
+ Use `mp -f table token balance list ...` for a quick table view, or `mp -f json ...` for programmatic processing.
40
53
 
41
54
  ## Related skills
42
55
 
43
56
  - **moonpay-auth** — Set up wallets if none exist.
44
- - **moonpay-portfolio-report** — Full report with allocation percentages.
45
- - **moonpay-rug-check** — Risk-check a token before buying.
57
+ - **moonpay-discover-tokens** — Research specific tokens in the portfolio.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: moonpay-discover-tokens
3
- description: Search for tokens and retrieve detailed market data. Use to find token addresses, check prices, volume, liquidity, and trading activity.
3
+ description: Search for tokens, check prices, get trading briefs, and evaluate risk. Use for token research, "is this token safe?", price checks, and market analysis.
4
4
  tags: [research]
5
5
  ---
6
6
 
@@ -8,26 +8,20 @@ tags: [research]
8
8
 
9
9
  ## Goal
10
10
 
11
- Search for tokens by name/symbol and retrieve detailed market data including price, volume, liquidity, and trading activity.
11
+ Search for tokens, retrieve market data, generate trading briefs, and assess risk — all from one skill.
12
12
 
13
13
  ## Commands
14
14
 
15
- ### Search for tokens
16
-
17
15
  ```bash
18
- mp token search --query "SOL" --chain solana
19
- mp token search --query "BONK" --chain solana --limit 3
20
- ```
21
-
22
- Returns matching tokens with market data (price, volume, liquidity, trades, buys/sells, unique wallets).
16
+ # Search by name or symbol
17
+ mp token search --query "BONK" --chain solana
23
18
 
24
- ### Retrieve token details
25
-
26
- ```bash
19
+ # Get full details for a specific token
27
20
  mp token retrieve --token <mint-address> --chain solana
28
- ```
29
21
 
30
- Returns token metadata (name, symbol, decimals, image) and market data.
22
+ # See what's trending
23
+ mp token trending list --chain solana
24
+ ```
31
25
 
32
26
  ## Supported chains
33
27
 
@@ -37,18 +31,46 @@ Returns token metadata (name, symbol, decimals, image) and market data.
37
31
 
38
32
  1. Search by name/symbol with `mp token search`.
39
33
  2. Use the returned address to get details with `mp token retrieve`.
40
- 3. Evaluate risk with **moonpay-rug-check** for unknown tokens.
41
- 4. Proceed to buy/swap if desired.
34
+ 3. Assess risk and generate a brief from the market data.
42
35
 
43
- ## Example flow
36
+ ## Trading brief format
44
37
 
38
+ When the user wants a brief or analysis, format the output like:
39
+
40
+ ```
41
+ BONK (DezX...pump) — mcap $850M, liq $12M, vol24 $45M
42
+ momentum: 1h +2.3%, 4h -0.5%, 24h +8.1%
43
+ activity: trades24 12,500, wallets24 3,200
44
+ note: healthy volume, broad wallet distribution
45
+ ```
46
+
47
+ ## Risk assessment
48
+
49
+ When the user asks "is this safe?" or wants to evaluate an unknown token, check these indicators from the market data:
50
+
51
+ 1. **Liquidity** — Under $10K is a red flag.
52
+ 2. **Volume pattern** — Sudden spikes with no context = suspicious.
53
+ 3. **Buy/sell ratio** — Extremely one-sided trading = dump risk.
54
+ 4. **Unique wallets** — Very few unique wallets = concentrated activity.
55
+ 5. **Market cap vs liquidity** — Huge mcap with tiny liquidity = inflated, hard to exit.
56
+ 6. **Price volatility** — Extreme short-term swings (>50% in 1h) = high risk.
57
+
58
+ Present a risk summary with traffic-light ratings. This is a heuristic check based on market data, not a smart contract audit — always recommend caution with unknown tokens.
59
+
60
+ ## Example flows
61
+
62
+ **Price check:**
45
63
  1. User: "What's the price of BONK?"
46
64
  2. Run: `mp token search --query "BONK" --chain solana`
47
65
  3. Present: name, symbol, price, 24h change, volume, liquidity.
48
66
 
67
+ **Risk check:**
68
+ 1. User: "Is BONK safe to buy?"
69
+ 2. Run: `mp token search --query "BONK" --chain solana` then `mp token retrieve --token <address> --chain solana`
70
+ 3. Present risk indicators with ratings.
71
+
49
72
  ## Related skills
50
73
 
51
- - **moonpay-token-brief** — Detailed trading brief for a specific token.
52
- - **moonpay-rug-check** — Risk assessment for unknown tokens.
53
- - **moonpay-swap-tokens** — Swap after research.
74
+ - **moonpay-swap-tokens** — Trade after research.
54
75
  - **moonpay-buy-crypto** — Buy with fiat after research.
76
+ - **moonpay-check-wallet** — Check your current holdings.
@@ -4,7 +4,7 @@ description: A series of missions that walk through every MoonPay CLI capability
4
4
  tags: [setup]
5
5
  ---
6
6
 
7
- # MoonPay Orientation
7
+ # MoonPay Missions
8
8
 
9
9
  Walk the user through a series of missions. Complete each one before moving to the next. After each mission, give a brief summary of what they just did and what's next.
10
10
 
@@ -27,9 +27,17 @@ Tell the user their email, wallet address, and that this wallet's private key li
27
27
 
28
28
  ## Mission 2: Recon
29
29
 
30
- **Goal:** Search for a token and pull up its intel.
30
+ **Goal:** See what's trending and research a token.
31
31
 
32
- Ask the user to pick a token (or default to SOL). Then:
32
+ First, check what's hot:
33
+
34
+ ```bash
35
+ mp token trending list --chain solana --limit 5 --page 1
36
+ ```
37
+
38
+ Present the top trending tokens with price, 24h change, and volume.
39
+
40
+ Then ask the user to pick a token to research (or default to SOL):
33
41
 
34
42
  ```bash
35
43
  mp token search --query "<token>" --chain solana
@@ -71,13 +79,13 @@ If no, move on. Either way, explain what just happened: the transaction was buil
71
79
 
72
80
  ## Mission 5: Buy with Fiat
73
81
 
74
- **Goal:** Generate a fiat checkout link.
82
+ **Goal:** Generate a fiat checkout link and open it.
75
83
 
76
84
  ```bash
77
85
  mp buy --token sol --amount 1 --wallet <address> --email <email-from-mission-1>
78
86
  ```
79
87
 
80
- Present the checkout URL. Explain: this opens MoonPay's fiat gateway where they can pay with a card or bank transfer. Tokens get sent to their wallet.
88
+ Present the checkout URL and open it in the user's browser. Explain: this is MoonPay's fiat gateway where they can buy crypto with a card or bank transfer. Tokens get sent directly to their wallet.
81
89
 
82
90
  ## Mission 6: Message Signing
83
91
 
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: moonpay-x402
3
+ description: Make paid API requests to x402-protected endpoints. Automatically handles payment with your local wallet.
4
+ tags: [payments, api]
5
+ ---
6
+
7
+ # x402 paid API requests
8
+
9
+ ## Goal
10
+
11
+ Make HTTP requests to x402-protected endpoints. The CLI automatically detects 402 Payment Required responses, builds and signs a Solana payment transaction with your local wallet, and retries the request with the payment proof.
12
+
13
+ ## Command
14
+
15
+ ```bash
16
+ mp x402 request \
17
+ --method POST \
18
+ --url <x402-endpoint-url> \
19
+ --body '<json-body>' \
20
+ --wallet <wallet-name-or-address>
21
+ ```
22
+
23
+ ## Available x402 endpoints
24
+
25
+ | Endpoint | Cost | Input |
26
+ |----------|------|-------|
27
+ | `https://agents.moonpay.com/api/x402/tools/market_digest_retrieve` | $0.01 | `{"chain": "solana"}` |
28
+ | `https://agents.moonpay.com/api/x402/tools/token_digest_retrieve` | $0.01 | `{"token": "<mint>", "chain": "solana"}` |
29
+ | `https://agents.moonpay.com/api/x402/tools/wallet_digest_retrieve` | $0.01 | `{"wallet": "<address>", "chain": "solana"}` |
30
+
31
+ ## Example flow
32
+
33
+ 1. User: "Get me a market digest for Solana."
34
+ 2. Run: `mp x402 request --method POST --url "https://agents.moonpay.com/api/x402/tools/market_digest_retrieve" --body '{"chain": "solana"}' --wallet my-wallet`
35
+ 3. The CLI handles the 402 payment flow automatically and returns the digest.
36
+
37
+ ## Notes
38
+
39
+ - Requires a local wallet with USDC to pay for requests.
40
+ - Payments are on Solana mainnet.
41
+ - If the tool request fails (status >= 400), the payment is not settled — you don't pay for errors.
42
+ - Use **moonpay-auth** to set up a local wallet first.
43
+
44
+ ## Related skills
45
+
46
+ - **moonpay-auth** — Create or import a local wallet.
47
+ - **moonpay-check-wallet** — Check your wallet balance before making paid requests.
@@ -1,57 +0,0 @@
1
- ---
2
- name: moonpay-env
3
- description: Ensure the MoonPay CLI environment is set up correctly. Use when commands fail due to PATH or config issues.
4
- tags: [setup]
5
- ---
6
-
7
- # MoonPay environment setup
8
-
9
- ## Install
10
-
11
- ```bash
12
- npm i -g @moonpay/cli
13
- ```
14
-
15
- This installs the `mp` (and `moonpay`) binary globally.
16
-
17
- ## Verify installation
18
-
19
- ```bash
20
- mp --version
21
- mp --help
22
- ```
23
-
24
- ## Config locations
25
-
26
- - **Credentials:** `~/.config/moonpay/credentials.json` (OAuth tokens)
27
- - **Config:** `~/.config/moonpay/config.json` (base URL, client ID)
28
- - **Wallets:** `~/.config/moonpay/wallets/` (local keypairs, 0600 permissions)
29
-
30
- ## Environment for scripts/agents
31
-
32
- If running `mp` from a script or agent subprocess, ensure PATH includes the npm global bin:
33
-
34
- ```bash
35
- export PATH="$(npm config get prefix)/bin:$PATH"
36
- mp --version
37
- ```
38
-
39
- ## Output formats
40
-
41
- The CLI supports three output formats via `-f`:
42
-
43
- ```bash
44
- mp -f json wallet list # Pretty JSON (default)
45
- mp -f compact wallet list # Single-line JSON
46
- mp -f table wallet list # ASCII table
47
- ```
48
-
49
- ## Troubleshooting
50
-
51
- - **"command not found"** — `npm i -g @moonpay/cli` and check PATH.
52
- - **401 / auth errors** — Run `mp login`.
53
- - **"fetch failed"** — Check network connectivity to agents.moonpay.com.
54
-
55
- ## Related skills
56
-
57
- - **moonpay-auth** — Login, logout, wallet management.
@@ -1,49 +0,0 @@
1
- ---
2
- name: moonpay-portfolio-report
3
- description: Generate a portfolio summary with holdings, allocation breakdown, and USD totals. Use when the user asks for a portfolio overview or report.
4
- tags: [portfolio]
5
- ---
6
-
7
- # Portfolio report
8
-
9
- ## Goal
10
-
11
- Produce a structured portfolio report for a wallet: holdings with USD values, allocation percentages, and total portfolio value.
12
-
13
- ## Commands
14
-
15
- ```bash
16
- # Get all balances
17
- mp token balance list --wallet <address> --chain solana
18
-
19
- # Get details on a specific token (optional)
20
- mp token retrieve --token <mint-address> --chain solana
21
- ```
22
-
23
- ## Workflow
24
-
25
- 1. Run `mp wallet list` to find the user's wallet address.
26
- 2. Call `mp token balance list` with the wallet and chain.
27
- 3. Sort holdings by USD value descending.
28
- 4. Calculate allocation percentages (each holding's USD / total USD).
29
- 5. Format into sections: Top Holdings, Dust Balances, Total Value.
30
-
31
- ## Example flow
32
-
33
- 1. User: "Generate a portfolio report."
34
- 2. Run: `mp token balance list --wallet <address> --chain solana`
35
- 3. Present:
36
- - **Total value:** $168.05
37
- - **SOL** — 0.61 ($51.87) — 30.9%
38
- - **WBTC** — 0.00127 ($85.48) — 50.9%
39
- - **USDC** — 29.81 ($29.81) — 17.7%
40
- - **Dust:** none
41
-
42
- ## Output formats
43
-
44
- Use `mp -f table token balance list ...` for a quick table view, or `mp -f json ...` for programmatic processing.
45
-
46
- ## Related skills
47
-
48
- - **moonpay-check-wallet** — Quick balance check (this skill builds on it).
49
- - **moonpay-discover-tokens** — Research specific tokens in the portfolio.
@@ -1,59 +0,0 @@
1
- ---
2
- name: moonpay-rug-check
3
- description: Analyze a token for rug pull risk indicators. Use when the user asks "is this token safe?" or wants to evaluate an unknown token before buying.
4
- tags: [research]
5
- ---
6
-
7
- # Rug check
8
-
9
- ## Goal
10
-
11
- Assess a token's risk profile using available market data. Give the user a clear risk summary before they buy.
12
-
13
- ## Commands
14
-
15
- ```bash
16
- # Resolve token address
17
- mp token search --query "BONK" --chain solana
18
-
19
- # Get market data
20
- mp token retrieve --token <mint-address> --chain solana
21
- ```
22
-
23
- ## Risk indicators to check
24
-
25
- 1. **Liquidity** — Low liquidity = easy to manipulate. Under $10K is a red flag.
26
- 2. **Volume pattern** — Compare 5m/1h/4h/24h volume. Sudden spikes with no context = suspicious.
27
- 3. **Buy/sell ratio** — Heavy sell pressure or extremely one-sided trading = dump risk.
28
- 4. **Unique wallets** — Very few unique wallets trading = concentrated activity.
29
- 5. **Market cap vs liquidity** — Huge mcap with tiny liquidity = inflated, hard to exit.
30
- 6. **Price volatility** — Extreme short-term swings (>50% in 1h) = high risk.
31
-
32
- ## Workflow
33
-
34
- 1. Resolve token via `mp token search` if user provides name/symbol.
35
- 2. Call `mp token retrieve` for market data.
36
- 3. Analyze against risk indicators above.
37
- 4. Present a risk summary with traffic-light ratings.
38
-
39
- ## Example flow
40
-
41
- 1. User: "Is BONK safe to buy?"
42
- 2. Search: `mp token search --query "BONK" --chain solana`
43
- 3. Retrieve: `mp token retrieve --token <address> --chain solana`
44
- 4. Present:
45
- - Liquidity: $12M (green)
46
- - Volume 24h: $45M (green)
47
- - Buy/sell ratio: balanced (green)
48
- - Unique wallets 24h: 3,200 (green)
49
- - **Overall: Low risk**
50
-
51
- ## Notes
52
-
53
- - This is a heuristic check based on market data, not a smart contract audit.
54
- - Always recommend caution with unknown tokens regardless of data.
55
-
56
- ## Related skills
57
-
58
- - **moonpay-discover-tokens** — Token search and research.
59
- - **moonpay-token-brief** — Detailed market data brief.
@@ -1,47 +0,0 @@
1
- ---
2
- name: moonpay-token-brief
3
- description: Generate a concise trading brief for a token with market cap, liquidity, volume, momentum, and activity metrics.
4
- tags: [research]
5
- ---
6
-
7
- # Token brief
8
-
9
- ## Goal
10
-
11
- Given a token address, produce a compact brief with key trading metrics.
12
-
13
- ## Command
14
-
15
- ```bash
16
- mp token retrieve --token <mint-address> --chain solana
17
- ```
18
-
19
- ## What to include
20
-
21
- - **Identity:** name, symbol, address
22
- - **Market data:**
23
- - Market cap, liquidity, volume (24h)
24
- - Price change % (5m, 1h, 4h, 12h, 24h)
25
- - Trades, buys/sells, unique wallets (5m through 24h)
26
- - **Risk notes:** thin liquidity, cooling volume, extreme swings
27
-
28
- ## Example output format
29
-
30
- ```
31
- BONK (DezX...pump) — mcap $850M, liq $12M, vol24 $45M
32
- momentum: 1h +2.3%, 4h -0.5%, 24h +8.1%
33
- activity: trades24 12,500, wallets24 3,200
34
- note: healthy volume, broad wallet distribution
35
- ```
36
-
37
- ## Workflow
38
-
39
- 1. If user provides name/symbol, resolve with `mp token search`.
40
- 2. Call `mp token retrieve` for the full data.
41
- 3. Format into a brief.
42
-
43
- ## Related skills
44
-
45
- - **moonpay-discover-tokens** — Search if you only have a name/symbol.
46
- - **moonpay-rug-check** — Risk assessment for unknown tokens.
47
- - **moonpay-swap-tokens** — Trade after analysis.