@xcheeze/x402 0.1.0 → 0.1.2
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 +7 -6
- package/dist/config.js +1 -0
- package/dist/index.js +30 -17
- package/package.json +1 -1
- package/skill.md +9 -5
package/README.md
CHANGED
|
@@ -10,23 +10,24 @@ Cheeze inbox. **No Cheeze account or API key.** Mainnet is not live.
|
|
|
10
10
|
## Quick start
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
npx @xcheeze/x402 wallet # create the agent wallet, print address
|
|
14
|
-
|
|
15
|
-
# the faucet drips 20 testnet USDC per request
|
|
13
|
+
npx @xcheeze/x402 wallet # create the agent wallet, print its address
|
|
14
|
+
npx @xcheeze/x402 faucet # auto top-up the wallet with test USDC
|
|
16
15
|
npx @xcheeze/x402 fund # deposit on-chain USDC → Circle Gateway pocket
|
|
17
|
-
npx @xcheeze/x402 balance # confirm pocket available > 0
|
|
18
16
|
npx @xcheeze/x402 send @hudson --subject "Hello" --message "…"
|
|
19
17
|
```
|
|
20
18
|
|
|
19
|
+
If `faucet` says it's exhausted, top up manually at
|
|
20
|
+
https://faucet.circle.com/ ("Arc Testnet", paste the wallet address).
|
|
21
|
+
|
|
21
22
|
## Commands
|
|
22
23
|
|
|
23
24
|
| Command | Purpose |
|
|
24
25
|
|---|---|
|
|
25
26
|
| `wallet` | Create / show the local agent wallet (`~/.cheeze/x402.json`, or `CHEEZE_X402_PRIVATE_KEY`). |
|
|
27
|
+
| `faucet` | Auto top-up the wallet with test USDC (capped per wallet; falls back to faucet.circle.com). |
|
|
26
28
|
| `balance` | On-chain USDC + Gateway pocket (available / pending). |
|
|
27
29
|
| `fund [--amount N]` | Deposit on-chain USDC into the Gateway pocket (leaves a gas buffer; Arc gas is USDC). |
|
|
28
|
-
| `quote @handle
|
|
29
|
-
| `read @handle` | Pay to read the public summary. |
|
|
30
|
+
| `quote @handle` | Show the price to deliver a message — no payment. |
|
|
30
31
|
| `send @handle --subject "..." --message "..."` | Pay to deliver a message to the inbox. |
|
|
31
32
|
|
|
32
33
|
## Constraints
|
package/dist/config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineChain } from 'viem';
|
|
2
2
|
export const FACILITATOR_BASE = 'https://facilitator.cheeze.com';
|
|
3
|
+
export const FAUCET_RELAY = 'https://agents.cheeze.com/faucet';
|
|
3
4
|
export const ARC_CHAIN_ID = 5042002;
|
|
4
5
|
export const ARC_RPC = 'https://rpc.testnet.arc.network';
|
|
5
6
|
export const ARC_EXPLORER = 'https://testnet.arcscan.app';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createKey, loadKey, account, onchainUsdc, gatewayPocket, depositToPocket, usdc6, } from './wallet.js';
|
|
3
3
|
import { fetchChallenge, priceUsd, pay } from './x402.js';
|
|
4
|
-
import { FAUCET_URL, FAUCET_AMOUNT_USDC, ARC_EXPLORER, MAX_SUBJECT_CHARS, MAX_MESSAGE_CHARS, } from './config.js';
|
|
4
|
+
import { FAUCET_URL, FAUCET_AMOUNT_USDC, FAUCET_RELAY, ARC_EXPLORER, MAX_SUBJECT_CHARS, MAX_MESSAGE_CHARS, } from './config.js';
|
|
5
5
|
function flag(argv, name) {
|
|
6
6
|
const i = argv.indexOf(`--${name}`);
|
|
7
7
|
return i >= 0 ? argv[i + 1] : undefined;
|
|
@@ -13,14 +13,14 @@ function fail(msg) {
|
|
|
13
13
|
const USAGE = `@xcheeze/x402 — message a human on Cheeze over x402 (Arc testnet)
|
|
14
14
|
|
|
15
15
|
xcheeze-x402 wallet create / show your agent wallet
|
|
16
|
+
xcheeze-x402 faucet auto top-up the wallet with test USDC
|
|
16
17
|
xcheeze-x402 balance on-chain USDC + Gateway pocket
|
|
17
18
|
xcheeze-x402 fund [--amount <usdc>] deposit on-chain USDC into the pocket
|
|
18
|
-
xcheeze-x402 quote @handle
|
|
19
|
-
xcheeze-x402 read @handle pay to read @handle's public summary
|
|
19
|
+
xcheeze-x402 quote @handle show the price — no payment
|
|
20
20
|
xcheeze-x402 send @handle --subject "<s>" --message "<m>"
|
|
21
21
|
|
|
22
|
-
Setup: 1) wallet 2)
|
|
23
|
-
|
|
22
|
+
Setup: 1) wallet 2) faucet 3) fund 4) send.
|
|
23
|
+
No Cheeze account or API key needed.`;
|
|
24
24
|
async function main() {
|
|
25
25
|
const argv = process.argv.slice(2);
|
|
26
26
|
const cmd = argv[0];
|
|
@@ -48,6 +48,28 @@ async function main() {
|
|
|
48
48
|
` 4. xcheeze-x402 send @handle --subject "..." --message "..."`);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
+
if (cmd === 'faucet') {
|
|
52
|
+
const a = account();
|
|
53
|
+
process.stderr.write('Requesting test USDC for your wallet…\n');
|
|
54
|
+
const res = await fetch(FAUCET_RELAY, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
headers: { 'content-type': 'application/json' },
|
|
57
|
+
body: JSON.stringify({ address: a.address }),
|
|
58
|
+
});
|
|
59
|
+
const out = (await res.json().catch(() => ({})));
|
|
60
|
+
if (!res.ok || !out.ok) {
|
|
61
|
+
fail(`${out.detail || out.error || `faucet error (HTTP ${res.status})`}\n` +
|
|
62
|
+
` Get test USDC manually: ${FAUCET_URL} (choose "Arc Testnet"),\n` +
|
|
63
|
+
` paste ${a.address}, then run \`xcheeze-x402 fund\`.`);
|
|
64
|
+
}
|
|
65
|
+
console.log(`✓ ${out.amount_usdc} test USDC sent to ${a.address}` +
|
|
66
|
+
(out.tx ? `\n ${ARC_EXPLORER}/tx/${out.tx}` : '') +
|
|
67
|
+
(typeof out.remaining_draws === 'number'
|
|
68
|
+
? `\n ${out.remaining_draws} free top-up(s) left for this wallet.`
|
|
69
|
+
: '') +
|
|
70
|
+
`\nNext: xcheeze-x402 fund`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
51
73
|
if (cmd === 'balance') {
|
|
52
74
|
const a = account();
|
|
53
75
|
const [oc, pk] = await Promise.all([onchainUsdc(a.address), gatewayPocket(a.address)]);
|
|
@@ -72,20 +94,11 @@ async function main() {
|
|
|
72
94
|
return;
|
|
73
95
|
}
|
|
74
96
|
if (cmd === 'quote') {
|
|
75
|
-
const handle = argv[1];
|
|
76
|
-
const act = argv[2] || 'deliver';
|
|
77
|
-
if (!handle)
|
|
78
|
-
fail('Usage: xcheeze-x402 quote @handle [read|deliver]');
|
|
79
|
-
const { accept } = await fetchChallenge(handle, act);
|
|
80
|
-
console.log(`${handle} · ${act}: ${priceUsd(accept)} USDC (the price you pay)`);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
if (cmd === 'read') {
|
|
84
97
|
const handle = argv[1];
|
|
85
98
|
if (!handle)
|
|
86
|
-
fail('Usage: xcheeze-x402
|
|
87
|
-
const
|
|
88
|
-
console.log(
|
|
99
|
+
fail('Usage: xcheeze-x402 quote @handle');
|
|
100
|
+
const { accept } = await fetchChallenge(handle, 'deliver');
|
|
101
|
+
console.log(`${handle}: ${priceUsd(accept)} USDC to deliver a message (the price you pay)`);
|
|
89
102
|
return;
|
|
90
103
|
}
|
|
91
104
|
if (cmd === 'send') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xcheeze/x402",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Pay a human on Cheeze over x402. An AI agent funds an Arc-testnet wallet and sends a paid message that lands in the human's Cheeze inbox. No Cheeze account or API key.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/skill.md
CHANGED
|
@@ -23,10 +23,14 @@ prints your wallet **address**. The private key is written to
|
|
|
23
23
|
`CHEEZE_X402_PRIVATE_KEY` env var. It is YOUR key — it is never sent
|
|
24
24
|
to Cheeze and Cheeze never holds funds for you.
|
|
25
25
|
|
|
26
|
-
**Step 2 —
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
**Step 2 — top up the wallet (automatic).**
|
|
27
|
+
```bash
|
|
28
|
+
npx @xcheeze/x402 faucet
|
|
29
|
+
```
|
|
30
|
+
Auto-sends test USDC to your wallet — no website, no human. If it
|
|
31
|
+
reports the faucet is exhausted for this wallet, top up manually at
|
|
32
|
+
**https://faucet.circle.com/** (choose **Arc Testnet**, paste your
|
|
33
|
+
address from Step 1).
|
|
30
34
|
|
|
31
35
|
**Step 3 — move it into your Gateway pocket.**
|
|
32
36
|
```bash
|
|
@@ -47,7 +51,7 @@ repeat Steps 2–3 when the pocket runs low.
|
|
|
47
51
|
## Discover the price (no payment)
|
|
48
52
|
|
|
49
53
|
```bash
|
|
50
|
-
npx @xcheeze/x402 quote @handle
|
|
54
|
+
npx @xcheeze/x402 quote @handle
|
|
51
55
|
```
|
|
52
56
|
|
|
53
57
|
Returns the USDC price you will pay. The price is also returned
|