$npx -y skills add Uniswap/uniswap-ai --skill pay-with-any-tokenPay HTTP 402 payment challenges using tokens via the Tempo CLI and Uniswap Trading API. Use when the user encounters a 402 Payment Required response, needs to fulfill a machine payment, mentions "MPP", "Tempo payment", "pay for API access", "HTTP 402", "x402", "machine payment pr
| 1 | # Pay With Tokens |
| 2 | |
| 3 | Use the **Tempo CLI** to call paid APIs and handle 402 challenges automatically. |
| 4 | When the Tempo wallet has insufficient balance, fund it by swapping and bridging |
| 5 | tokens from any EVM chain using the **Uniswap Trading API**. |
| 6 | |
| 7 | ## Tempo CLI Setup |
| 8 | |
| 9 | Run these commands in order. Do not skip steps. |
| 10 | |
| 11 | **Step 1 — Install:** |
| 12 | |
| 13 | ```bash |
| 14 | mkdir -p "$HOME/.local/bin" \ |
| 15 | && curl -fsSL https://tempo.xyz/install -o /tmp/tempo_install.sh \ |
| 16 | && TEMPO_BIN_DIR="$HOME/.local/bin" bash /tmp/tempo_install.sh |
| 17 | ``` |
| 18 | |
| 19 | **Step 2 — Login** (requires browser/passkey — prompt user, wait for |
| 20 | confirmation): |
| 21 | |
| 22 | ```bash |
| 23 | "$HOME/.local/bin/tempo" wallet login |
| 24 | ``` |
| 25 | |
| 26 | > When run by agents, use a long command timeout (at least 16 minutes). |
| 27 | |
| 28 | **Step 3 — Confirm readiness:** |
| 29 | |
| 30 | ```bash |
| 31 | "$HOME/.local/bin/tempo" wallet -t whoami |
| 32 | ``` |
| 33 | |
| 34 | > **Rules:** Do not use `sudo`. Use full absolute paths (`$HOME/.local/bin/tempo`) |
| 35 | > — do not rely on `export PATH`. If `$HOME` does not expand, use the literal |
| 36 | > absolute path. |
| 37 | |
| 38 | After setup, report: install location, version (`--version`), wallet status |
| 39 | (address, balance). If balance is 0, direct user to `tempo wallet fund`. |
| 40 | |
| 41 | > **Minimum balance reserve:** Keep at least **0.10 USDC** in the Tempo wallet |
| 42 | > to cover typical API calls without triggering the full swap+bridge funding |
| 43 | > flow. The funding flow requires 3-5 on-chain transactions and ~2 minutes of |
| 44 | > wall time, which is disproportionate for small top-ups. When transferring |
| 45 | > funds out of the Tempo wallet, warn the user if the remaining balance would |
| 46 | > drop below this threshold. |
| 47 | |
| 48 | ## Using Tempo Services |
| 49 | |
| 50 | ```bash |
| 51 | # Discover services |
| 52 | "$HOME/.local/bin/tempo" wallet -t services --search <query> |
| 53 | # Get service details (exact URL, method, path, pricing) |
| 54 | "$HOME/.local/bin/tempo" wallet -t services <SERVICE_ID> |
| 55 | # Make a paid request |
| 56 | "$HOME/.local/bin/tempo" request -t -X POST \ |
| 57 | --json '{"input":"..."}' <SERVICE_URL>/<ENDPOINT_PATH> |
| 58 | ``` |
| 59 | |
| 60 | - Anchor on `tempo wallet -t services <SERVICE_ID>` for exact URL and pricing |
| 61 | - Use `-t` for agent calls, `--dry-run` before expensive requests |
| 62 | - On HTTP 422, check the service's docs URL or llms.txt for exact field names |
| 63 | - Fire independent multi-service requests in parallel |
| 64 | |
| 65 | > **When the user explicitly says "use tempo", always use tempo CLI commands — |
| 66 | > never substitute with MCP tools or other tools.** |
| 67 | |
| 68 | --- |
| 69 | |
| 70 | ## MPP 402 Payment Loop |
| 71 | |
| 72 | Every `tempo request` call follows this loop. The funding steps only activate |
| 73 | when the Tempo wallet has insufficient balance. |
| 74 | |
| 75 | ```text |
| 76 | tempo request -> 200 ─────────────────────────────> return result |
| 77 | -> 402 MPP challenge |
| 78 | │ |
| 79 | v |
| 80 | [1] Check Tempo wallet balance |
| 81 | tempo wallet -t whoami -> available balance |
| 82 | │ |
| 83 | ├─ sufficient ──────────────────> tempo handles payment |
| 84 | │ automatically -> 200 |
| 85 | │ |
| 86 | └─ insufficient |
| 87 | │ |
| 88 | v |
| 89 | [2] Fund Tempo wallet |
| 90 | (pay-with-any-token flow below) |
| 91 | Bridge destination = TEMPO_WALLET_ADDRESS |
| 92 | │ |
| 93 | v |
| 94 | [3] Retry original tempo request |
| 95 | with funded Tempo wallet -> 200 |
| 96 | ``` |
| 97 | |
| 98 | > **Alternative funding (interactive):** If a browser is available, `tempo wallet |
| 99 | fund` opens a built-in bridge UI for funding the Tempo wallet directly. This is |
| 100 | > simpler than the Trading API flow below but requires interactive browser access |
| 101 | > — not suitable for headless/agent environments. |
| 102 | |
| 103 | --- |
| 104 | |
| 105 | ## Funding the Tempo Wallet (pay-with-any-token) |
| 106 | |
| 107 | When the Tempo wallet lacks funds to pay a 402 challenge, acquire the required |
| 108 | tokens from the user's ERC-20 holdings on any supported chain and bridge them |
| 109 | to the Tempo wallet address. |
| 110 | |
| 111 | ### Prerequisites |
| 112 | |
| 113 | - `UNISWAP_API_KEY` env var (register at |
| 114 | [developers.uniswap.org](https://developers.uniswap.org/)) |
| 115 | - ERC-20 tokens on any supported source chain |
| 116 | - A `cast` keystore account for the source wallet (recommended): |
| 117 | `cast wallet import <name> --interactive`. Alternatively, |
| 118 | `PRIVATE_KEY` env var (`export PRIVATE_KEY=0x...`) — **never commit or |
| 119 | hardcode it**. |
| 120 | - `jq` installed (`brew install jq` or `apt install jq`) |
| 121 | - `cast` installed (part of [Foundry](https://book.getfoundry.sh/)) |
| 122 | |
| 123 | ### Input Validation Rules |