Skip to content

Commit ef03301

Browse files
authored
Merge pull request #68 from 0xPolygon/feat/v2-relay-session
docs(skills): review and improve SKILL.md clarity
2 parents 9aba3a2 + c78cd40 commit ef03301

File tree

3 files changed

+60
-57
lines changed

3 files changed

+60
-57
lines changed

packages/connector-ui/public/SKILL.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,33 @@ export SEQUENCE_PROJECT_ACCESS_KEY=<override-key>
4343
## Complete Setup Flow
4444

4545
```bash
46-
# Phase 1: Setup (creates EOA + Sequence project, stores access key to disk)
46+
# Step 1: Setup (creates EOA + Sequence project, stores access key to disk)
4747
polygon-agent setup --name "MyAgent"
4848
# → saves privateKey (not shown again), eoaAddress, accessKey to ~/.polygon-agent/builder.json
4949
# → all subsequent commands auto-load the access key from disk — no export needed
5050

51-
# Phase 2: Create ecosystem wallet (opens browser, waits for 6-digit code)
51+
# Step 2: Create ecosystem wallet (opens browser, waits for 6-digit code)
5252
polygon-agent wallet create --usdc-limit 100 --native-limit 5
5353
# → opens https://agentconnect.polygon.technology/link?rid=<rid>&...
5454
# → user approves in browser, browser shows a 6-digit code
5555
# → enter the 6-digit code in the terminal when prompted
5656
# → session saved to ~/.polygon-agent/wallets/main.json
5757

58-
# Phase 3: Fund wallet
58+
# Step 3: Fund wallet
5959
polygon-agent fund
6060
# → reads walletAddress from session, builds Trails widget URL with toAddress=<walletAddress>
6161
# → ALWAYS run this command to get the URL — never construct it manually or hardcode any address
6262
# → send the returned `fundingUrl` to the user; `walletAddress` in the output confirms the recipient
6363

64-
# Phase 4: Verify
64+
# Step 4: Verify balances
6565
polygon-agent balances
6666

67-
# Phase 5: Register agent on-chain (ERC-8004, Polygon mainnet)
67+
# Step 5: Register agent on-chain (ERC-8004, Polygon mainnet only)
6868
polygon-agent agent register --name "MyAgent" --broadcast
69-
# → mints ERC-721 NFT, emits agentId in Registered event
70-
# → use agentId for reputation queries and feedback
69+
# → mints ERC-721 NFT, emits Registered event containing agentId
70+
# → retrieve agentId: open the tx on https://polygonscan.com, go to Logs tab,
71+
# find the Registered event — agentId is the first indexed parameter
72+
# → use agentId for reputation queries, reviews, and feedback
7173
```
7274

7375
## Commands Reference
@@ -78,6 +80,8 @@ polygon-agent setup --name <name> [--force]
7880
```
7981

8082
### Wallet
83+
Valid `--chain` values: `polygon` (default/mainnet), `amoy` (Polygon testnet), `mainnet` (Ethereum), `arbitrum`, `optimism`, `base`. ERC-8004 agent operations only support `polygon`.
84+
8185
```bash
8286
polygon-agent wallet create [--name <n>] [--chain polygon] [--timeout <sec>] [--print-url]
8387
[--native-limit <amt>] [--usdc-limit <amt>] [--usdt-limit <amt>]
@@ -123,25 +127,17 @@ polygon-agent agent feedback --agent-id <id> --value <score> [--tag1 <t>] [--tag
123127
- **Smart defaults**`--wallet main`, `--chain polygon`, auto-wait on `wallet create`
124128
- **Fee preference** — auto-selects USDC over native POL when both available
125129
- **`fund`** — reads `walletAddress` from the wallet session and sets it as `toAddress` in the Trails widget URL. Always run `polygon-agent fund` to get the correct URL — never construct it manually or hardcode any address.
126-
- **`deposit`** — picks highest-TVL pool via Trails `getEarnPools`. If session rejects, re-create wallet with `--contract <depositAddress>`
130+
- **`deposit`** — picks highest-TVL pool via Trails `getEarnPools`. If session rejects (contract not whitelisted), re-create wallet with `--contract <depositAddress>`
127131
- **`x402-pay`** — probes endpoint for 402, smart wallet funds builder EOA with exact token amount, EOA signs EIP-3009 payment. Chain auto-detected from 402 response
128132
- **`send-native --direct`** — bypasses ValueForwarder contract for direct EOA transfer
129133
- **Session permissions** — without `--usdc-limit` etc., session gets bare-bones defaults and may not transact
130134
- **Session expiry** — 6 months from creation
131135

132136
## Wallet Creation Flow (v2 Relay)
133137

134-
`wallet create` uses a Cloudflare Durable Object relay and a 6-digit out-of-band code — no cloudflared tunnel required:
135-
136-
1. CLI registers its X25519 public key with the relay, gets a request ID (`rid`)
137-
2. CLI opens `https://agentconnect.polygon.technology/link?rid=<rid>&...` in the browser
138-
3. User approves the wallet session in the browser (Sequence popup)
139-
4. Browser encrypts the session with the CLI's public key and posts it to the relay
140-
5. Browser displays a **6-digit code**
141-
6. User enters the code in the terminal when prompted
142-
7. CLI fetches the encrypted payload from the relay, decrypts it using the code, saves the session
138+
`wallet create` uses a Cloudflare Durable Object relay and a 6-digit out-of-band code — no cloudflared tunnel required. The browser encrypts the approved session with an X25519 key negotiated via the relay; the 6-digit code is the decryption key entered in the terminal.
143139

144-
**`--print-url` flow:** CLI outputs the URL without blocking. Complete later with:
140+
**`--print-url` flag:** Use this in headless or non-interactive environments (CI, remote shells) where `wallet create` can't block waiting for the code. The CLI prints the approval URL and exits immediately. Complete the flow separately:
145141
```bash
146142
polygon-agent wallet import --code <6-digit-code> --rid <rid>
147143
```
@@ -166,7 +162,9 @@ CLI commands output JSON (non-TTY). After running a command, always render the r
166162
| `deposit` | Summary: amount, asset, protocol, pool address. If broadcast, show tx hash + explorer link. |
167163
| `fund` | Show the `fundingUrl` as a clickable link with a brief instruction to open it. |
168164
| `wallet create` / `wallet list` | Wallet name, truncated address, chain in a small table or bullet list. |
169-
| `agent register` | Show agent name and tx hash. Remind user to retrieve `agentId` from the Registered event. |
165+
| `agent register` | Show agent name and tx hash as a code span with Polygonscan link. Remind user to retrieve `agentId` from the Registered event on the Logs tab. |
166+
| `agent wallet` | Show `agentId`, wallet address, and whether a wallet is set. |
167+
| `agent metadata` | Show `agentId`, key, and decoded value. |
170168
| `agent reputation` | Format score and tag breakdown as a small table. |
171169

172170
**Dry-run results** — always make it visually clear this was a simulation. Prefix with `⚡ Dry run` and show what *would* happen. Remind the user to re-run with `--broadcast` to execute.
@@ -187,6 +185,9 @@ CLI commands output JSON (non-TTY). After running a command, always render the r
187185
| `Relay request not found` | Session expired or already used — re-run `wallet create` (or `wallet create --print-url`) |
188186
| Deposit session rejected | Re-create wallet with `--contract <depositAddress>` |
189187
| Wrong recipient in Trails widget | Run `polygon-agent fund` (do not construct the URL manually) |
188+
| `x402-pay`: no 402 response | Endpoint doesn't require x402 payment, or URL is wrong |
189+
| `x402-pay`: payment token mismatch | Chain/token in the 402 response differs from wallet — check `--wallet` points to the right chain |
190+
| `x402-pay`: EOA funding failed | Wallet lacks sufficient balance to cover the payment amount — run `balances` and fund if needed |
190191

191192
## File Structure
192193
```

packages/polygon-agent-cli/skills/SKILL.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,33 @@ export SEQUENCE_PROJECT_ACCESS_KEY=<override-key>
4343
## Complete Setup Flow
4444

4545
```bash
46-
# Phase 1: Setup (creates EOA + Sequence project, stores access key to disk)
46+
# Step 1: Setup (creates EOA + Sequence project, stores access key to disk)
4747
polygon-agent setup --name "MyAgent"
4848
# → saves privateKey (not shown again), eoaAddress, accessKey to ~/.polygon-agent/builder.json
4949
# → all subsequent commands auto-load the access key from disk — no export needed
5050

51-
# Phase 2: Create ecosystem wallet (opens browser, waits for 6-digit code)
51+
# Step 2: Create ecosystem wallet (opens browser, waits for 6-digit code)
5252
polygon-agent wallet create --usdc-limit 100 --native-limit 5
5353
# → opens https://agentconnect.polygon.technology/link?rid=<rid>&...
5454
# → user approves in browser, browser shows a 6-digit code
5555
# → enter the 6-digit code in the terminal when prompted
5656
# → session saved to ~/.polygon-agent/wallets/main.json
5757

58-
# Phase 3: Fund wallet
58+
# Step 3: Fund wallet
5959
polygon-agent fund
6060
# → reads walletAddress from session, builds Trails widget URL with toAddress=<walletAddress>
6161
# → ALWAYS run this command to get the URL — never construct it manually or hardcode any address
6262
# → send the returned `fundingUrl` to the user; `walletAddress` in the output confirms the recipient
6363

64-
# Phase 4: Verify
64+
# Step 4: Verify balances
6565
polygon-agent balances
6666

67-
# Phase 5: Register agent on-chain (ERC-8004, Polygon mainnet)
67+
# Step 5: Register agent on-chain (ERC-8004, Polygon mainnet only)
6868
polygon-agent agent register --name "MyAgent" --broadcast
69-
# → mints ERC-721 NFT, emits agentId in Registered event
70-
# → use agentId for reputation queries and feedback
69+
# → mints ERC-721 NFT, emits Registered event containing agentId
70+
# → retrieve agentId: open the tx on https://polygonscan.com, go to Logs tab,
71+
# find the Registered event — agentId is the first indexed parameter
72+
# → use agentId for reputation queries, reviews, and feedback
7173
```
7274

7375
## Commands Reference
@@ -78,6 +80,8 @@ polygon-agent setup --name <name> [--force]
7880
```
7981

8082
### Wallet
83+
Valid `--chain` values: `polygon` (default/mainnet), `amoy` (Polygon testnet), `mainnet` (Ethereum), `arbitrum`, `optimism`, `base`. ERC-8004 agent operations only support `polygon`.
84+
8185
```bash
8286
polygon-agent wallet create [--name <n>] [--chain polygon] [--timeout <sec>] [--print-url]
8387
[--native-limit <amt>] [--usdc-limit <amt>] [--usdt-limit <amt>]
@@ -123,25 +127,17 @@ polygon-agent agent feedback --agent-id <id> --value <score> [--tag1 <t>] [--tag
123127
- **Smart defaults**`--wallet main`, `--chain polygon`, auto-wait on `wallet create`
124128
- **Fee preference** — auto-selects USDC over native POL when both available
125129
- **`fund`** — reads `walletAddress` from the wallet session and sets it as `toAddress` in the Trails widget URL. Always run `polygon-agent fund` to get the correct URL — never construct it manually or hardcode any address.
126-
- **`deposit`** — picks highest-TVL pool via Trails `getEarnPools`. If session rejects, re-create wallet with `--contract <depositAddress>`
130+
- **`deposit`** — picks highest-TVL pool via Trails `getEarnPools`. If session rejects (contract not whitelisted), re-create wallet with `--contract <depositAddress>`
127131
- **`x402-pay`** — probes endpoint for 402, smart wallet funds builder EOA with exact token amount, EOA signs EIP-3009 payment. Chain auto-detected from 402 response
128132
- **`send-native --direct`** — bypasses ValueForwarder contract for direct EOA transfer
129133
- **Session permissions** — without `--usdc-limit` etc., session gets bare-bones defaults and may not transact
130134
- **Session expiry** — 6 months from creation
131135

132136
## Wallet Creation Flow (v2 Relay)
133137

134-
`wallet create` uses a Cloudflare Durable Object relay and a 6-digit out-of-band code — no cloudflared tunnel required:
135-
136-
1. CLI registers its X25519 public key with the relay, gets a request ID (`rid`)
137-
2. CLI opens `https://agentconnect.polygon.technology/link?rid=<rid>&...` in the browser
138-
3. User approves the wallet session in the browser (Sequence popup)
139-
4. Browser encrypts the session with the CLI's public key and posts it to the relay
140-
5. Browser displays a **6-digit code**
141-
6. User enters the code in the terminal when prompted
142-
7. CLI fetches the encrypted payload from the relay, decrypts it using the code, saves the session
138+
`wallet create` uses a Cloudflare Durable Object relay and a 6-digit out-of-band code — no cloudflared tunnel required. The browser encrypts the approved session with an X25519 key negotiated via the relay; the 6-digit code is the decryption key entered in the terminal.
143139

144-
**`--print-url` flow:** CLI outputs the URL without blocking. Complete later with:
140+
**`--print-url` flag:** Use this in headless or non-interactive environments (CI, remote shells) where `wallet create` can't block waiting for the code. The CLI prints the approval URL and exits immediately. Complete the flow separately:
145141
```bash
146142
polygon-agent wallet import --code <6-digit-code> --rid <rid>
147143
```
@@ -166,7 +162,9 @@ CLI commands output JSON (non-TTY). After running a command, always render the r
166162
| `deposit` | Summary: amount, asset, protocol, pool address. If broadcast, show tx hash + explorer link. |
167163
| `fund` | Show the `fundingUrl` as a clickable link with a brief instruction to open it. |
168164
| `wallet create` / `wallet list` | Wallet name, truncated address, chain in a small table or bullet list. |
169-
| `agent register` | Show agent name and tx hash. Remind user to retrieve `agentId` from the Registered event. |
165+
| `agent register` | Show agent name and tx hash as a code span with Polygonscan link. Remind user to retrieve `agentId` from the Registered event on the Logs tab. |
166+
| `agent wallet` | Show `agentId`, wallet address, and whether a wallet is set. |
167+
| `agent metadata` | Show `agentId`, key, and decoded value. |
170168
| `agent reputation` | Format score and tag breakdown as a small table. |
171169

172170
**Dry-run results** — always make it visually clear this was a simulation. Prefix with `⚡ Dry run` and show what *would* happen. Remind the user to re-run with `--broadcast` to execute.
@@ -187,6 +185,9 @@ CLI commands output JSON (non-TTY). After running a command, always render the r
187185
| `Relay request not found` | Session expired or already used — re-run `wallet create` (or `wallet create --print-url`) |
188186
| Deposit session rejected | Re-create wallet with `--contract <depositAddress>` |
189187
| Wrong recipient in Trails widget | Run `polygon-agent fund` (do not construct the URL manually) |
188+
| `x402-pay`: no 402 response | Endpoint doesn't require x402 payment, or URL is wrong |
189+
| `x402-pay`: payment token mismatch | Chain/token in the 402 response differs from wallet — check `--wallet` points to the right chain |
190+
| `x402-pay`: EOA funding failed | Wallet lacks sufficient balance to cover the payment amount — run `balances` and fund if needed |
190191

191192
## File Structure
192193
```

0 commit comments

Comments
 (0)