@t402/tron 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +136 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # @t402/tron
2
+
3
+ TRON blockchain implementation of the t402 payment protocol using the **Exact** payment scheme with TRC-20 token transfers.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @t402/tron
9
+ ```
10
+
11
+ ## Overview
12
+
13
+ This package provides three main components for handling t402 payments on TRON:
14
+
15
+ - **Client** - For applications that need to make payments (sign TRC-20 transfers)
16
+ - **Server** - For resource servers that accept payments and build payment requirements
17
+ - **Facilitator** - For payment processors that verify signatures and execute on-chain settlements
18
+
19
+ ## Quick Start
20
+
21
+ ### Client
22
+
23
+ ```typescript
24
+ import { ExactTronClient } from "@t402/tron/exact/client";
25
+
26
+ const client = new ExactTronClient(signer);
27
+ const payload = await client.createPaymentPayload(requirements);
28
+ ```
29
+
30
+ ### Server
31
+
32
+ ```typescript
33
+ import { ExactTronServer } from "@t402/tron/exact/server";
34
+ import { t402ResourceServer } from "@t402/express";
35
+ import { HTTPFacilitatorClient } from "@t402/core/server";
36
+
37
+ const facilitator = new HTTPFacilitatorClient({ url: "https://facilitator.t402.io" });
38
+ const resourceServer = new t402ResourceServer(facilitator)
39
+ .register("tron:mainnet", new ExactTronServer());
40
+ ```
41
+
42
+ ### Facilitator
43
+
44
+ ```typescript
45
+ import { ExactTronFacilitator } from "@t402/tron/exact/facilitator";
46
+
47
+ const facilitator = new ExactTronFacilitator(signer);
48
+ ```
49
+
50
+ ## Package Exports
51
+
52
+ ### Main Package (`@t402/tron`)
53
+
54
+ All constants, types, utilities, token registry, and scheme classes.
55
+
56
+ ### Subpath Exports
57
+
58
+ - `@t402/tron/exact/client` - Client-only imports
59
+ - `@t402/tron/exact/server` - Server-only imports
60
+ - `@t402/tron/exact/facilitator` - Facilitator-only imports
61
+
62
+ ## Supported Networks
63
+
64
+ | Network | CAIP-2 Identifier |
65
+ |---------|-------------------|
66
+ | TRON Mainnet | `tron:mainnet` |
67
+ | TRON Nile Testnet | `tron:nile` |
68
+ | TRON Shasta Testnet | `tron:shasta` |
69
+
70
+ ## Supported Assets
71
+
72
+ | Token | Network | Contract Address |
73
+ |-------|---------|-----------------|
74
+ | USDT | Mainnet | `TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t` |
75
+ | USDT | Nile | `TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf` |
76
+
77
+ ## Token Utilities
78
+
79
+ ```typescript
80
+ import {
81
+ getDefaultToken,
82
+ getTRC20Config,
83
+ getNetworkTokens,
84
+ getSupportedNetworks,
85
+ isNetworkSupported,
86
+ } from "@t402/tron";
87
+
88
+ // Check if a network is supported
89
+ isNetworkSupported("tron:mainnet"); // true
90
+
91
+ // Get USDT config for mainnet
92
+ const config = getTRC20Config("tron:mainnet", "USDT");
93
+
94
+ // Get all supported networks
95
+ const networks = getSupportedNetworks();
96
+ ```
97
+
98
+ ## Address & Amount Utilities
99
+
100
+ ```typescript
101
+ import {
102
+ validateTronAddress,
103
+ convertToSmallestUnits,
104
+ convertFromSmallestUnits,
105
+ estimateTransactionFee,
106
+ formatAddress,
107
+ } from "@t402/tron";
108
+
109
+ // Validate TRON address (base58check T-prefix)
110
+ validateTronAddress("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"); // true
111
+
112
+ // Convert amounts (6 decimals for USDT)
113
+ convertToSmallestUnits("1.5", 6); // 1500000n
114
+ convertFromSmallestUnits(1500000n, 6); // "1.5"
115
+ ```
116
+
117
+ ## Security
118
+
119
+ - Client signs TRC-20 transfer transactions using ECDSA (secp256k1)
120
+ - Replay protection via Protobuf nonce and expiration
121
+ - Facilitator verifies signatures before broadcasting to TRON network
122
+
123
+ ## Development
124
+
125
+ ```bash
126
+ pnpm build # Build the package
127
+ pnpm test # Run unit tests
128
+ pnpm test:integration # Run integration tests
129
+ ```
130
+
131
+ ## Related Packages
132
+
133
+ - `@t402/core` - Core protocol types and client
134
+ - `@t402/fetch` - HTTP wrapper with automatic payment handling
135
+ - `@t402/evm` - EVM chains implementation
136
+ - `@t402/ton` - TON implementation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t402/tron",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "main": "./dist/cjs/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/cjs/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  "vitest": "^3.2.4"
37
37
  },
38
38
  "dependencies": {
39
- "@t402/core": "2.3.0"
39
+ "@t402/core": "2.3.1"
40
40
  },
41
41
  "exports": {
42
42
  ".": {