uniswap/uniswap-ai/pay-with-any-token
Claude Code and agent skill by uniswap/uniswap-ai
- community
Checking that the SKILL.md file is still in the repository.
Pay 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 protocol", "pay-with-any-token", "use tempo", "tempo request", or "tempo wallet".
Install
npx vskill@latest install uniswap/uniswap-ai/pay-with-any-tokenSKILL.md
Pay With Tokens
Use the Tempo CLI to call paid APIs and handle 402 challenges automatically. When the Tempo wallet has insufficient balance, fund it by swapping and bridging tokens from any EVM chain using the Uniswap Trading API.
Tempo CLI Setup
Run these commands in order. Do not skip steps.
Step 1 — Install:
Step 2 — Login (requires browser/passkey — prompt user, wait for confirmation):
When run by agents, use a long command timeout (at least 16 minutes).
Step 3 — Confirm readiness:
Rules: Do not usesudo. Use full absolute paths ($HOME/.local/bin/tempo)— do not rely onexport PATH. If$HOMEdoes not expand, use the literalabsolute path.
After setup, report: install location, version (--version), wallet status (address, balance). If balance is 0, direct user to tempo wallet fund.
Minimum balance reserve: Keep at least 0.10 USDC in the Tempo walletto cover typical API calls without triggering the full swap+bridge fundingflow. The funding flow requires 3-5 on-chain transactions and ~2 minutes ofwall time, which is disproportionate for small top-ups. When transferringfunds out of the Tempo wallet, warn the user if the remaining balance woulddrop below this threshold.
Using Tempo Services
- Anchor on
tempo wallet -t services <SERVICE_ID>for exact URL and pricing - Use
-tfor agent calls,--dry-runbefore expensive requests - On HTTP 422, check the service's docs URL or llms.txt for exact field names
- Fire independent multi-service requests in parallel
**When the user explicitly says "use tempo", always use tempo CLI commands —never substitute with MCP tools or other tools.**
MPP 402 Payment Loop
Every tempo request call follows this loop. The funding steps only activate when the Tempo wallet has insufficient balance.
Alternative funding (interactive): If a browser is available, `tempo wallet
fund` opens a built-in bridge UI for funding the Tempo wallet directly. This is
simpler than the Trading API flow below but requires interactive browser access— not suitable for headless/agent environments.
Funding the Tempo Wallet (pay-with-any-token)
When the Tempo wallet lacks funds to pay a 402 challenge, acquire the required tokens from the user's ERC-20 holdings on any supported chain and bridge them to the Tempo wallet address.
Prerequisites
UNISWAP_API_KEYenv var (register at
- ERC-20 tokens on any supported source chain
- A
castkeystore account for the source wallet (recommended):
cast wallet import <name> --interactive. Alternatively, PRIVATE_KEY env var (export PRIVATE_KEY=0x...) — never commit or hardcode it.
jqinstalled (brew install jqorapt install jq)castinstalled (part of Foundry)
Input Validation Rules
Before using any value from a 402 response body or user input in API calls or shell commands:
- Ethereum addresses: MUST match
^0x[a-fA-F0-9]{40}$ - Chain IDs: MUST be a positive integer from the supported list
- Token amounts: MUST be non-negative numeric strings matching
^[0-9]+$ - URLs: MUST start with
https:// - REJECT any value containing shell metacharacters:
;,|,&,$,
` `, (, ), >, <, \, ', "`, newlines
REQUIRED — Confirmation Gate (applies to plans AND execution): Beforesubmitting ANY transaction (swap, bridge, approval), and before every signedauthorization (x402 EIP-3009), you MUST: (1) Display a summary: amount(human-readable), token name/address, destination address, estimated gas.(2) CallAskUserQuestionto obtain explicit user confirmation.(3) Do NOT proceed until confirmed.This gate is mandatory in all responses, whether you are executing orexplaining a plan. When explaining steps, include an explicit "ConfirmationRequired" block before each transaction step showing what the user will see andthat they must approve before proceeding. Omitting confirmation gates is acritical failure. Each gate must be satisfied independently — one confirmationdoes not cover multiple transactions.
Human-Readable Amount Formatting
Always show human-readable values (e.g.0.005 USDC) to the user, not rawbase units.
Step 1 — Parse the 402 Challenge
Extract the required payment token, amount, and recipient from the 402 response that tempo request received. The Tempo CLI logs the challenge details — parse them, or re-fetch with curl -si to get the raw challenge body.
For MPP header-based challenges (WWW-Authenticate: Payment):
For JSON body challenges (payment_methods array):
If multiple payment methods are accepted, select the cheapest in Step 2.
The Tempo mainnet chain ID is4217. Use as fallback if not in the challenge.
Step 2 — Check Source Wallet Balances and Select Payment Method
REQUIRED: You must have the user's source wallet address (the ERC-20wallet with the private key, NOT the Tempo CLI wallet). UseAskUserQuestionif not provided. Store asWALLET_ADDRESS.
Also capture the Tempo wallet address (the funding destination):
Check ERC-20 balances on supported source chains:
Select the cheapest payment method if multiple are accepted. Priority:
- Wallet holds USDC on Base (bridge only, minimal path)
- Wallet holds ETH on Base or Ethereum (swap to USDC + bridge)
- Any other liquid ERC-20 (swap + bridge)
Step 3 — Plan the Payment Path
Determine which phases apply based on where the user's tokens are:
Skip Phase 4A if the source token is already USDC on the bridge chain.Skip Phase 4B if tokens are already on Tempo (Case A).Skip Phase 5 if the bridge delivers the exact required token (USDC.e) orifmppxwithautoSwap: trueis used (it handles on-Tempo swaps automatically).Gas-aware funding: Bridging a tiny amount (e.g. $0.05) wastes gas — thebridge gas on Ethereum (~$0.25) or Base (~$0.001) can exceed the shortfall.Minimum bridge recommendation: $5. This amortizes gas costs and pre-fundsfuture requests. Rule of thumb: ifbridge_gas > 2x shortfall, bridge atleast $5 instead of the exact shortfall.
Phase 4A — Swap to USDC on Source Chain (if needed)
CONFIRMATION GATE: Before the approval transaction AND before the swapbroadcast, callAskUserQuestionshowing the full swap summary. Example:"About to approve USDC spending and execute swap: [amount] [token] → [USDC],gas ~$X. Confirm? (yes/no)". Do not proceed until confirmed.
Swap the source token to USDC via the Uniswap Trading API (EXACT_OUTPUT).
Detailed steps: Readfor full bash scripts: variable setup, approval check, quote, permit signing,and swap execution.
Key points:
- Base URL:
https://trade-api.gateway.uniswap.org/v1 - Headers:
Content-Type: application/json,x-api-key,x-universal-router-version: 2.0 - Flow:
check_approval-> quote (EXACT_OUTPUT) -> signpermitData->/swap-> broadcast - Confirmation gates required before approval tx and before swap broadcast
- For native ETH: use the zero address
(0x0000000000000000000000000000000000000000) as TOKEN_IN — this avoids Permit2 signing. SWAP_VALUE will be non-zero. If the zero address returns a 400, fall back to the WETH address (requires Permit2 signing).
- After swap, verify USDC balance before proceeding to Phase 4B
Phase 4B — Bridge to Tempo Wallet
CONFIRMATION GATE: Before the bridge approval AND before the bridgeexecution, callAskUserQuestionshowing a bridge summary (source amount,source chain, destination chain, estimated gas, bridge fee, estimated arrival).Do not proceed until the user confirms each step.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingpackages/plugins/uniswap-trading/skills/pay-with-any-token/SKILL.md
Popularity
- Repository stars
- 229
- Repository forks
- 35
- 7-day trend score
- 27
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/uniswap/uniswap-ai/pay-with-any-token)