@t402/cli 2.0.0 → 2.3.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 +250 -0
- package/package.json +7 -6
package/README.md
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# @t402/cli
|
|
2
|
+
|
|
3
|
+
Command-line interface for the T402 payment protocol.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Wallet Management**: Create, import, and manage WDK wallets
|
|
8
|
+
- **Payments**: Send USDT0/USDC payments with standard or gasless modes
|
|
9
|
+
- **Multi-Chain**: Support for EVM, Solana, TON, and TRON networks
|
|
10
|
+
- **Configuration**: Manage networks, RPC endpoints, and preferences
|
|
11
|
+
- **Request Parsing**: Parse and inspect T402 payment requests
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g @t402/cli
|
|
17
|
+
# or
|
|
18
|
+
pnpm add -g @t402/cli
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Create a new wallet
|
|
25
|
+
t402 wallet create
|
|
26
|
+
|
|
27
|
+
# Check balance
|
|
28
|
+
t402 wallet balance
|
|
29
|
+
|
|
30
|
+
# Send payment
|
|
31
|
+
t402 pay 0xRecipient... 10.5 --network eip155:8453
|
|
32
|
+
|
|
33
|
+
# Send gasless payment (ERC-4337)
|
|
34
|
+
t402 pay 0xRecipient... 10.5 --gasless
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
### Wallet Management
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Create a new wallet (generates seed phrase)
|
|
43
|
+
t402 wallet create
|
|
44
|
+
|
|
45
|
+
# Import existing wallet
|
|
46
|
+
t402 wallet import
|
|
47
|
+
|
|
48
|
+
# Show wallet info
|
|
49
|
+
t402 wallet info
|
|
50
|
+
|
|
51
|
+
# Check balance
|
|
52
|
+
t402 wallet balance
|
|
53
|
+
t402 wallet balance --network eip155:42161
|
|
54
|
+
|
|
55
|
+
# Export seed phrase (requires confirmation)
|
|
56
|
+
t402 wallet export
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Payments
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Standard payment
|
|
63
|
+
t402 pay <address> <amount> [options]
|
|
64
|
+
|
|
65
|
+
# Options:
|
|
66
|
+
# -n, --network <network> Network (e.g., eip155:8453, solana:devnet)
|
|
67
|
+
# -a, --asset <asset> Asset to send (default: usdt0)
|
|
68
|
+
# -g, --gasless Use gasless ERC-4337 transaction
|
|
69
|
+
|
|
70
|
+
# Examples:
|
|
71
|
+
t402 pay 0x742d35Cc... 100 --network eip155:8453
|
|
72
|
+
t402 pay 0x742d35Cc... 50 --gasless --asset usdc
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Configuration
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# View all config
|
|
79
|
+
t402 config list
|
|
80
|
+
|
|
81
|
+
# Get specific config
|
|
82
|
+
t402 config get defaultNetwork
|
|
83
|
+
|
|
84
|
+
# Set config value
|
|
85
|
+
t402 config set defaultNetwork eip155:8453
|
|
86
|
+
t402 config set testnet true
|
|
87
|
+
|
|
88
|
+
# Set RPC endpoint
|
|
89
|
+
t402 config rpc eip155:8453 https://base.llamarpc.com
|
|
90
|
+
|
|
91
|
+
# Reset to defaults
|
|
92
|
+
t402 config reset
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Request Handling
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Parse a T402 payment request
|
|
99
|
+
t402 request parse <base64-encoded-request>
|
|
100
|
+
|
|
101
|
+
# Show request details
|
|
102
|
+
t402 request info <request-id>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Info
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Show supported networks
|
|
109
|
+
t402 info networks
|
|
110
|
+
|
|
111
|
+
# Show version
|
|
112
|
+
t402 --version
|
|
113
|
+
|
|
114
|
+
# Show help
|
|
115
|
+
t402 --help
|
|
116
|
+
t402 <command> --help
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Configuration
|
|
120
|
+
|
|
121
|
+
Configuration is stored in `~/.config/t402-cli/config.json`:
|
|
122
|
+
|
|
123
|
+
| Key | Description | Default |
|
|
124
|
+
|-----|-------------|---------|
|
|
125
|
+
| `defaultNetwork` | Default network for payments | `eip155:8453` |
|
|
126
|
+
| `testnet` | Use testnet networks | `false` |
|
|
127
|
+
| `gasless` | Default to gasless payments | `false` |
|
|
128
|
+
|
|
129
|
+
### Custom RPC Endpoints
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Set custom RPC for a network
|
|
133
|
+
t402 config rpc eip155:1 https://eth.llamarpc.com
|
|
134
|
+
t402 config rpc eip155:42161 https://arb1.arbitrum.io/rpc
|
|
135
|
+
t402 config rpc solana:mainnet https://api.mainnet-beta.solana.com
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Supported Networks
|
|
139
|
+
|
|
140
|
+
### EVM (eip155)
|
|
141
|
+
|
|
142
|
+
| Network | Chain ID | Identifier |
|
|
143
|
+
|---------|----------|------------|
|
|
144
|
+
| Ethereum | 1 | `eip155:1` |
|
|
145
|
+
| Arbitrum | 42161 | `eip155:42161` |
|
|
146
|
+
| Base | 8453 | `eip155:8453` |
|
|
147
|
+
| Optimism | 10 | `eip155:10` |
|
|
148
|
+
| Ink | 57073 | `eip155:57073` |
|
|
149
|
+
| Base Sepolia | 84532 | `eip155:84532` |
|
|
150
|
+
|
|
151
|
+
### Solana
|
|
152
|
+
|
|
153
|
+
| Network | Identifier |
|
|
154
|
+
|---------|------------|
|
|
155
|
+
| Mainnet | `solana:mainnet` |
|
|
156
|
+
| Devnet | `solana:devnet` |
|
|
157
|
+
|
|
158
|
+
### TON
|
|
159
|
+
|
|
160
|
+
| Network | Identifier |
|
|
161
|
+
|---------|------------|
|
|
162
|
+
| Mainnet | `ton:0` |
|
|
163
|
+
| Testnet | `ton:-3` |
|
|
164
|
+
|
|
165
|
+
### TRON
|
|
166
|
+
|
|
167
|
+
| Network | Identifier |
|
|
168
|
+
|---------|------------|
|
|
169
|
+
| Mainnet | `tron:mainnet` |
|
|
170
|
+
| Nile | `tron:nile` |
|
|
171
|
+
|
|
172
|
+
## Programmatic Usage
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import {
|
|
176
|
+
createCli,
|
|
177
|
+
getConfig,
|
|
178
|
+
setConfig,
|
|
179
|
+
formatAmount,
|
|
180
|
+
parseAmount,
|
|
181
|
+
} from '@t402/cli';
|
|
182
|
+
|
|
183
|
+
// Get configuration
|
|
184
|
+
const network = getConfig('defaultNetwork');
|
|
185
|
+
|
|
186
|
+
// Set configuration
|
|
187
|
+
setConfig('testnet', true);
|
|
188
|
+
|
|
189
|
+
// Format/parse amounts
|
|
190
|
+
const formatted = formatAmount(1000000n, 6); // "1.0"
|
|
191
|
+
const parsed = parseAmount("1.5", 6); // 1500000n
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Security
|
|
195
|
+
|
|
196
|
+
- Seed phrases are encrypted at rest using machine-specific keys
|
|
197
|
+
- No seed phrases are transmitted over the network
|
|
198
|
+
- Configuration files have restricted permissions
|
|
199
|
+
|
|
200
|
+
## Examples
|
|
201
|
+
|
|
202
|
+
### Daily Payment Workflow
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Morning: Check balance
|
|
206
|
+
t402 wallet balance
|
|
207
|
+
|
|
208
|
+
# Send payment to vendor
|
|
209
|
+
t402 pay 0xVendor... 1000 --network eip155:8453
|
|
210
|
+
|
|
211
|
+
# Check transaction
|
|
212
|
+
t402 info tx <txHash>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Multi-Network Operations
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Check balances on multiple chains
|
|
219
|
+
t402 wallet balance --network eip155:1
|
|
220
|
+
t402 wallet balance --network eip155:42161
|
|
221
|
+
t402 wallet balance --network eip155:8453
|
|
222
|
+
|
|
223
|
+
# Send from cheapest chain
|
|
224
|
+
t402 pay 0xRecipient... 100 --network eip155:42161 --gasless
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Testnet Development
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Switch to testnet mode
|
|
231
|
+
t402 config set testnet true
|
|
232
|
+
|
|
233
|
+
# Use testnet RPC
|
|
234
|
+
t402 config rpc eip155:84532 https://sepolia.base.org
|
|
235
|
+
|
|
236
|
+
# Send test payment
|
|
237
|
+
t402 pay 0xTest... 10 --network eip155:84532
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Environment Variables
|
|
241
|
+
|
|
242
|
+
| Variable | Description |
|
|
243
|
+
|----------|-------------|
|
|
244
|
+
| `T402_DEFAULT_NETWORK` | Override default network |
|
|
245
|
+
| `T402_TESTNET` | Enable testnet mode |
|
|
246
|
+
| `T402_CONFIG_PATH` | Custom config directory |
|
|
247
|
+
|
|
248
|
+
## License
|
|
249
|
+
|
|
250
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t402/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Command-line interface for the T402 payment protocol",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"t402",
|
|
@@ -34,17 +34,18 @@
|
|
|
34
34
|
"commander": "^12.1.0",
|
|
35
35
|
"conf": "^13.0.1",
|
|
36
36
|
"ora": "^8.1.0",
|
|
37
|
-
"viem": "^2.
|
|
38
|
-
"@t402/core": "2.
|
|
39
|
-
"@t402/wdk-gasless": "
|
|
40
|
-
"@t402/wdk": "2.
|
|
37
|
+
"viem": "^2.44.2",
|
|
38
|
+
"@t402/core": "2.3.1",
|
|
39
|
+
"@t402/wdk-gasless": "2.0.0-beta.1",
|
|
40
|
+
"@t402/wdk": "2.3.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^22.10.0",
|
|
44
|
+
"glob": "^13.0.0",
|
|
44
45
|
"tsup": "^8.5.0",
|
|
45
46
|
"typescript": "^5.8.0",
|
|
46
47
|
"vite-tsconfig-paths": "^5.1.0",
|
|
47
|
-
"vitest": "^3.
|
|
48
|
+
"vitest": "^3.2.4"
|
|
48
49
|
},
|
|
49
50
|
"engines": {
|
|
50
51
|
"node": ">=18"
|