Loading...
Loading...
Compare original and translation side by side
mkdir -p "$HOME/.local/bin" \
&& curl -fsSL https://tempo.xyz/install -o /tmp/tempo_install.sh \
&& TEMPO_BIN_DIR="$HOME/.local/bin" bash /tmp/tempo_install.sh"$HOME/.local/bin/tempo" wallet loginWhen run by agents, use a long command timeout (at least 16 minutes).
"$HOME/.local/bin/tempo" wallet -t whoamiRules: Do not use. Use full absolute paths (sudo) — do not rely on$HOME/.local/bin/tempo. Ifexport PATHdoes not expand, use the literal absolute path.$HOME
--versiontempo wallet fundmkdir -p "$HOME/.local/bin" \
&& curl -fsSL https://tempo.xyz/install -o /tmp/tempo_install.sh \
&& TEMPO_BIN_DIR="$HOME/.local/bin" bash /tmp/tempo_install.sh"$HOME/.local/bin/tempo" wallet login当由Agent运行时,设置较长的命令超时时间(至少16分钟)。
"$HOME/.local/bin/tempo" wallet -t whoami规则: 请勿使用。使用完整绝对路径(sudo)—— 不要依赖$HOME/.local/bin/tempo。如果export PATH无法展开,使用字面绝对路径。$HOME
--versiontempo wallet fundundefinedundefined
- Anchor on `tempo wallet -t services <SERVICE_ID>` for exact URL and pricing
- Use `-t` for agent calls, `--dry-run` before 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.**
---
- 以`tempo wallet -t services <SERVICE_ID>`获取准确的URL和定价
- Agent调用时使用`-t`参数,在执行高成本请求前使用`--dry-run`
- 遇到HTTP 422时,查看服务的文档URL或llms.txt获取准确的字段名称
- 并行发起独立的多服务请求
> **当用户明确要求"use tempo"时,务必使用Tempo CLI命令——绝不替换为MCP工具或其他工具。**
---tempo requesttempo request -> 200 ─────────────────────────────> return result
-> 402 MPP challenge
│
v
[1] Check Tempo wallet balance
tempo wallet -t whoami -> available balance
│
├─ sufficient ──────────────────> tempo handles payment
│ automatically -> 200
│
└─ insufficient
│
v
[2] Fund Tempo wallet
(pay-with-any-token flow below)
Bridge destination = TEMPO_WALLET_ADDRESS
│
v
[3] Retry original tempo request
with funded Tempo wallet -> 200tempo requesttempo request -> 200 ─────────────────────────────> return result
-> 402 MPP challenge
│
v
[1] Check Tempo wallet balance
tempo wallet -t whoami -> available balance
│
├─ sufficient ──────────────────> tempo handles payment
│ automatically -> 200
│
└─ insufficient
│
v
[2] Fund Tempo wallet
(pay-with-any-token flow below)
Bridge destination = TEMPO_WALLET_ADDRESS
│
v
[3] Retry original tempo request
with funded Tempo wallet -> 200UNISWAP_API_KEYPRIVATE_KEYexport PRIVATE_KEY=0x...jqbrew install jqapt install jqUNISWAP_API_KEYPRIVATE_KEYexport PRIVATE_KEY=0x...jqbrew install jqapt install jq^0x[a-fA-F0-9]{40}$^[0-9]+$https://;|&$`()><\'"REQUIRED: Before submitting ANY transaction (swap, bridge, approval), useto show the user a summary (amount, token, destination, estimated gas) and obtain explicit confirmation. Never auto-submit. Each confirmation gate must be satisfied independently.AskUserQuestion
^0x[a-fA-F0-9]{40}$^[0-9]+$https://;|&$`()><\'"必填: 在提交任何交易(兑换、跨链转移、授权)之前,使用向用户显示摘要(金额、代币、目标地址、预估Gas费)并获取明确确认。绝不要自动提交。每个确认环节都必须独立完成。AskUserQuestion
get_token_decimals() {
local token_addr="$1" rpc_url="$2"
cast call "$token_addr" "decimals()(uint8)" --rpc-url "$rpc_url" 2>/dev/null || echo "18"
}
format_token_amount() {
local amount="$1" decimals="$2"
echo "scale=$decimals; $amount / (10 ^ $decimals)" | bc -l | sed 's/0*$//' | sed 's/\.$//'
}Always show human-readable values (e.g.) to the user, not raw base units.0.005 USDC
get_token_decimals() {
local token_addr="$1" rpc_url="$2"
cast call "$token_addr" "decimals()(uint8)" --rpc-url "$rpc_url" 2>/dev/null || echo "18"
}
format_token_amount() {
local amount="$1" decimals="$2"
echo "scale=$decimals; $amount / (10 ^ $decimals)" | bc -l | sed 's/0*$//' | sed 's/\.$//'
}始终向用户显示人类可读的值(例如),而非原始基础单位。0.005 USDC
tempo requestcurl -siWWW-Authenticate: PaymentREQUEST_B64=$(echo "$WWW_AUTHENTICATE" | grep -oE 'request="[^"]+"' | sed 's/request="//;s/"$//')
REQUEST_JSON=$(echo "${REQUEST_B64}==" | base64 --decode 2>/dev/null)
REQUIRED_AMOUNT=$(echo "$REQUEST_JSON" | jq -r '.amount')
PAYMENT_TOKEN=$(echo "$REQUEST_JSON" | jq -r '.currency')
RECIPIENT=$(echo "$REQUEST_JSON" | jq -r '.recipient')
TEMPO_CHAIN_ID=$(echo "$REQUEST_JSON" | jq -r '.methodDetails.chainId')payment_methodsNUM_METHODS=$(echo "$CHALLENGE_BODY" | jq '.payment_methods | length')
PAYMENT_METHODS=$(echo "$CHALLENGE_BODY" | jq -c '.payment_methods')
RECIPIENT=$(echo "$CHALLENGE_BODY" | jq -r '.payment_methods[0].recipient')
TEMPO_CHAIN_ID=$(echo "$CHALLENGE_BODY" | jq -r '.payment_methods[0].chain_id')The Tempo mainnet chain ID is. Use as fallback if not in the challenge.4217
tempo requestcurl -siWWW-Authenticate: PaymentREQUEST_B64=$(echo "$WWW_AUTHENTICATE" | grep -oE 'request="[^"]+"' | sed 's/request="//;s/"$//')
REQUEST_JSON=$(echo "${REQUEST_B64}==" | base64 --decode 2>/dev/null)
REQUIRED_AMOUNT=$(echo "$REQUEST_JSON" | jq -r '.amount')
PAYMENT_TOKEN=$(echo "$REQUEST_JSON" | jq -r '.currency')
RECIPIENT=$(echo "$REQUEST_JSON" | jq -r '.recipient')
TEMPO_CHAIN_ID=$(echo "$REQUEST_JSON" | jq -r '.methodDetails.chainId')payment_methodsNUM_METHODS=$(echo "$CHALLENGE_BODY" | jq '.payment_methods | length')
PAYMENT_METHODS=$(echo "$CHALLENGE_BODY" | jq -c '.payment_methods')
RECIPIENT=$(echo "$CHALLENGE_BODY" | jq -r '.payment_methods[0].recipient')
TEMPO_CHAIN_ID=$(echo "$CHALLENGE_BODY" | jq -r '.payment_methods[0].chain_id')Tempo主网链ID为。如果验证请求中未提供,可作为 fallback 值使用。4217
REQUIRED: You must have the user's source wallet address (the ERC-20 wallet with the private key, NOT the Tempo CLI wallet). Useif not provided. Store asAskUserQuestion.WALLET_ADDRESS
TEMPO_WALLET_ADDRESS=$("$HOME/.local/bin/tempo" wallet -t whoami | grep -oE '0x[a-fA-F0-9]{40}' | head -1)undefined必填: 必须获取用户的源钱包地址(持有私钥的ERC-20钱包,而非Tempo CLI钱包)。如果未提供,使用获取。将其存储为AskUserQuestion。WALLET_ADDRESS
TEMPO_WALLET_ADDRESS=$("$HOME/.local/bin/tempo" wallet -t whoami | grep -oE '0x[a-fA-F0-9]{40}' | head -1)undefined
**Select the cheapest payment method** if multiple are accepted. Priority:
1. Wallet holds USDC on Base (bridge only, minimal path)
2. Wallet holds ETH on Base or Ethereum (swap to USDC + bridge)
3. Any other liquid ERC-20 (swap + bridge)
```bash
REQUIRED_AMOUNT=$(echo "$PAYMENT_METHODS" | jq -r ".[$SELECTED_INDEX].amount")
PAYMENT_TOKEN=$(echo "$PAYMENT_METHODS" | jq -r ".[$SELECTED_INDEX].token")
**如果支持多种支付方式,选择成本最低的一种**。优先级:
1. 钱包在Base链上持有USDC(仅跨链转移,路径最短)
2. 钱包在Base或以太坊链上持有ETH(兑换为USDC + 跨链转移)
3. 其他任何流动性ERC-20代币(兑换 + 跨链转移)
```bash
REQUIRED_AMOUNT=$(echo "$PAYMENT_METHODS" | jq -r ".[$SELECTED_INDEX].amount")
PAYMENT_TOKEN=$(echo "$PAYMENT_METHODS" | jq -r ".[$SELECTED_INDEX].token")Source token (Base/Ethereum)
-> [Phase 4A: Uniswap Trading API swap] -> native USDC (bridge asset)
-> [Phase 4B: bridge via Trading API] -> USDC.e on Tempo (to TEMPO_WALLET_ADDRESS)
-> tempo request retries automatically with funded walletSkip Phase 4A if the source token is already USDC on the bridge chain.
Source token (Base/Ethereum)
-> [Phase 4A: Uniswap Trading API swap] -> native USDC (bridge asset)
-> [Phase 4B: bridge via Trading API] -> USDC.e on Tempo (to TEMPO_WALLET_ADDRESS)
-> tempo request retries automatically with funded wallet跳过Phase 4A如果源代币已经是跨链链上的USDC。
EXACT_OUTPUTDetailed steps: Read references/trading-api-flows.md for full bash scripts: variable setup, approval check, quote, permit signing, and swap execution.
https://trade-api.gateway.uniswap.org/v1Content-Type: application/jsonx-api-keyx-universal-router-version: 2.0check_approvalEXACT_OUTPUTpermitData/swapTOKEN_INSWAP_VALUEEXACT_OUTPUT详细步骤: 阅读references/trading-api-flows.md获取完整bash脚本:变量配置、授权检查、报价、许可签名和兑换执行。
https://trade-api.gateway.uniswap.org/v1Content-Type: application/jsonx-api-keyx-universal-router-version: 2.0check_approvalEXACT_OUTPUTpermitData/swapTOKEN_INSWAP_VALUECRITICAL: The bridge recipient must be(fromTEMPO_WALLET_ADDRESS), NOTtempo wallet -t whoami(your source ERC-20 wallet). This funds the Tempo CLI wallet soWALLET_ADDRESScan retry the payment.tempo requestDetailed steps: Read references/trading-api-flows.md for full bash scripts: approval, bridge quote, execution, and arrival polling.
TEMPO_WALLET_ADDRESScheck_approvalEXACT_OUTPUT/swaptempo requestBalance buffer: On Tempo,may report more than is spendable. Apply a 2x buffer when comparing tobalanceOf. If short, swap additional tokens to top up.REQUIRED_AMOUNT
关键提示: 跨链转移的收款方必须是(来自TEMPO_WALLET_ADDRESS),而非tempo wallet -t whoami(用户的源ERC-20钱包)。这会为Tempo CLI钱包充值,以便WALLET_ADDRESS可以重试付费。tempo request详细步骤: 阅读references/trading-api-flows.md获取完整bash脚本:授权、跨链报价、执行和到账轮询。
TEMPO_WALLET_ADDRESScheck_approvalEXACT_OUTPUT/swaptempo request余额缓冲: 在Tempo链上,返回的余额可能大于可花费的金额。与balanceOf比较时,应用2倍缓冲。如果余额不足,兑换额外代币进行补充。REQUIRED_AMOUNT
PROTOCOL"x402"has("x402Version")"exact"transferWithAuthorizationDetailed steps: Read references/credential-construction.md for full code: prerequisite checks, nonce generation, EIP-3009 signing, X-PAYMENT payload construction, and retry.
has("x402Version")X402_NETWORKTransferWithAuthorizationvalue--arg--argjson| Protocol | Version | Handler |
|---|---|---|
| MPP | v1 | Tempo CLI |
| x402 | v1 | Manual (above) |
PROTOCOL"x402"has("x402Version")"exact"transferWithAuthorization详细步骤: 阅读references/credential-construction.md获取完整代码:前提检查、随机数生成、EIP-3009签名、X-PAYMENT负载构建和重试。
has("x402Version")X402_NETWORKTransferWithAuthorizationvalue--arg--argjson| Protocol | Version | Handler |
|---|---|---|
| MPP | v1 | Tempo CLI |
| x402 | v1 | Manual (above) |
| Situation | Action |
|---|---|
| Reinstall via install script; use full path |
| Reinstall; |
| |
| |
| HTTP 422 from service | Check service details + llms.txt for exact field names |
| Balance 0 / insufficient | Trigger pay-with-any-token funding flow |
| Service not found | Broaden search query |
| Timeout | Retry with |
| Challenge body is malformed | Report raw body to user; do not proceed |
| Approval transaction fails | Surface error; check gas and allowances |
| Quote API returns 400 | Log request/response; check amount formatting |
| Quote API returns 429 | Wait and retry with exponential backoff |
| Swap data is empty after /swap | Quote expired; re-fetch quote |
| Bridge times out | Check bridge explorer; do not re-submit |
| x402 payment rejected (402) | Check domain name/version, validBefore, nonce freshness |
| InsufficientBalance on Tempo | Swap more tokens on Tempo, then retry |
| Apply 2x buffer; top up before retrying |
| Situation | Action |
|---|---|
| Reinstall via install script; use full path |
| Reinstall; |
| |
| |
| HTTP 422 from service | Check service details + llms.txt for exact field names |
| Balance 0 / insufficient | Trigger pay-with-any-token funding flow |
| Service not found | Broaden search query |
| Timeout | Retry with |
| Challenge body is malformed | Report raw body to user; do not proceed |
| Approval transaction fails | Surface error; check gas and allowances |
| Quote API returns 400 | Log request/response; check amount formatting |
| Quote API returns 429 | Wait and retry with exponential backoff |
| Swap data is empty after /swap | Quote expired; re-fetch quote |
| Bridge times out | Check bridge explorer; do not re-submit |
| x402 payment rejected (402) | Check domain name/version, validBefore, nonce freshness |
| InsufficientBalance on Tempo | Swap more tokens on Tempo, then retry |
| Apply 2x buffer; top up before retrying |
https://tempo.xyzhttps://tempo.xyz/installhttps://trade-api.gateway.uniswap.org/v1https://mpp.devhttps://mpp.dev/api/serviceshttps://mainnet.docs.tempo.xyz4217https://rpc.presto.tempo.xyzhttps://explore.mainnet.tempo.xyz0x20c00000000000000000000000000000000000000x20C000000000000000000000b9537d11c60E8b500xdec00000000000000000000000000000000000000x000000000022d473030f116ddee9f6b43ac78ba3mppxnpm install mppx viem0x833589fCD6eDb6E08f4c7C32D4f71b54bdA029130xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB480xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8https://github.com/coinbase/x402https://tempo.xyzhttps://tempo.xyz/installhttps://trade-api.gateway.uniswap.org/v1https://mpp.devhttps://mpp.dev/api/serviceshttps://mainnet.docs.tempo.xyz4217https://rpc.presto.tempo.xyzhttps://explore.mainnet.tempo.xyz0x20c00000000000000000000000000000000000000x20C000000000000000000000b9537d11c60E8b500xdec00000000000000000000000000000000000000x000000000022d473030f116ddee9f6b43ac78ba3mppxnpm install mppx viem0x833589fCD6eDb6E08f4c7C32D4f71b54bdA029130xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB480xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8https://github.com/coinbase/x402