@t402/tron 1.0.0

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 (35) hide show
  1. package/dist/cjs/exact/client/index.d.ts +90 -0
  2. package/dist/cjs/exact/client/index.js +172 -0
  3. package/dist/cjs/exact/client/index.js.map +1 -0
  4. package/dist/cjs/exact/facilitator/index.d.ts +114 -0
  5. package/dist/cjs/exact/facilitator/index.js +344 -0
  6. package/dist/cjs/exact/facilitator/index.js.map +1 -0
  7. package/dist/cjs/exact/server/index.d.ts +123 -0
  8. package/dist/cjs/exact/server/index.js +350 -0
  9. package/dist/cjs/exact/server/index.js.map +1 -0
  10. package/dist/cjs/index.d.ts +237 -0
  11. package/dist/cjs/index.js +863 -0
  12. package/dist/cjs/index.js.map +1 -0
  13. package/dist/cjs/signer-BB-HLs-P.d.ts +261 -0
  14. package/dist/esm/chunk-A2E6FJU3.mjs +98 -0
  15. package/dist/esm/chunk-A2E6FJU3.mjs.map +1 -0
  16. package/dist/esm/chunk-CH6GR2VO.mjs +267 -0
  17. package/dist/esm/chunk-CH6GR2VO.mjs.map +1 -0
  18. package/dist/esm/chunk-L773HPM3.mjs +202 -0
  19. package/dist/esm/chunk-L773HPM3.mjs.map +1 -0
  20. package/dist/esm/chunk-RHOZZ6XV.mjs +285 -0
  21. package/dist/esm/chunk-RHOZZ6XV.mjs.map +1 -0
  22. package/dist/esm/exact/client/index.d.mts +90 -0
  23. package/dist/esm/exact/client/index.mjs +10 -0
  24. package/dist/esm/exact/client/index.mjs.map +1 -0
  25. package/dist/esm/exact/facilitator/index.d.mts +114 -0
  26. package/dist/esm/exact/facilitator/index.mjs +10 -0
  27. package/dist/esm/exact/facilitator/index.mjs.map +1 -0
  28. package/dist/esm/exact/server/index.d.mts +123 -0
  29. package/dist/esm/exact/server/index.mjs +10 -0
  30. package/dist/esm/exact/server/index.mjs.map +1 -0
  31. package/dist/esm/index.d.mts +237 -0
  32. package/dist/esm/index.mjs +113 -0
  33. package/dist/esm/index.mjs.map +1 -0
  34. package/dist/esm/signer-BB-HLs-P.d.mts +261 -0
  35. package/package.json +97 -0
@@ -0,0 +1,10 @@
1
+ import {
2
+ ExactTronScheme,
3
+ registerExactTronScheme
4
+ } from "../../chunk-RHOZZ6XV.mjs";
5
+ import "../../chunk-L773HPM3.mjs";
6
+ export {
7
+ ExactTronScheme,
8
+ registerExactTronScheme
9
+ };
10
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,237 @@
1
+ import { N as NetworkTRC20Registry, T as TRC20Config } from './signer-BB-HLs-P.mjs';
2
+ export { C as ClientTronSigner, E as ExactTronPayload, b as ExactTronPayloadV2, F as FacilitatorTronSigner, c as TransactionConfirmation, a as TronAuthorization, V as VerifyMessageResult } from './signer-BB-HLs-P.mjs';
3
+ export { ExactTronScheme as ExactTronClientScheme, ExactTronSchemeConfig as ExactTronClientSchemeConfig, TronClientConfig, registerExactTronScheme as registerExactTronClientScheme } from './exact/client/index.mjs';
4
+ export { ExactTronScheme as ExactTronServerScheme, ExactTronSchemeConfig as ExactTronServerSchemeConfig, TronResourceServerConfig, registerExactTronScheme as registerExactTronServerScheme } from './exact/server/index.mjs';
5
+ export { ExactTronScheme as ExactTronFacilitatorScheme, ExactTronSchemeConfig as ExactTronFacilitatorSchemeConfig, TronFacilitatorConfig, registerExactTronScheme as registerExactTronFacilitatorScheme } from './exact/facilitator/index.mjs';
6
+ import '@t402/core/types';
7
+ import '@t402/core/client';
8
+ import '@t402/core/server';
9
+ import '@t402/core/facilitator';
10
+
11
+ /**
12
+ * TRON Network Constants
13
+ *
14
+ * Network identifiers, endpoints, and configuration for TRON blockchain.
15
+ */
16
+ /** TRON Mainnet CAIP-2 identifier */
17
+ declare const TRON_MAINNET_CAIP2 = "tron:mainnet";
18
+ /** TRON Nile Testnet CAIP-2 identifier */
19
+ declare const TRON_NILE_CAIP2 = "tron:nile";
20
+ /** TRON Shasta Testnet CAIP-2 identifier */
21
+ declare const TRON_SHASTA_CAIP2 = "tron:shasta";
22
+ /** All supported TRON networks */
23
+ declare const TRON_NETWORKS: readonly ["tron:mainnet", "tron:nile", "tron:shasta"];
24
+ /** TRON network type */
25
+ type TronNetwork = (typeof TRON_NETWORKS)[number];
26
+ /** Network to endpoint mapping */
27
+ declare const NETWORK_ENDPOINTS: Record<string, string>;
28
+ /** TRC20 transfer function selector (transfer(address,uint256)) */
29
+ declare const TRC20_TRANSFER_SELECTOR = "a9059cbb";
30
+ /** TRC20 approve function selector (approve(address,uint256)) */
31
+ declare const TRC20_APPROVE_SELECTOR = "095ea7b3";
32
+ /** TRC20 balanceOf function selector (balanceOf(address)) */
33
+ declare const TRC20_BALANCE_OF_SELECTOR = "70a08231";
34
+ /** Default fee limit for TRC20 transfers (in SUN, 1 TRX = 1,000,000 SUN) */
35
+ declare const DEFAULT_FEE_LIMIT = 100000000;
36
+ /** Minimum fee limit for TRC20 transfers */
37
+ declare const MIN_FEE_LIMIT = 10000000;
38
+ /** Maximum fee limit for TRC20 transfers */
39
+ declare const MAX_FEE_LIMIT = 1000000000;
40
+ /** SUN per TRX (1 TRX = 1,000,000 SUN) */
41
+ declare const SUN_PER_TRX = 1000000;
42
+ /** Payment scheme identifier */
43
+ declare const SCHEME_EXACT = "exact";
44
+ /** Default transaction validity duration in seconds (1 hour) */
45
+ declare const DEFAULT_VALIDITY_DURATION = 3600;
46
+ /** Minimum validity buffer for verification (30 seconds) */
47
+ declare const MIN_VALIDITY_BUFFER = 30;
48
+ /** TRON address prefix (base58check) */
49
+ declare const TRON_ADDRESS_PREFIX = "T";
50
+ /** TRON address length (base58check format) */
51
+ declare const TRON_ADDRESS_LENGTH = 34;
52
+ /** TRON address hex prefix (0x41 in decimal = 65) */
53
+ declare const TRON_ADDRESS_HEX_PREFIX = 65;
54
+ /** USDT TRC20 contract addresses by network */
55
+ declare const USDT_ADDRESSES: Record<string, string>;
56
+ /** Default decimals for USDT */
57
+ declare const DEFAULT_USDT_DECIMALS = 6;
58
+ /** Default decimals for TRX */
59
+ declare const DEFAULT_TRX_DECIMALS = 6;
60
+
61
+ /**
62
+ * TRC20 Token Configuration
63
+ *
64
+ * Registry of supported TRC20 tokens for each TRON network.
65
+ */
66
+
67
+ /**
68
+ * Registry of TRC20 tokens by network
69
+ */
70
+ declare const TRC20_REGISTRY: Record<string, NetworkTRC20Registry>;
71
+ /**
72
+ * Get TRC20 configuration for a specific token on a network
73
+ *
74
+ * @param network - CAIP-2 network identifier
75
+ * @param symbol - Token symbol (e.g., "USDT")
76
+ * @returns Token configuration or undefined if not found
77
+ */
78
+ declare function getTRC20Config(network: string, symbol: string): TRC20Config | undefined;
79
+ /**
80
+ * Get all TRC20 tokens for a network
81
+ *
82
+ * @param network - CAIP-2 network identifier
83
+ * @returns Array of token configurations
84
+ */
85
+ declare function getNetworkTokens(network: string): TRC20Config[];
86
+ /**
87
+ * Get the default TRC20 token for a network
88
+ *
89
+ * @param network - CAIP-2 network identifier
90
+ * @returns Default token configuration or undefined
91
+ */
92
+ declare function getDefaultToken(network: string): TRC20Config | undefined;
93
+ /**
94
+ * Get token by contract address
95
+ *
96
+ * @param network - CAIP-2 network identifier
97
+ * @param contractAddress - TRC20 contract address
98
+ * @returns Token configuration or undefined
99
+ */
100
+ declare function getTokenByAddress(network: string, contractAddress: string): TRC20Config | undefined;
101
+ /**
102
+ * Get all networks that support a specific token
103
+ *
104
+ * @param symbol - Token symbol (e.g., "USDT")
105
+ * @returns Array of network identifiers
106
+ */
107
+ declare function getNetworksForToken(symbol: string): string[];
108
+ /**
109
+ * Get all networks that support USDT
110
+ *
111
+ * @returns Array of network identifiers
112
+ */
113
+ declare function getUsdtNetworks(): string[];
114
+ /**
115
+ * Check if a network is supported
116
+ *
117
+ * @param network - CAIP-2 network identifier
118
+ * @returns true if network is supported
119
+ */
120
+ declare function isNetworkSupported(network: string): boolean;
121
+ /**
122
+ * Get all supported networks
123
+ *
124
+ * @returns Array of network identifiers
125
+ */
126
+ declare function getSupportedNetworks(): string[];
127
+
128
+ /**
129
+ * TRON Utility Functions
130
+ *
131
+ * Address validation, amount conversion, and network utilities.
132
+ */
133
+
134
+ /**
135
+ * Normalize network identifier to CAIP-2 format
136
+ *
137
+ * @param network - Network identifier (e.g., "tron:mainnet", "mainnet")
138
+ * @returns Normalized CAIP-2 identifier
139
+ * @throws Error if network is not supported
140
+ */
141
+ declare function normalizeNetwork(network: string): TronNetwork;
142
+ /**
143
+ * Get RPC endpoint for a network
144
+ *
145
+ * @param network - CAIP-2 network identifier
146
+ * @returns RPC endpoint URL
147
+ * @throws Error if network is not supported
148
+ */
149
+ declare function getEndpoint(network: string): string;
150
+ /**
151
+ * Check if a network identifier is a TRON network
152
+ *
153
+ * @param network - Network identifier
154
+ * @returns true if TRON network
155
+ */
156
+ declare function isTronNetwork(network: string): boolean;
157
+ /**
158
+ * Validate a TRON address
159
+ *
160
+ * TRON addresses are:
161
+ * - Base58check encoded
162
+ * - 34 characters long
163
+ * - Start with 'T' (mainnet) or 'A'/'4' (testnet - rare)
164
+ *
165
+ * @param address - Address to validate
166
+ * @returns true if valid TRON address
167
+ */
168
+ declare function validateTronAddress(address: string): boolean;
169
+ /**
170
+ * Compare two TRON addresses for equality
171
+ *
172
+ * Handles case-insensitivity and different formats.
173
+ *
174
+ * @param addr1 - First address
175
+ * @param addr2 - Second address
176
+ * @returns true if addresses are equal
177
+ */
178
+ declare function addressesEqual(addr1: string, addr2: string): boolean;
179
+ /**
180
+ * Format a TRON address for display
181
+ *
182
+ * @param address - Address to format
183
+ * @param options - Formatting options
184
+ * @returns Formatted address
185
+ */
186
+ declare function formatAddress(address: string, options?: {
187
+ /** Truncate to first/last N characters */
188
+ truncate?: number;
189
+ }): string;
190
+ /**
191
+ * Convert decimal amount to smallest units
192
+ *
193
+ * @param decimalAmount - Amount as decimal string (e.g., "1.50")
194
+ * @param decimals - Token decimals (default: 6 for USDT)
195
+ * @returns Amount in smallest units as string
196
+ */
197
+ declare function convertToSmallestUnits(decimalAmount: string, decimals?: number): string;
198
+ /**
199
+ * Convert smallest units to decimal amount
200
+ *
201
+ * @param smallestUnits - Amount in smallest units as string
202
+ * @param decimals - Token decimals (default: 6 for USDT)
203
+ * @returns Amount as decimal string
204
+ */
205
+ declare function convertFromSmallestUnits(smallestUnits: string, decimals?: number): string;
206
+ /**
207
+ * Generate a unique memo/reference for payment tracking
208
+ *
209
+ * @returns Unique reference string
210
+ */
211
+ declare function generatePaymentReference(): string;
212
+ /**
213
+ * Calculate transaction expiration time
214
+ *
215
+ * @param validitySeconds - Validity duration in seconds
216
+ * @returns Expiration timestamp in milliseconds
217
+ */
218
+ declare function calculateExpiration(validitySeconds: number): number;
219
+ /**
220
+ * Validate a hex string
221
+ *
222
+ * @param hex - String to validate
223
+ * @returns true if valid hex string
224
+ */
225
+ declare function isValidHex(hex: string): boolean;
226
+ /**
227
+ * Estimate transaction fee
228
+ *
229
+ * Note: Actual fees depend on energy/bandwidth consumption.
230
+ * This provides a conservative estimate.
231
+ *
232
+ * @param isActivated - Whether recipient account is activated
233
+ * @returns Estimated fee in SUN
234
+ */
235
+ declare function estimateTransactionFee(isActivated?: boolean): number;
236
+
237
+ export { DEFAULT_FEE_LIMIT, DEFAULT_TRX_DECIMALS, DEFAULT_USDT_DECIMALS, DEFAULT_VALIDITY_DURATION, MAX_FEE_LIMIT, MIN_FEE_LIMIT, MIN_VALIDITY_BUFFER, NETWORK_ENDPOINTS, NetworkTRC20Registry, SCHEME_EXACT, SUN_PER_TRX, TRC20Config, TRC20_APPROVE_SELECTOR, TRC20_BALANCE_OF_SELECTOR, TRC20_REGISTRY, TRC20_TRANSFER_SELECTOR, TRON_ADDRESS_HEX_PREFIX, TRON_ADDRESS_LENGTH, TRON_ADDRESS_PREFIX, TRON_MAINNET_CAIP2, TRON_NETWORKS, TRON_NILE_CAIP2, TRON_SHASTA_CAIP2, type TronNetwork, USDT_ADDRESSES, addressesEqual, calculateExpiration, convertFromSmallestUnits, convertToSmallestUnits, estimateTransactionFee, formatAddress, generatePaymentReference, getDefaultToken, getEndpoint, getNetworkTokens, getNetworksForToken, getSupportedNetworks, getTRC20Config, getTokenByAddress, getUsdtNetworks, isNetworkSupported, isTronNetwork, isValidHex, normalizeNetwork, validateTronAddress };
@@ -0,0 +1,113 @@
1
+ import {
2
+ ExactTronScheme,
3
+ registerExactTronScheme
4
+ } from "./chunk-A2E6FJU3.mjs";
5
+ import {
6
+ ExactTronScheme as ExactTronScheme2,
7
+ TRC20_REGISTRY,
8
+ getDefaultToken,
9
+ getNetworkTokens,
10
+ getNetworksForToken,
11
+ getSupportedNetworks,
12
+ getTRC20Config,
13
+ getTokenByAddress,
14
+ getUsdtNetworks,
15
+ init_tokens,
16
+ isNetworkSupported,
17
+ registerExactTronScheme as registerExactTronScheme2
18
+ } from "./chunk-RHOZZ6XV.mjs";
19
+ import {
20
+ ExactTronScheme as ExactTronScheme3,
21
+ registerExactTronScheme as registerExactTronScheme3
22
+ } from "./chunk-CH6GR2VO.mjs";
23
+ import {
24
+ DEFAULT_FEE_LIMIT,
25
+ DEFAULT_TRX_DECIMALS,
26
+ DEFAULT_USDT_DECIMALS,
27
+ DEFAULT_VALIDITY_DURATION,
28
+ MAX_FEE_LIMIT,
29
+ MIN_FEE_LIMIT,
30
+ MIN_VALIDITY_BUFFER,
31
+ NETWORK_ENDPOINTS,
32
+ SCHEME_EXACT,
33
+ SUN_PER_TRX,
34
+ TRC20_APPROVE_SELECTOR,
35
+ TRC20_BALANCE_OF_SELECTOR,
36
+ TRC20_TRANSFER_SELECTOR,
37
+ TRON_ADDRESS_HEX_PREFIX,
38
+ TRON_ADDRESS_LENGTH,
39
+ TRON_ADDRESS_PREFIX,
40
+ TRON_MAINNET_CAIP2,
41
+ TRON_NETWORKS,
42
+ TRON_NILE_CAIP2,
43
+ TRON_SHASTA_CAIP2,
44
+ USDT_ADDRESSES,
45
+ addressesEqual,
46
+ calculateExpiration,
47
+ convertFromSmallestUnits,
48
+ convertToSmallestUnits,
49
+ estimateTransactionFee,
50
+ formatAddress,
51
+ generatePaymentReference,
52
+ getEndpoint,
53
+ init_constants,
54
+ isTronNetwork,
55
+ isValidHex,
56
+ normalizeNetwork,
57
+ validateTronAddress
58
+ } from "./chunk-L773HPM3.mjs";
59
+
60
+ // src/index.ts
61
+ init_constants();
62
+ init_tokens();
63
+ export {
64
+ DEFAULT_FEE_LIMIT,
65
+ DEFAULT_TRX_DECIMALS,
66
+ DEFAULT_USDT_DECIMALS,
67
+ DEFAULT_VALIDITY_DURATION,
68
+ ExactTronScheme as ExactTronClientScheme,
69
+ ExactTronScheme3 as ExactTronFacilitatorScheme,
70
+ ExactTronScheme2 as ExactTronServerScheme,
71
+ MAX_FEE_LIMIT,
72
+ MIN_FEE_LIMIT,
73
+ MIN_VALIDITY_BUFFER,
74
+ NETWORK_ENDPOINTS,
75
+ SCHEME_EXACT,
76
+ SUN_PER_TRX,
77
+ TRC20_APPROVE_SELECTOR,
78
+ TRC20_BALANCE_OF_SELECTOR,
79
+ TRC20_REGISTRY,
80
+ TRC20_TRANSFER_SELECTOR,
81
+ TRON_ADDRESS_HEX_PREFIX,
82
+ TRON_ADDRESS_LENGTH,
83
+ TRON_ADDRESS_PREFIX,
84
+ TRON_MAINNET_CAIP2,
85
+ TRON_NETWORKS,
86
+ TRON_NILE_CAIP2,
87
+ TRON_SHASTA_CAIP2,
88
+ USDT_ADDRESSES,
89
+ addressesEqual,
90
+ calculateExpiration,
91
+ convertFromSmallestUnits,
92
+ convertToSmallestUnits,
93
+ estimateTransactionFee,
94
+ formatAddress,
95
+ generatePaymentReference,
96
+ getDefaultToken,
97
+ getEndpoint,
98
+ getNetworkTokens,
99
+ getNetworksForToken,
100
+ getSupportedNetworks,
101
+ getTRC20Config,
102
+ getTokenByAddress,
103
+ getUsdtNetworks,
104
+ isNetworkSupported,
105
+ isTronNetwork,
106
+ isValidHex,
107
+ normalizeNetwork,
108
+ registerExactTronScheme as registerExactTronClientScheme,
109
+ registerExactTronScheme3 as registerExactTronFacilitatorScheme,
110
+ registerExactTronScheme2 as registerExactTronServerScheme,
111
+ validateTronAddress
112
+ };
113
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * @t402/tron - TRON blockchain support for t402 protocol\n *\n * This package provides TRC-20 token payment support for the t402 protocol,\n * enabling micropayments on the TRON network.\n *\n * @packageDocumentation\n */\n\n// Constants\nexport {\n TRON_MAINNET_CAIP2,\n TRON_NILE_CAIP2,\n TRON_SHASTA_CAIP2,\n TRON_NETWORKS,\n SCHEME_EXACT,\n TRC20_TRANSFER_SELECTOR,\n TRC20_APPROVE_SELECTOR,\n TRC20_BALANCE_OF_SELECTOR,\n USDT_ADDRESSES,\n NETWORK_ENDPOINTS,\n DEFAULT_USDT_DECIMALS,\n DEFAULT_TRX_DECIMALS,\n MIN_VALIDITY_BUFFER,\n DEFAULT_VALIDITY_DURATION,\n DEFAULT_FEE_LIMIT,\n MIN_FEE_LIMIT,\n MAX_FEE_LIMIT,\n SUN_PER_TRX,\n TRON_ADDRESS_PREFIX,\n TRON_ADDRESS_LENGTH,\n TRON_ADDRESS_HEX_PREFIX,\n} from \"./constants.js\";\n\n// Types from constants\nexport type { TronNetwork } from \"./constants.js\";\n\n// Types\nexport type {\n TronAuthorization,\n ExactTronPayload,\n ExactTronPayloadV2,\n VerifyMessageResult,\n TransactionConfirmation,\n TRC20Config,\n NetworkTRC20Registry,\n} from \"./types.js\";\n\n// Signer interfaces\nexport type {\n ClientTronSigner,\n FacilitatorTronSigner,\n} from \"./signer.js\";\n\n// Token registry\nexport {\n TRC20_REGISTRY,\n getDefaultToken,\n getTRC20Config,\n getTokenByAddress,\n getNetworkTokens,\n getNetworksForToken,\n getUsdtNetworks,\n isNetworkSupported,\n getSupportedNetworks,\n} from \"./tokens.js\";\n\n// Utilities\nexport {\n normalizeNetwork,\n getEndpoint,\n isTronNetwork,\n validateTronAddress,\n addressesEqual,\n formatAddress,\n convertToSmallestUnits,\n convertFromSmallestUnits,\n generatePaymentReference,\n calculateExpiration,\n isValidHex,\n estimateTransactionFee,\n} from \"./utils.js\";\n\n// Exact scheme exports (for convenience)\nexport * from \"./exact/index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA;AA6CA;","names":[]}
@@ -0,0 +1,261 @@
1
+ /**
2
+ * TRON Payment Types
3
+ *
4
+ * Type definitions for TRON TRC20 payment payloads.
5
+ */
6
+ /**
7
+ * Authorization metadata for a TRON TRC20 transfer
8
+ *
9
+ * Contains all information needed to verify and track a payment
10
+ * without parsing the signed transaction.
11
+ */
12
+ type TronAuthorization = {
13
+ /** Sender wallet address (T-prefix base58check) */
14
+ from: string;
15
+ /** Recipient wallet address (T-prefix base58check) */
16
+ to: string;
17
+ /** TRC20 contract address (e.g., USDT contract) */
18
+ contractAddress: string;
19
+ /** Transfer amount in smallest units (as string for large numbers) */
20
+ amount: string;
21
+ /** Transaction expiration timestamp (milliseconds since epoch) */
22
+ expiration: number;
23
+ /** Reference block bytes (hex string) */
24
+ refBlockBytes: string;
25
+ /** Reference block hash (hex string) */
26
+ refBlockHash: string;
27
+ /** Transaction timestamp (milliseconds since epoch) */
28
+ timestamp: number;
29
+ };
30
+ /**
31
+ * V2 TRON payment payload
32
+ *
33
+ * Contains the signed transaction ready for broadcast
34
+ * along with authorization metadata for verification.
35
+ */
36
+ type ExactTronPayloadV2 = {
37
+ /** Hex-encoded signed transaction */
38
+ signedTransaction: string;
39
+ /** Transaction authorization metadata */
40
+ authorization: TronAuthorization;
41
+ };
42
+ /**
43
+ * Current version alias
44
+ */
45
+ type ExactTronPayload = ExactTronPayloadV2;
46
+ /**
47
+ * Result of verifying a signed TRON transaction
48
+ */
49
+ type VerifyMessageResult = {
50
+ /** Whether the message is valid */
51
+ valid: boolean;
52
+ /** Reason for invalidity (if not valid) */
53
+ reason?: string;
54
+ /** Parsed transfer details (if valid) */
55
+ transfer?: {
56
+ /** Sender address */
57
+ from: string;
58
+ /** Recipient address */
59
+ to: string;
60
+ /** Contract address */
61
+ contractAddress: string;
62
+ /** Transfer amount */
63
+ amount: string;
64
+ /** Transaction ID */
65
+ txId: string;
66
+ };
67
+ };
68
+ /**
69
+ * Transaction confirmation result
70
+ */
71
+ type TransactionConfirmation = {
72
+ /** Whether the transaction was confirmed */
73
+ success: boolean;
74
+ /** Transaction ID/hash */
75
+ txId?: string;
76
+ /** Block number containing the transaction */
77
+ blockNumber?: number;
78
+ /** Error message if failed */
79
+ error?: string;
80
+ };
81
+ /**
82
+ * TRC20 token configuration
83
+ */
84
+ type TRC20Config = {
85
+ /** Contract address (T-prefix) */
86
+ contractAddress: string;
87
+ /** Token symbol (e.g., "USDT") */
88
+ symbol: string;
89
+ /** Token name (e.g., "Tether USD") */
90
+ name: string;
91
+ /** Token decimals */
92
+ decimals: number;
93
+ };
94
+ /**
95
+ * Network-specific token registry
96
+ */
97
+ type NetworkTRC20Registry = {
98
+ /** Network CAIP-2 identifier */
99
+ network: string;
100
+ /** Default token for this network */
101
+ defaultToken: TRC20Config;
102
+ /** All supported tokens on this network */
103
+ tokens: Record<string, TRC20Config>;
104
+ };
105
+
106
+ /**
107
+ * TRON Signer Interfaces
108
+ *
109
+ * Defines the signer interfaces for t402 client and facilitator operations.
110
+ * These interfaces abstract away the specific wallet implementation,
111
+ * allowing integration with various TRON wallets and signing mechanisms.
112
+ */
113
+
114
+ /**
115
+ * Parameters for signing a TRC20 transfer transaction
116
+ */
117
+ type SignTransactionParams = {
118
+ /** TRC20 contract address */
119
+ contractAddress: string;
120
+ /** Recipient address (T-prefix base58check) */
121
+ to: string;
122
+ /** Amount to transfer (in smallest units) */
123
+ amount: string;
124
+ /** Fee limit in SUN (optional, defaults to 100 TRX) */
125
+ feeLimit?: number;
126
+ /** Transaction expiration time in milliseconds (optional) */
127
+ expiration?: number;
128
+ };
129
+ /**
130
+ * Parameters for verifying a signed transaction
131
+ */
132
+ type VerifyTransactionParams = {
133
+ /** Hex-encoded signed transaction */
134
+ signedTransaction: string;
135
+ /** Expected sender address */
136
+ expectedFrom: string;
137
+ /** Expected transfer details */
138
+ expectedTransfer: {
139
+ /** Expected recipient address */
140
+ to: string;
141
+ /** Expected contract address */
142
+ contractAddress: string;
143
+ /** Expected amount */
144
+ amount: string;
145
+ };
146
+ /** Network identifier */
147
+ network: string;
148
+ };
149
+ /**
150
+ * Parameters for waiting on transaction confirmation
151
+ */
152
+ type WaitForTransactionParams = {
153
+ /** Transaction ID to monitor */
154
+ txId: string;
155
+ /** Network identifier */
156
+ network: string;
157
+ /** Timeout in milliseconds (optional) */
158
+ timeout?: number;
159
+ };
160
+ /**
161
+ * Parameters for getting TRC20 balance
162
+ */
163
+ type GetBalanceParams = {
164
+ /** Owner address */
165
+ ownerAddress: string;
166
+ /** TRC20 contract address */
167
+ contractAddress: string;
168
+ /** Network identifier */
169
+ network: string;
170
+ };
171
+ /**
172
+ * ClientTronSigner - Used by t402 clients to sign TRC20 transfer transactions
173
+ *
174
+ * This interface represents a TRON wallet that can:
175
+ * - Sign TRC20 transfer transactions
176
+ * - Query its own address
177
+ *
178
+ * Implementations may include:
179
+ * - TronWeb with private key
180
+ * - TronLink wallet adapter
181
+ * - Hardware wallet integration
182
+ */
183
+ type ClientTronSigner = {
184
+ /** The wallet address (T-prefix base58check) */
185
+ readonly address: string;
186
+ /**
187
+ * Sign a TRC20 transfer transaction
188
+ * Returns the hex-encoded signed transaction ready for broadcast
189
+ *
190
+ * @param params - Transaction parameters
191
+ * @returns Hex-encoded signed transaction
192
+ */
193
+ signTransaction(params: SignTransactionParams): Promise<string>;
194
+ /**
195
+ * Get the current reference block info for transaction building
196
+ * Returns block bytes and hash for replay protection
197
+ *
198
+ * @returns Reference block info
199
+ */
200
+ getBlockInfo(): Promise<{
201
+ refBlockBytes: string;
202
+ refBlockHash: string;
203
+ expiration: number;
204
+ }>;
205
+ };
206
+ /**
207
+ * FacilitatorTronSigner - Used by t402 facilitators to verify and settle payments
208
+ *
209
+ * This interface combines RPC capabilities with verification abilities:
210
+ * - Query TRC20 balances
211
+ * - Verify signed transactions
212
+ * - Broadcast transactions
213
+ * - Wait for confirmations
214
+ */
215
+ type FacilitatorTronSigner = {
216
+ /**
217
+ * Get all addresses this facilitator can use
218
+ * Enables dynamic address selection for load balancing
219
+ */
220
+ getAddresses(): readonly string[];
221
+ /**
222
+ * Query TRC20 balance for an owner
223
+ *
224
+ * @param params - Balance query parameters
225
+ * @returns Balance in smallest units
226
+ */
227
+ getBalance(params: GetBalanceParams): Promise<string>;
228
+ /**
229
+ * Verify a signed transaction matches expected parameters
230
+ * Validates the transaction structure and transfer details
231
+ *
232
+ * @param params - Verification parameters
233
+ * @returns Verification result
234
+ */
235
+ verifyTransaction(params: VerifyTransactionParams): Promise<VerifyMessageResult>;
236
+ /**
237
+ * Broadcast a signed transaction to the network
238
+ *
239
+ * @param signedTransaction - Hex-encoded signed transaction
240
+ * @param network - Network identifier
241
+ * @returns Transaction ID
242
+ */
243
+ broadcastTransaction(signedTransaction: string, network: string): Promise<string>;
244
+ /**
245
+ * Wait for transaction confirmation
246
+ *
247
+ * @param params - Transaction monitoring parameters
248
+ * @returns Confirmation result
249
+ */
250
+ waitForTransaction(params: WaitForTransactionParams): Promise<TransactionConfirmation>;
251
+ /**
252
+ * Check if an account is activated (has any transaction history)
253
+ *
254
+ * @param address - Address to check
255
+ * @param network - Network identifier
256
+ * @returns true if activated
257
+ */
258
+ isActivated(address: string, network: string): Promise<boolean>;
259
+ };
260
+
261
+ export type { ClientTronSigner as C, ExactTronPayload as E, FacilitatorTronSigner as F, NetworkTRC20Registry as N, TRC20Config as T, VerifyMessageResult as V, TronAuthorization as a, ExactTronPayloadV2 as b, TransactionConfirmation as c };