pay-for-service

📁 agnicpay/agnic-wallet-skills 📅 6 days ago
3
总安装量
3
周安装量
#56551
全站排名
安装命令
npx skills add https://github.com/agnicpay/agnic-wallet-skills --skill pay-for-service

Agent 安装分布

opencode 3
antigravity 3
github-copilot 3
codex 3
kimi-cli 3
gemini-cli 3

Skill 文档

Pay for Service

Make a paid x402 request to an API endpoint. AgnicPay handles the payment automatically.

Steps

  1. Verify authentication:

    npx agnic@latest status --json
    
  2. Check balance to ensure sufficient funds:

    npx agnic@latest balance --network base --json
    
  3. Make the x402 payment request:

    npx agnic@latest x402 pay "<url>" --json
    
  4. For POST requests with a body:

    npx agnic@latest x402 pay "<url>" --method POST --body '{"key": "value"}' --json
    

Parameters

  • <url> — Full URL of the x402-enabled API endpoint
  • --method — HTTP method (default: GET)
  • --body — Request body as JSON string (for POST/PUT)

Example

npx agnic@latest x402 pay "https://api.example.com/analysis" \
  --method POST \
  --body '{"query": "latest market data"}' \
  --json

Expected Output

{
  "status": 200,
  "cost": "0.001",
  "network": "base",
  "transactionHash": "0xabc123...",
  "data": { "result": "..." }
}

Error Handling

  • If not authenticated: prompt user to run npx agnic@latest auth login
  • If balance is insufficient, inform the user and suggest funding
  • If the API returns an error, show the status code and response body
  • The --body flag must be valid JSON; if invalid, the CLI will report the parse error