npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@erudite-intelligence/x402-tron-v2

v1.0.1

Published

x402 Payment Protocol V2 - Tron Network Plugin. The first and only x402 V2 implementation for TRON, enabling USDT TRC-20 payments for AI agents and web services.

Readme

@erudite-intelligence/x402-tron-v2

The first and only x402 V2 protocol implementation for the TRON blockchain. Enables USDT TRC-20 payments for AI agents, APIs, and web services using the HTTP 402 Payment Required standard.

Built by Erudite Intelligence LLC — FinCEN-registered MSB.

How It Works

Tron does not support EIP-3009 (transferWithAuthorization). This plugin uses an alternative approach that provides the same security guarantees:

  1. Client creates a TriggerSmartContract transaction calling the standard TRC-20 transfer(address, uint256) function.
  2. Client signs the transaction but does not broadcast it.
  3. The signed transaction is sent to the resource server via the PAYMENT-SIGNATURE HTTP header.
  4. The facilitator verifies the signature, recipient, amount, and token — then broadcasts the transaction on settlement.

No custom contracts are required. Payments use the standard USDT TRC-20 contract directly. The facilitator pays energy and bandwidth costs on behalf of the sender.

Install

npm install @erudite-intelligence/x402-tron-v2

Peer dependencies:

npm install @x402/core tronweb

| Dependency | Version | |---|---| | @x402/core | >=2.3.0 | | tronweb | >=6.0.0 |

Supported Networks

This plugin uses CAIP-2 identifiers:

| Network | CAIP-2 ID | Status | |---|---|---| | Mainnet | tron:27Lqcw | Production | | Shasta Testnet | tron:4oPwXB | Testing | | Nile Testnet | tron:6FhfKq | Testing |

Supported assets:

| Token | Mainnet Address | Decimals | |---|---|---| | USDT | TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t | 6 |

Usage

Facilitator (Verify & Settle Payments)

import { x402Facilitator } from "@x402/core/facilitator";
import { registerExactTronFacilitatorScheme } from "@erudite-intelligence/x402-tron-v2/exact/facilitator/register";
import TronWeb from "tronweb";

const tronWeb = new TronWeb({
  fullHost: "https://api.trongrid.io",
  privateKey: process.env.FACILITATOR_PRIVATE_KEY,
});

const facilitator = new x402Facilitator();

registerExactTronFacilitatorScheme(facilitator, {
  tronWeb,
  maxEnergyFeeSun: 100_000_000, // Max 100 TRX in energy costs
});

// The facilitator now handles Tron payments via /verify and /settle

Client (Create Payment Payloads)

import { x402Client } from "@x402/core/client";
import { registerExactTronClientScheme } from "@erudite-intelligence/x402-tron-v2/exact/client/register";
import TronWeb from "tronweb";

const tronWeb = new TronWeb({
  fullHost: "https://api.trongrid.io",
  privateKey: process.env.CLIENT_PRIVATE_KEY,
});

const client = new x402Client();

registerExactTronClientScheme(client, { tronWeb });

// Client is ready to sign Tron payment payloads

Server (Resource Server Middleware)

import { x402ResourceServer } from "@x402/core/server";
import { registerExactTronServerScheme } from "@erudite-intelligence/x402-tron-v2/exact/server/register";

const server = new x402ResourceServer(facilitatorClient);

registerExactTronServerScheme(server);

// Use with Express, Hono, Next.js, etc.
// Example with Express:
app.use(
  paymentMiddleware(
    {
      "GET /api/data": {
        accepts: {
          scheme: "exact",
          network: "tron:27Lqcw",
          price: "$0.01",
          payTo: "TYourMerchantTronAddress",
        },
        description: "Access to premium data",
      },
    },
    server,
  ),
);

Package Exports

// Main entry — constants, types, helpers
import { TRON_NETWORKS, getUsdtAddress, usdToUsdt } from "@erudite-intelligence/x402-tron-v2";

// Facilitator (verify + settle)
import { ExactTronFacilitatorScheme } from "@erudite-intelligence/x402-tron-v2/exact/facilitator";
import { registerExactTronFacilitatorScheme } from "@erudite-intelligence/x402-tron-v2/exact/facilitator/register";

// Client (create payment payloads)
import { ExactTronClientScheme } from "@erudite-intelligence/x402-tron-v2/exact/client";
import { registerExactTronClientScheme } from "@erudite-intelligence/x402-tron-v2/exact/client/register";

// Server (resource server integration)
import { ExactTronServerScheme } from "@erudite-intelligence/x402-tron-v2/exact/server";
import { registerExactTronServerScheme } from "@erudite-intelligence/x402-tron-v2/exact/server/register";

Security

This package has been independently audited:

  • Grok (xAI): Identified critical signature verification bypass and phantom feature claims. All findings resolved.
  • Gemini (Google): Approved for production after security fixes applied.
  • 17 attack-scenario tests covering signature forgery, transaction tampering, replay attacks, ABI manipulation, and amount spoofing — all passing.

Key security properties:

  • Transactions are decoded and the signature is verified via ECRecover before any verification or settlement occurs.
  • The transaction ID is recomputed from raw_data_hex to detect tampering.
  • A second-layer signature verification runs in settle() before broadcast as a belt-and-suspenders defense.
  • ABI data length is validated before parsing to prevent malformed input attacks.

Roadmap

The following features are defined in the type system but are not yet implemented. They have no effect if configured and will be activated in future releases:

  • useWrapperContract — Route payments through the EruditePay wrapper contract for automated on-chain fee collection.
  • feeDelegation — Facilitator covers energy costs on behalf of the sender.

Related

Why Tron

  • Largest USDT network: 95%+ of Tether's circulating supply lives on Tron.
  • Dominant payment rail: De facto stablecoin infrastructure across Southeast Asia, Africa, and Latin America.
  • Sub-cent transaction costs: $0.001–$0.01 per transfer.
  • 3-second block finality.
  • No existing x402 Tron support. This package fills that gap.

Author

Erudite Intelligence LLC FinCEN-registered Money Services Business eruditepay.com

License

MIT