x402-bazaar 3.0.0 → 3.2.1
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 +67 -4
- package/bin/cli.js +109 -109
- package/package.json +50 -50
- package/src/commands/call.js +419 -305
- package/src/commands/init.js +566 -565
- package/src/commands/wallet.js +217 -216
- package/src/lib/payment.js +149 -23
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# x402-bazaar
|
|
2
2
|
|
|
3
|
+
   
|
|
4
|
+
|
|
3
5
|
> Connect your AI agent to the x402 Bazaar marketplace in one command.
|
|
4
6
|
|
|
5
7
|
x402 Bazaar is an autonomous marketplace where AI agents buy and sell API services using the HTTP 402 protocol with USDC payments on Base L2.
|
|
@@ -56,6 +58,60 @@ npx x402-bazaar status
|
|
|
56
58
|
npx x402-bazaar status --server-url https://your-server.com
|
|
57
59
|
```
|
|
58
60
|
|
|
61
|
+
### `npx x402-bazaar list`
|
|
62
|
+
|
|
63
|
+
List all available services on the marketplace. Supports filters.
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# List all services
|
|
67
|
+
npx x402-bazaar list
|
|
68
|
+
|
|
69
|
+
# Filter by blockchain network
|
|
70
|
+
npx x402-bazaar list --chain base
|
|
71
|
+
npx x402-bazaar list --chain skale
|
|
72
|
+
|
|
73
|
+
# Filter by category
|
|
74
|
+
npx x402-bazaar list --category ai
|
|
75
|
+
npx x402-bazaar list --category search
|
|
76
|
+
|
|
77
|
+
# Show only free services
|
|
78
|
+
npx x402-bazaar list --free
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### `npx x402-bazaar search <query>`
|
|
82
|
+
|
|
83
|
+
Search for a specific service by keyword.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npx x402-bazaar search "weather"
|
|
87
|
+
npx x402-bazaar search "image generation"
|
|
88
|
+
npx x402-bazaar search "sentiment analysis"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### `npx x402-bazaar call <url> [--key wallet.json]`
|
|
92
|
+
|
|
93
|
+
Call an API endpoint with automatic USDC payment. The CLI handles the HTTP 402 flow transparently.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Call with default wallet
|
|
97
|
+
npx x402-bazaar call https://x402-api.onrender.com/api/weather?city=Paris
|
|
98
|
+
|
|
99
|
+
# Call with a specific wallet key file
|
|
100
|
+
npx x402-bazaar call https://x402-api.onrender.com/api/search?q=AI --key ./wallet.json
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### `npx x402-bazaar wallet [--create|--balance]`
|
|
104
|
+
|
|
105
|
+
Manage the agent wallet: create a new one or check its USDC balance.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Create a new agent wallet (generates a key file)
|
|
109
|
+
npx x402-bazaar wallet --create
|
|
110
|
+
|
|
111
|
+
# Check the USDC balance of the current wallet
|
|
112
|
+
npx x402-bazaar wallet --balance
|
|
113
|
+
```
|
|
114
|
+
|
|
59
115
|
## Supported Environments
|
|
60
116
|
|
|
61
117
|
| Environment | Config Location |
|
|
@@ -89,11 +145,18 @@ x402 Bazaar is a marketplace where AI agents autonomously trade API services:
|
|
|
89
145
|
- Node.js >= 18
|
|
90
146
|
- npm or npx
|
|
91
147
|
|
|
92
|
-
##
|
|
148
|
+
## Ecosystem
|
|
149
|
+
|
|
150
|
+
| Repository | Description |
|
|
151
|
+
|---|---|
|
|
152
|
+
| **[x402-backend](https://github.com/Wintyx57/x402-backend)** | API server, 69 native endpoints, payment middleware, MCP server |
|
|
153
|
+
| **[x402-frontend](https://github.com/Wintyx57/x402-frontend)** | React + TypeScript UI, wallet connect |
|
|
154
|
+
| **[x402-bazaar-cli](https://github.com/Wintyx57/x402-bazaar-cli)** | `npx x402-bazaar` -- CLI with 7 commands (this repo) |
|
|
155
|
+
| **[x402-sdk](https://github.com/Wintyx57/x402-sdk)** | TypeScript SDK for AI agents |
|
|
156
|
+
| **[x402-langchain](https://github.com/Wintyx57/x402-langchain)** | Python LangChain tools |
|
|
157
|
+
| **[x402-fast-monetization-template](https://github.com/Wintyx57/x402-fast-monetization-template)** | FastAPI template to monetize any Python function |
|
|
93
158
|
|
|
94
|
-
|
|
95
|
-
- Dashboard: https://x402-api.onrender.com/dashboard
|
|
96
|
-
- GitHub: https://github.com/Wintyx57
|
|
159
|
+
**Live:** [x402bazaar.org](https://x402bazaar.org) | **API:** [x402-api.onrender.com](https://x402-api.onrender.com)
|
|
97
160
|
|
|
98
161
|
## License
|
|
99
162
|
|
package/bin/cli.js
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import { initCommand } from '../src/commands/init.js';
|
|
5
|
-
import { configCommand } from '../src/commands/config.js';
|
|
6
|
-
import { statusCommand } from '../src/commands/status.js';
|
|
7
|
-
import { listCommand } from '../src/commands/list.js';
|
|
8
|
-
import { searchCommand } from '../src/commands/search.js';
|
|
9
|
-
import { callCommand } from '../src/commands/call.js';
|
|
10
|
-
import { walletCommand } from '../src/commands/wallet.js';
|
|
11
|
-
import chalk from 'chalk';
|
|
12
|
-
|
|
13
|
-
// Global error handler
|
|
14
|
-
process.on('unhandledRejection', (err) => {
|
|
15
|
-
console.error('');
|
|
16
|
-
console.error(chalk.red('Error: ' + (err.message || err)));
|
|
17
|
-
if (err.code === 'ERR_MODULE_NOT_FOUND') {
|
|
18
|
-
console.error(chalk.dim(' Run: npm install'));
|
|
19
|
-
}
|
|
20
|
-
process.exit(1);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const program = new Command();
|
|
24
|
-
|
|
25
|
-
program
|
|
26
|
-
.name('x402-bazaar')
|
|
27
|
-
.description(chalk.hex('#FF9900')('x402 Bazaar') + ' — Connect your AI agent to the marketplace in one command')
|
|
28
|
-
.version('3.
|
|
29
|
-
|
|
30
|
-
program
|
|
31
|
-
.command('init')
|
|
32
|
-
.description('Set up x402 Bazaar MCP server (detect environment, configure wallet, generate config)')
|
|
33
|
-
.option('--env <environment>', 'Force environment (claude-desktop, cursor, claude-code, vscode-continue, generic)')
|
|
34
|
-
.option('--no-wallet', 'Skip wallet configuration (read-only mode)')
|
|
35
|
-
.option('--server-url <url>', 'Custom server URL', 'https://x402-api.onrender.com')
|
|
36
|
-
.option('--network <network>', 'Network: mainnet or testnet'
|
|
37
|
-
.option('--budget <amount>', 'Max USDC budget per session', '1.00')
|
|
38
|
-
.action(initCommand);
|
|
39
|
-
|
|
40
|
-
program
|
|
41
|
-
.command('config')
|
|
42
|
-
.description('Generate MCP configuration file for your environment')
|
|
43
|
-
.option('--env <environment>', 'Target environment (claude-desktop, cursor, claude-code, vscode-continue, generic)')
|
|
44
|
-
.option('--output <path>', 'Output file path')
|
|
45
|
-
.option('--server-url <url>', 'Custom server URL', 'https://x402-api.onrender.com')
|
|
46
|
-
.option('--network <network>', 'Network: mainnet or testnet'
|
|
47
|
-
.option('--budget <amount>', 'Max USDC budget per session', '1.00')
|
|
48
|
-
.action(configCommand);
|
|
49
|
-
|
|
50
|
-
program
|
|
51
|
-
.command('status')
|
|
52
|
-
.description('Check connection to x402 Bazaar marketplace')
|
|
53
|
-
.option('--server-url <url>', 'Server URL to check', 'https://x402-api.onrender.com')
|
|
54
|
-
.action(statusCommand);
|
|
55
|
-
|
|
56
|
-
program
|
|
57
|
-
.command('list')
|
|
58
|
-
.description('List all services on x402 Bazaar')
|
|
59
|
-
.option('--chain <chain>', 'Filter by chain (base or skale)')
|
|
60
|
-
.option('--category <category>', 'Filter by category (ai, data, weather, etc.)')
|
|
61
|
-
.option('--free', 'Show only free services')
|
|
62
|
-
.option('--server-url <url>', 'Server URL', 'https://x402-api.onrender.com')
|
|
63
|
-
.action(listCommand);
|
|
64
|
-
|
|
65
|
-
program
|
|
66
|
-
.command('search <query>')
|
|
67
|
-
.description('Search for services by keyword')
|
|
68
|
-
.option('--server-url <url>', 'Server URL', 'https://x402-api.onrender.com')
|
|
69
|
-
.action(searchCommand);
|
|
70
|
-
|
|
71
|
-
program
|
|
72
|
-
.command('call <endpoint>')
|
|
73
|
-
.description('Call a marketplace endpoint with automatic x402 payment')
|
|
74
|
-
.option('--param <key=value>', 'Add parameter (can be used multiple times)', (value, previous) => {
|
|
75
|
-
return previous ? [...previous, value] : [value];
|
|
76
|
-
}, [])
|
|
77
|
-
.option('--key <privateKey>', 'Private key for auto-payment
|
|
78
|
-
.option('--server-url <url>', 'Server URL', 'https://x402-api.onrender.com')
|
|
79
|
-
.action(callCommand);
|
|
80
|
-
|
|
81
|
-
program
|
|
82
|
-
.command('wallet')
|
|
83
|
-
.description('Check USDC wallet balance or generate a new wallet')
|
|
84
|
-
.option('--address <address>', 'Ethereum address to check')
|
|
85
|
-
.option('--setup', 'Generate a new wallet for auto-payment')
|
|
86
|
-
.action(walletCommand);
|
|
87
|
-
|
|
88
|
-
// Default: show help if no command given
|
|
89
|
-
if (process.argv.length <= 2) {
|
|
90
|
-
console.log('');
|
|
91
|
-
console.log(chalk.hex('#FF9900').bold(' x402 Bazaar') + chalk.dim(' — AI Agent Marketplace CLI v3'));
|
|
92
|
-
console.log('');
|
|
93
|
-
console.log(' Setup commands:');
|
|
94
|
-
console.log(chalk.cyan(' npx x402-bazaar init') + chalk.dim(' Full interactive setup'));
|
|
95
|
-
console.log(chalk.cyan(' npx x402-bazaar config') + chalk.dim(' Generate MCP config'));
|
|
96
|
-
console.log(chalk.cyan(' npx x402-bazaar status') + chalk.dim(' Check server connection'));
|
|
97
|
-
console.log('');
|
|
98
|
-
console.log(' Marketplace commands:');
|
|
99
|
-
console.log(chalk.cyan(' npx x402-bazaar list') + chalk.dim(' Browse all services'));
|
|
100
|
-
console.log(chalk.cyan(' npx x402-bazaar search <query>') + chalk.dim(' Find services by keyword'));
|
|
101
|
-
console.log(chalk.cyan(' npx x402-bazaar call <endpoint>') + chalk.dim(' Call API with auto-payment'));
|
|
102
|
-
console.log(chalk.cyan(' npx x402-bazaar wallet') + chalk.dim(' Check balance / setup wallet'));
|
|
103
|
-
console.log('');
|
|
104
|
-
console.log(chalk.dim(' Run any command with --help for detailed options'));
|
|
105
|
-
console.log('');
|
|
106
|
-
process.exit(0);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
program.parse();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { initCommand } from '../src/commands/init.js';
|
|
5
|
+
import { configCommand } from '../src/commands/config.js';
|
|
6
|
+
import { statusCommand } from '../src/commands/status.js';
|
|
7
|
+
import { listCommand } from '../src/commands/list.js';
|
|
8
|
+
import { searchCommand } from '../src/commands/search.js';
|
|
9
|
+
import { callCommand } from '../src/commands/call.js';
|
|
10
|
+
import { walletCommand } from '../src/commands/wallet.js';
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
|
|
13
|
+
// Global error handler
|
|
14
|
+
process.on('unhandledRejection', (err) => {
|
|
15
|
+
console.error('');
|
|
16
|
+
console.error(chalk.red('Error: ' + (err.message || err)));
|
|
17
|
+
if (err.code === 'ERR_MODULE_NOT_FOUND') {
|
|
18
|
+
console.error(chalk.dim(' Run: npm install'));
|
|
19
|
+
}
|
|
20
|
+
process.exit(1);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const program = new Command();
|
|
24
|
+
|
|
25
|
+
program
|
|
26
|
+
.name('x402-bazaar')
|
|
27
|
+
.description(chalk.hex('#FF9900')('x402 Bazaar') + ' — Connect your AI agent to the marketplace in one command')
|
|
28
|
+
.version('3.2.1');
|
|
29
|
+
|
|
30
|
+
program
|
|
31
|
+
.command('init')
|
|
32
|
+
.description('Set up x402 Bazaar MCP server (detect environment, configure wallet, generate config)')
|
|
33
|
+
.option('--env <environment>', 'Force environment (claude-desktop, cursor, claude-code, vscode-continue, generic)')
|
|
34
|
+
.option('--no-wallet', 'Skip wallet configuration (read-only mode)')
|
|
35
|
+
.option('--server-url <url>', 'Custom server URL', 'https://x402-api.onrender.com')
|
|
36
|
+
.option('--network <network>', 'Network: skale, mainnet, or testnet')
|
|
37
|
+
.option('--budget <amount>', 'Max USDC budget per session', '1.00')
|
|
38
|
+
.action(initCommand);
|
|
39
|
+
|
|
40
|
+
program
|
|
41
|
+
.command('config')
|
|
42
|
+
.description('Generate MCP configuration file for your environment')
|
|
43
|
+
.option('--env <environment>', 'Target environment (claude-desktop, cursor, claude-code, vscode-continue, generic)')
|
|
44
|
+
.option('--output <path>', 'Output file path')
|
|
45
|
+
.option('--server-url <url>', 'Custom server URL', 'https://x402-api.onrender.com')
|
|
46
|
+
.option('--network <network>', 'Network: skale, mainnet, or testnet')
|
|
47
|
+
.option('--budget <amount>', 'Max USDC budget per session', '1.00')
|
|
48
|
+
.action(configCommand);
|
|
49
|
+
|
|
50
|
+
program
|
|
51
|
+
.command('status')
|
|
52
|
+
.description('Check connection to x402 Bazaar marketplace')
|
|
53
|
+
.option('--server-url <url>', 'Server URL to check', 'https://x402-api.onrender.com')
|
|
54
|
+
.action(statusCommand);
|
|
55
|
+
|
|
56
|
+
program
|
|
57
|
+
.command('list')
|
|
58
|
+
.description('List all services on x402 Bazaar')
|
|
59
|
+
.option('--chain <chain>', 'Filter by chain (base or skale)')
|
|
60
|
+
.option('--category <category>', 'Filter by category (ai, data, weather, etc.)')
|
|
61
|
+
.option('--free', 'Show only free services')
|
|
62
|
+
.option('--server-url <url>', 'Server URL', 'https://x402-api.onrender.com')
|
|
63
|
+
.action(listCommand);
|
|
64
|
+
|
|
65
|
+
program
|
|
66
|
+
.command('search <query>')
|
|
67
|
+
.description('Search for services by keyword')
|
|
68
|
+
.option('--server-url <url>', 'Server URL', 'https://x402-api.onrender.com')
|
|
69
|
+
.action(searchCommand);
|
|
70
|
+
|
|
71
|
+
program
|
|
72
|
+
.command('call <endpoint>')
|
|
73
|
+
.description('Call a marketplace endpoint with automatic x402 payment')
|
|
74
|
+
.option('--param <key=value>', 'Add parameter (can be used multiple times)', (value, previous) => {
|
|
75
|
+
return previous ? [...previous, value] : [value];
|
|
76
|
+
}, [])
|
|
77
|
+
.option('--key <privateKey>', 'Private key for auto-payment. ⚠️ WARNING: Using --key on CLI exposes your key in shell history. Prefer setting X402_PRIVATE_KEY environment variable instead.')
|
|
78
|
+
.option('--server-url <url>', 'Server URL', 'https://x402-api.onrender.com')
|
|
79
|
+
.action(callCommand);
|
|
80
|
+
|
|
81
|
+
program
|
|
82
|
+
.command('wallet')
|
|
83
|
+
.description('Check USDC wallet balance or generate a new wallet')
|
|
84
|
+
.option('--address <address>', 'Ethereum address to check')
|
|
85
|
+
.option('--setup', 'Generate a new wallet for auto-payment')
|
|
86
|
+
.action(walletCommand);
|
|
87
|
+
|
|
88
|
+
// Default: show help if no command given
|
|
89
|
+
if (process.argv.length <= 2) {
|
|
90
|
+
console.log('');
|
|
91
|
+
console.log(chalk.hex('#FF9900').bold(' x402 Bazaar') + chalk.dim(' — AI Agent Marketplace CLI v3'));
|
|
92
|
+
console.log('');
|
|
93
|
+
console.log(' Setup commands:');
|
|
94
|
+
console.log(chalk.cyan(' npx x402-bazaar init') + chalk.dim(' Full interactive setup'));
|
|
95
|
+
console.log(chalk.cyan(' npx x402-bazaar config') + chalk.dim(' Generate MCP config'));
|
|
96
|
+
console.log(chalk.cyan(' npx x402-bazaar status') + chalk.dim(' Check server connection'));
|
|
97
|
+
console.log('');
|
|
98
|
+
console.log(' Marketplace commands:');
|
|
99
|
+
console.log(chalk.cyan(' npx x402-bazaar list') + chalk.dim(' Browse all services'));
|
|
100
|
+
console.log(chalk.cyan(' npx x402-bazaar search <query>') + chalk.dim(' Find services by keyword'));
|
|
101
|
+
console.log(chalk.cyan(' npx x402-bazaar call <endpoint>') + chalk.dim(' Call API with auto-payment'));
|
|
102
|
+
console.log(chalk.cyan(' npx x402-bazaar wallet') + chalk.dim(' Check balance / setup wallet'));
|
|
103
|
+
console.log('');
|
|
104
|
+
console.log(chalk.dim(' Run any command with --help for detailed options'));
|
|
105
|
+
console.log('');
|
|
106
|
+
process.exit(0);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
program.parse();
|
package/package.json
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "x402-bazaar",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "CLI for x402 Bazaar — AI Agent Marketplace. Browse, call, and auto-pay APIs with USDC on Base. One command to connect your agent.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "bin/cli.js",
|
|
7
|
-
"bin": {
|
|
8
|
-
"x402-bazaar": "./bin/cli.js"
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"bin/",
|
|
12
|
-
"src/",
|
|
13
|
-
"README.md",
|
|
14
|
-
"LICENSE"
|
|
15
|
-
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"start": "node bin/cli.js",
|
|
18
|
-
"test": "node
|
|
19
|
-
},
|
|
20
|
-
"engines": {
|
|
21
|
-
"node": ">=18.0.0"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"x402",
|
|
25
|
-
"mcp",
|
|
26
|
-
"ai-agents",
|
|
27
|
-
"marketplace",
|
|
28
|
-
"crypto",
|
|
29
|
-
"usdc",
|
|
30
|
-
"base",
|
|
31
|
-
"coinbase",
|
|
32
|
-
"claude",
|
|
33
|
-
"cursor",
|
|
34
|
-
"model-context-protocol"
|
|
35
|
-
],
|
|
36
|
-
"author": "x402 Bazaar",
|
|
37
|
-
"license": "MIT",
|
|
38
|
-
"homepage": "https://x402bazaar.org",
|
|
39
|
-
"repository": {
|
|
40
|
-
"type": "git",
|
|
41
|
-
"url": "https://github.com/Wintyx57/x402-bazaar-cli"
|
|
42
|
-
},
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"chalk": "^5.3.0",
|
|
45
|
-
"commander": "^12.1.0",
|
|
46
|
-
"inquirer": "^9.3.0",
|
|
47
|
-
"ora": "^8.0.1",
|
|
48
|
-
"viem": "^2.45.3"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "x402-bazaar",
|
|
3
|
+
"version": "3.2.1",
|
|
4
|
+
"description": "CLI for x402 Bazaar — AI Agent Marketplace. Browse, call, and auto-pay APIs with USDC on Base. One command to connect your agent.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "bin/cli.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"x402-bazaar": "./bin/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin/",
|
|
12
|
+
"src/",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"start": "node bin/cli.js",
|
|
18
|
+
"test": "node --test tests/*.test.js"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18.0.0"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"x402",
|
|
25
|
+
"mcp",
|
|
26
|
+
"ai-agents",
|
|
27
|
+
"marketplace",
|
|
28
|
+
"crypto",
|
|
29
|
+
"usdc",
|
|
30
|
+
"base",
|
|
31
|
+
"coinbase",
|
|
32
|
+
"claude",
|
|
33
|
+
"cursor",
|
|
34
|
+
"model-context-protocol"
|
|
35
|
+
],
|
|
36
|
+
"author": "x402 Bazaar",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"homepage": "https://x402bazaar.org",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/Wintyx57/x402-bazaar-cli"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"chalk": "^5.3.0",
|
|
45
|
+
"commander": "^12.1.0",
|
|
46
|
+
"inquirer": "^9.3.0",
|
|
47
|
+
"ora": "^8.0.1",
|
|
48
|
+
"viem": "^2.45.3"
|
|
49
|
+
}
|
|
50
|
+
}
|