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:
CODEBLOCK0
How It Works
The x402_tron_invoke tool:
1. Constructs the endpoint URL:
- If entrypoint is provided: {url}/entrypoints/{entrypoint}/invoke (v2)
- Otherwise: Uses {url} as-is (v1 / Discovery)
2. 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
4. Returns the response
Prerequisites
- Wallet: A TRON private key must be available. The skill automatically looks for it in:
1. TRON_PRIVATE_KEY environment variable.
2. ~/.mcporter/mcporter.json (AIBank standard).
3. 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).
Tool Reference
x402troninvoke
Invokes an HTTP endpoint with automatic payment handling.
2. 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.
3. 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.
Parameter
Type
Required
Description
INLINECODE29
string
Yes
Base URL (v2) or Full URL (v1/Discovery). Not required for --check.
INLINECODE31
string | No | Entrypoint name. Required for v2 Invoke. |
| input | object | No | Input data. |
| method | string | No | HTTP method. Default: POST (v2), GET (Direct). |
| network | string | No | mainnet, nile, shasta (Default: nile). |
| check | boolean | No | Verify wallet configuration and output address. |
Example: Chat with Agent (v2 Invoke)
CODEBLOCK1 (Sends POST https://api.example.com/entrypoints/chat/invoke)
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