# Send tron-x402-payment to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "tron-x402-payment",
    "name": "tron-x402-payment",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/wzc1206/tron-x402-payment",
    "canonicalUrl": "https://clawhub.ai/wzc1206/tron-x402-payment",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/tron-x402-payment",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=tron-x402-payment",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "package.json",
      "SKILL.md",
      "tsconfig.json",
      "src/x402_tron_invoke.ts",
      "dist/x402_tron_invoke.js",
      "dist/package.json"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-07T17:22:31.273Z",
      "expiresAt": "2026-05-14T17:22:31.273Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
        "contentDisposition": "attachment; filename=\"afrexai-annual-report-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/tron-x402-payment"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/tron-x402-payment",
    "downloadUrl": "https://openagent3.xyz/downloads/tron-x402-payment",
    "agentUrl": "https://openagent3.xyz/skills/tron-x402-payment/agent",
    "manifestUrl": "https://openagent3.xyz/skills/tron-x402-payment/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/tron-x402-payment/agent.md"
  }
}
```
## Documentation

### x402 Payment Protocol for TRON Agents

Invoke x402-enabled AI agent endpoints with automatic TRC20 token payments on TRON.
Currently recommended tokens: USDT, USDD.

### Quick Start

The tool x402_tron_invoke is implemented by the compiled script dist/x402_tron_invoke.js.

The script is pre-built and ready to run. You can execute it directly from the command line:

# v2 Invoke
node dist/x402_tron_invoke.js --url https://api.example.com --entrypoint chat --input '{"prompt": "hi"}'

# Direct/Discovery
node dist/x402_tron_invoke.js --url https://api.example.com/.well-known/agent.json

### How It Works

The x402_tron_invoke tool:

Constructs the endpoint URL:

If entrypoint is provided: {url}/entrypoints/{entrypoint}/invoke (v2)
Otherwise: Uses {url} as-is (v1 / Discovery)


Makes a request (POST for v2, GET default for v1)
If 402 Payment Required is returned:

Parses payment requirements
Checks wallet balance and allowance
Performs an infinite approval if allowance is insufficient
Signs the payment permit (EIP-712 / TRON Typed Data)
Retries the request with X-PAYMENT header


Returns the response

### Prerequisites

Wallet: A TRON private key must be available. The skill automatically looks for it in:

TRON_PRIVATE_KEY environment variable.
~/.mcporter/mcporter.json (AIBank standard).
x402-config.json in the current/home directory.


Tokens: Wallet needs USDT/USDD and some TRX for gas.
TronGrid API Key: Required for Mainnet to avoid rate limits (TRON_GRID_API_KEY).

### x402_tron_invoke

Invokes an HTTP endpoint with automatic payment handling.

Modes:

v2 Agent Invoke (Recommended): Provide url (Base URL) + entrypoint.

Constructs: {url}/entrypoints/{entrypoint}/invoke
Wraps input: {"input": <input>}
Method: POST


v1 / Direct / Discovery: Provide url (Full URL) without entrypoint.

Uses the URL as-is.
Method: GET (default) or specified via method.
Agent Advice: Use this mode for discovery. If url returns 404, try appending /.well-known/agent.json or /entrypoints.


Status Check: Provide --check or --status.

Verifies if TRON_PRIVATE_KEY is correctly configured and outputs the associated wallet address.
Checks if TRON_GRID_API_KEY is present (Required for Mainnet).
Agent Advice: ALWAYS use this instead of env or echo $TRON_PRIVATE_KEY.

ParameterTypeRequiredDescriptionurlstringYes*Base URL (v2) or Full URL (v1/Discovery). *Not required for --check.entrypointstringNoEntrypoint name. Required for v2 Invoke.inputobjectNoInput data.methodstringNoHTTP method. Default: POST (v2), GET (Direct).networkstringNomainnet, nile, shasta (Default: nile).checkbooleanNoVerify wallet configuration and output address.

### Example: Chat with Agent (v2 Invoke)

node dist/x402_tron_invoke.js --url https://api.example.com --entrypoint chat --input '{"prompt": "Tell me a joke"}'

(Sends POST https://api.example.com/entrypoints/chat/invoke)

### Example: Agent Discovery (Direct)

Manifest: Fetch agent metadata.
node dist/x402_tron_invoke.js --url https://api.example.com/.well-known/agent.json



List Entrypoints: List available functions.
node dist/x402_tron_invoke.js --url https://api.example.com/entrypoints

Each entrypoint typically returns:

Path: /entrypoints/{name}/invoke
Pricing: Cost in tokens (e.g., 1000 units)
Network: Usually nile or mainnet
Input Schema: Expected JSON format for the input parameter

### Example: Raw URL (Legacy)

node dist/x402_tron_invoke.js --url https://api.example.com/chat --method POST --input '{"prompt": "Tell me a joke"}'

### Cost Reference (USDT/USDD)

TokenNetworkContract AddressDecimalsUSDTMainnetTR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t6USDTNileTXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf6USDTShastaTG3XXyExBkPp9nzdajDZsozEu4BkaSJozs6USDDMainnetTXDk8mbtRbXeYuMNS83CfKPaYYT8XWv9Hz18USDDNileTGjgvdTWWrybVLaVeFqSyVqJQWjxqRYbaK18

Amount (raw)Value (USDT, 6 dec)Typical Use1000$0.001Single API call5000$0.005Multiple results10000$0.01Premium request1000000$1.00Large batch

### Understanding 402 Responses

When payment is required, agents return:

{
  "error": "X-PAYMENT header is required",
  "accepts": [{
    "scheme": "exact",
    "network": "nile",
    "maxAmountRequired": "1000",
    "payTo": "T...",
    "asset": "T..."
  }],
  "x402Version": 1
}

The tool handles this automatically.

### Supported Tokens

This tool supports TRC20 tokens compatible with the x402 protocol.
Recommended:

USDT (Tether)
USDD (Decentralized USD)

### Security Rules for Agents

No Private Key Output: The Agent MUST NOT print, echo, or output the TRON_PRIVATE_KEY or any other signing secret to the dialogue context.
Internal Loading Only: The Agent should rely on the skill or underlying scripts to load the key internally.
No Export Commands: The Agent MUST NOT execute shell commands that contain the private key as a literal string.
Sanitized Logs: Ensure that logs or error messages do not leak the key.
Silent Environment Checks: If you need to verify if an environment variable is set, use a "Silent Check".

Correct: [[ -n $TRON_PRIVATE_KEY ]] && echo "Configured" || echo "Missing"
Forbidden: echo $TRON_PRIVATE_KEY, env, printenv, set, export.


Disabled Commands List: Do NOT use the following commands in any environment containing sensitive keys:

env / printenv
echo $VARIABLE_NAME
set / export (without arguments)


Use the Check Tool: To safely verify wallet status, use node dist/x402_tron_invoke.js --check.

### ❌ Negative Example (CRITICAL FAILURE)

"I will check your private key now: echo $TRON_PRIVATE_KEY" -> STOP! This leaks the secret to the logs and UI.

### ✅ Positive Example

"I will verify the wallet configuration: node dist/x402_tron_invoke.js --check" -> SAFE. Only the public address is shown.

### "Private key not found"

Ensure the TRON_PRIVATE_KEY environment variable is set or a valid x402-config.json exists in the expected locations.

### "Insufficient Allowance"

The tool will attempt to broadcast an infinite approve transaction. This requires TRX for gas. Ensure your wallet has TRX.

### "Transaction Failed"

Check if you have enough Token balance (USDT/USDD) and TRX for gas.

### Binary and Image Handling

If the endpoint returns an image (Content-Type: image/*) or binary data (application/octet-stream):

The data is automatically saved to a temporary file (e.g., /tmp/x402_image_...).
The tool returns a JSON object with:

file_path: Path to the temporary file.
content_type: The MIME type of the content.
bytes: File size in bytes.


Important: The Agent is responsible for deleting the temporary file after it has been used.

### Network Reference

NetworkChain IDCAIP-2USDT ContractUSDD ContractTRON Mainnet0x2b6653dceip155:728126428, tron:mainnetTR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6tTXDk8mbtRbXeYuMNS83CfKPaYYT8XWv9HzTRON Nile0xcd8690dceip155:3448148188, tron:nileTXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBfTGjgvdTWWrybVLaVeFqSyVqJQWjxqRYbaKTRON Shasta0x94a9059eeip155:2494104990, tron:shastaTG3XXyExBkPp9nzdajDZsozEu4BkaSJozs-
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: wzc1206
- Version: 1.0.0
## Source health
- Status: healthy
- Source download looks usable.
- Yavira can redirect you to the upstream package for this source.
- Health scope: source
- Reason: direct_download_ok
- Checked at: 2026-05-07T17:22:31.273Z
- Expires at: 2026-05-14T17:22:31.273Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/tron-x402-payment)
- [Send to Agent page](https://openagent3.xyz/skills/tron-x402-payment/agent)
- [JSON manifest](https://openagent3.xyz/skills/tron-x402-payment/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/tron-x402-payment/agent.md)
- [Download page](https://openagent3.xyz/downloads/tron-x402-payment)