@bankofai/mcp-server-tron 1.1.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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +312 -0
  3. package/bin/cli.js +51 -0
  4. package/build/core/chains.d.ts +17 -0
  5. package/build/core/chains.js +55 -0
  6. package/build/core/chains.js.map +1 -0
  7. package/build/core/prompts.d.ts +16 -0
  8. package/build/core/prompts.js +468 -0
  9. package/build/core/prompts.js.map +1 -0
  10. package/build/core/resources.d.ts +14 -0
  11. package/build/core/resources.js +42 -0
  12. package/build/core/resources.js.map +1 -0
  13. package/build/core/services/address.d.ts +8 -0
  14. package/build/core/services/address.js +52 -0
  15. package/build/core/services/address.js.map +1 -0
  16. package/build/core/services/balance.d.ts +26 -0
  17. package/build/core/services/balance.js +60 -0
  18. package/build/core/services/balance.js.map +1 -0
  19. package/build/core/services/blocks.d.ts +16 -0
  20. package/build/core/services/blocks.js +46 -0
  21. package/build/core/services/blocks.js.map +1 -0
  22. package/build/core/services/clients.d.ts +9 -0
  23. package/build/core/services/clients.js +46 -0
  24. package/build/core/services/clients.js.map +1 -0
  25. package/build/core/services/contracts.d.ts +50 -0
  26. package/build/core/services/contracts.js +225 -0
  27. package/build/core/services/contracts.js.map +1 -0
  28. package/build/core/services/index.d.ts +119 -0
  29. package/build/core/services/index.js +39 -0
  30. package/build/core/services/index.js.map +1 -0
  31. package/build/core/services/multicall-abi.d.ts +55 -0
  32. package/build/core/services/multicall-abi.js +61 -0
  33. package/build/core/services/multicall-abi.js.map +1 -0
  34. package/build/core/services/tokens.d.ts +22 -0
  35. package/build/core/services/tokens.js +68 -0
  36. package/build/core/services/tokens.js.map +1 -0
  37. package/build/core/services/transactions.d.ts +16 -0
  38. package/build/core/services/transactions.js +42 -0
  39. package/build/core/services/transactions.js.map +1 -0
  40. package/build/core/services/transfer.d.ts +24 -0
  41. package/build/core/services/transfer.js +70 -0
  42. package/build/core/services/transfer.js.map +1 -0
  43. package/build/core/services/utils.d.ts +13 -0
  44. package/build/core/services/utils.js +39 -0
  45. package/build/core/services/utils.js.map +1 -0
  46. package/build/core/services/wallet.d.ts +33 -0
  47. package/build/core/services/wallet.js +113 -0
  48. package/build/core/services/wallet.js.map +1 -0
  49. package/build/core/tools.d.ts +16 -0
  50. package/build/core/tools.js +792 -0
  51. package/build/core/tools.js.map +1 -0
  52. package/build/index.d.ts +1 -0
  53. package/build/index.js +20 -0
  54. package/build/index.js.map +1 -0
  55. package/build/server/http-server.d.ts +1 -0
  56. package/build/server/http-server.js +197 -0
  57. package/build/server/http-server.js.map +1 -0
  58. package/build/server/server.d.ts +3 -0
  59. package/build/server/server.js +46 -0
  60. package/build/server/server.js.map +1 -0
  61. package/package.json +91 -0
@@ -0,0 +1,468 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Register task-oriented prompts with the MCP server
4
+ *
5
+ * All prompts follow a consistent structure:
6
+ * - Clear objective statement
7
+ * - Step-by-step instructions
8
+ * - Expected outputs
9
+ * - Safety/security considerations
10
+ *
11
+ * Prompts guide the model through complex workflows that would otherwise
12
+ * require multiple tool calls in the correct sequence.
13
+ *
14
+ * @param server The MCP server instance
15
+ */
16
+ export function registerTRONPrompts(server) {
17
+ // ============================================================================
18
+ // TRANSACTION PROMPTS
19
+ // ============================================================================
20
+ server.registerPrompt("prepare_transfer", {
21
+ description: "Safely prepare and execute a token transfer with validation checks",
22
+ argsSchema: {
23
+ tokenType: z
24
+ .enum(["trx", "trc20"])
25
+ .describe("Token type: 'trx' for native or 'trc20' for contract tokens"),
26
+ recipient: z.string().describe("Recipient address"),
27
+ amount: z.string().describe("Amount to transfer (in TRX or token units)"),
28
+ network: z.string().optional().describe("Network name (default: mainnet)"),
29
+ tokenAddress: z.string().optional().describe("Token contract address (required for TRC20)"),
30
+ },
31
+ }, ({ tokenType, recipient, amount, network = "mainnet", tokenAddress }) => ({
32
+ messages: [
33
+ {
34
+ role: "user",
35
+ content: {
36
+ type: "text",
37
+ text: `# Token Transfer Task
38
+
39
+ **Objective**: Safely transfer ${amount} ${tokenType === "trx" ? "TRX" : "TRC20 tokens"} to ${recipient} on ${network}
40
+
41
+ ## Validation & Checks
42
+ Before executing any transfer:
43
+ 1. **Wallet Verification**: Call \`get_wallet_address\` to confirm the sending wallet
44
+ 2. **Balance Check**:
45
+ ${tokenType === "trx"
46
+ ? "- Call `get_balance` to verify TRX balance"
47
+ : `- Call \`get_token_balance\` with tokenAddress=${tokenAddress} to verify balance`}
48
+ 3. **Resource Analysis**: Call \`get_chain_parameters\` to assess current network costs (Energy/Bandwidth)
49
+
50
+ ## Execution Steps
51
+ ${tokenType === "trx"
52
+ ? `
53
+ 1. Summarize: sender address, recipient, amount, and estimated cost
54
+ 2. Request confirmation from user
55
+ 3. Call \`transfer_trx\` with to="${recipient}", amount="${amount}", network="${network}"
56
+ 4. Return transaction hash to user
57
+ 5. Call \`get_transaction_info\` to confirm completion
58
+ `
59
+ : `
60
+ 1. Summarize: sender, recipient, token, amount
61
+ 2. Request confirmation
62
+ 3. Call \`transfer_trc20\` with tokenAddress, recipient, amount
63
+ 4. Wait for confirmation with \`get_transaction_info\`
64
+ `}
65
+
66
+ ## Output Format
67
+ - **Transaction Hash**: Clear hex value
68
+ - **Status**: Pending or Confirmed
69
+ - **User Confirmation**: Always ask before sending
70
+
71
+ ## Safety Considerations
72
+ - Never send more than available balance
73
+ - Double-check recipient address
74
+ - Explain any approval requirements
75
+ `,
76
+ },
77
+ },
78
+ ],
79
+ }));
80
+ server.registerPrompt("interact_with_contract", {
81
+ description: "Safely execute write operations on a smart contract with validation and confirmation",
82
+ argsSchema: {
83
+ contractAddress: z.string().describe("Contract address to interact with"),
84
+ functionName: z.string().describe("Function to call (e.g., 'mint', 'swap', 'stake')"),
85
+ args: z.string().optional().describe("Comma-separated function arguments"),
86
+ value: z.string().optional().describe("TRX value to send (for payable functions)"),
87
+ network: z.string().optional().describe("Network name (default: mainnet)"),
88
+ },
89
+ }, ({ contractAddress, functionName, args, value, network = "mainnet" }) => {
90
+ const argsList = args ? args.split(",").map((a) => a.trim()) : [];
91
+ return {
92
+ messages: [
93
+ {
94
+ role: "user",
95
+ content: {
96
+ type: "text",
97
+ text: `# Smart Contract Interaction
98
+
99
+ **Objective**: Safely execute ${functionName} on contract ${contractAddress} on ${network}
100
+
101
+ ## Prerequisites Check
102
+
103
+ ### 1. Wallet Verification
104
+ - Call \`get_wallet_address\` to confirm the wallet that will execute this transaction
105
+ - Verify this is the correct wallet for this operation
106
+
107
+ ### 2. Contract Analysis
108
+ - Use \`read_contract\` or external knowledge to understand the function parameters
109
+ - Check function type:
110
+ * **View/Pure**: Read-only (use \`read_contract\` instead)
111
+ * **Nonpayable**: State-changing, no TRX required
112
+ * **Payable**: State-changing, can accept TRX
113
+
114
+ ### 3. Function Parameter Validation
115
+ For function: **${functionName}**
116
+ ${argsList.length > 0 ? `Arguments provided: ${argsList.join(", ")}` : "No arguments provided"}
117
+
118
+ - Verify parameter types match the contract requirements
119
+ - Validate addresses are correct (Base58 or Hex)
120
+ - Check numeric values are in correct units
121
+
122
+ ### 4. Pre-execution Checks
123
+
124
+ **Balance Check**:
125
+ - Call \`get_balance\` to verify sufficient TRX balance
126
+ - Account for Energy/Bandwidth costs + value (if payable)
127
+
128
+ **Resource Estimation**:
129
+ - Call \`get_chain_parameters\` to check current unit prices
130
+ - Estimate Energy and Bandwidth usage
131
+
132
+ ## Execution Process
133
+
134
+ ### 1. Present Summary to User
135
+ Before executing, show:
136
+ - **Contract**: ${contractAddress}
137
+ - **Network**: ${network}
138
+ - **Function**: ${functionName}
139
+ - **Arguments**: ${argsList.length > 0 ? argsList.join(", ") : "None"}
140
+ ${value ? `- **Value**: ${value} TRX` : ""}
141
+ - **From**: [wallet address from step 1]
142
+ - **Estimated Resource Cost**: [Energy / Bandwidth estimation]
143
+
144
+ ### 2. Request User Confirmation
145
+ ⚠️ **IMPORTANT**: Always ask user to confirm before executing write operations
146
+ - Clearly state what will happen
147
+ - Show all costs involved
148
+ - Explain any risks or irreversible actions
149
+
150
+ ### 3. Execute Transaction
151
+ Only after user confirms:
152
+ \`\`\`
153
+ Call write_contract with:
154
+ - contractAddress: "${contractAddress}"
155
+ - functionName: "${functionName}"
156
+ ${argsList.length > 0 ? `- args: ${JSON.stringify(argsList)}` : ""}
157
+ ${value ? `- value: "${value}"` : ""}
158
+ - network: "${network}"
159
+ \`\`\`
160
+
161
+ ### 4. Monitor Transaction
162
+ After execution:
163
+ 1. Return transaction hash to user
164
+ 2. Call \`get_transaction_info\` to verify success
165
+ 3. If failed, call \`diagnose_transaction\` to understand why
166
+
167
+ ## Output Format
168
+
169
+ **Pre-Execution Summary**:
170
+ - Contract details
171
+ - Function and parameters
172
+ - Cost breakdown
173
+ - Risk assessment
174
+
175
+ **Confirmation Request**:
176
+ "Ready to execute ${functionName} on ${contractAddress}. Proceed? (yes/no)"
177
+
178
+ **Execution Result**:
179
+ - Transaction Hash: [hash]
180
+ - Status: Pending/Confirmed/Failed
181
+ - Energy Used: [actual energy used]
182
+ - Bandwidth Used: [actual bandwidth used]
183
+
184
+ ## Safety Considerations
185
+
186
+ ### Critical Checks
187
+ - ✅ Check function parameters are correct type and format
188
+ - ✅ Ensure sufficient balance for fees + value
189
+ - ✅ Validate addresses (no typos, correct network)
190
+ - ✅ Understand what the function does before calling
191
+
192
+ ### Common Risks
193
+ - **Irreversible**: Most blockchain transactions cannot be undone
194
+ - **Fee Loss**: Failed transactions still consume Energy/Bandwidth
195
+ - **Approval Risks**: Be careful with unlimited approvals
196
+ - **Access Control**: Verify you have permission to call this function
197
+ `,
198
+ },
199
+ },
200
+ ],
201
+ };
202
+ });
203
+ server.registerPrompt("diagnose_transaction", {
204
+ description: "Analyze transaction status, failures, and provide debugging insights",
205
+ argsSchema: {
206
+ txHash: z.string().describe("Transaction hash to diagnose"),
207
+ network: z.string().optional().describe("Network name (default: mainnet)"),
208
+ },
209
+ }, ({ txHash, network = "mainnet" }) => ({
210
+ messages: [
211
+ {
212
+ role: "user",
213
+ content: {
214
+ type: "text",
215
+ text: `# Transaction Diagnosis
216
+
217
+ **Objective**: Analyze transaction ${txHash} on ${network} and identify any issues
218
+
219
+ ## Investigation Process
220
+
221
+ ### 1. Gather Transaction Data
222
+ - Call \`get_transaction\` to fetch transaction details
223
+ - Call \`get_transaction_info\` to get status and energy/bandwidth used
224
+ - Note: both calls are read-only and free
225
+
226
+ ### 2. Status Assessment
227
+ Determine transaction state:
228
+ - **Pending**: Not yet mined
229
+ - **Confirmed**: Successfully executed (contractRet='SUCCESS')
230
+ - **Failed**: Execution failed (contractRet='REVERT' or other error)
231
+
232
+ ### 3. Failure Analysis
233
+ If transaction failed, investigate:
234
+
235
+ **Out of Energy**:
236
+ - Check energy_usage vs energy_limit
237
+ - If usage >= limit, suggest increasing fee limit
238
+
239
+ **Contract Revert**:
240
+ - Check function called and parameters
241
+ - Verify sufficient balance/approvals
242
+ - Look for require/revert statements in contract
243
+
244
+ ### 4. Resource Analysis
245
+ - Calculate energy/bandwidth cost
246
+ - Compare to current chain parameters
247
+
248
+ ## Output Format
249
+
250
+ Provide structured diagnosis:
251
+ - **Status**: Pending/Confirmed/Failed with reason
252
+ - **Transaction Hash**: The hash analyzed
253
+ - **From/To**: Addresses involved
254
+ - **Resource Usage**: Energy / Bandwidth used
255
+ - **Issue (if failed)**: Root cause and explanation
256
+ - **Recommended Actions**: Next steps to resolve
257
+ `,
258
+ },
259
+ },
260
+ ],
261
+ }));
262
+ server.registerPrompt("explain_tron_concept", {
263
+ description: "Explain TRON and blockchain concepts with examples",
264
+ argsSchema: {
265
+ concept: z
266
+ .string()
267
+ .describe("Concept to explain (Energy, Bandwidth, Super Representative, TRC20, TRC721, etc)"),
268
+ },
269
+ }, ({ concept }) => ({
270
+ messages: [
271
+ {
272
+ role: "user",
273
+ content: {
274
+ type: "text",
275
+ text: `# Concept Explanation: ${concept}
276
+
277
+ **Objective**: Provide clear, practical explanation of "${concept}"
278
+
279
+ ## Explanation Structure
280
+
281
+ ### 1. Definition
282
+ - What is it?
283
+ - Simple one-sentence summary
284
+ - Technical name/terminology
285
+
286
+ ### 2. How It Works
287
+ - Step-by-step explanation
288
+ - Why it exists/why it's important (e.g., Resource model prevents spam)
289
+ - How it relates to TRON blockchain
290
+
291
+ ### 3. Real-World Analogy
292
+ - Compare to familiar concept (e.g., Bandwidth like internet data, Energy like CPU time)
293
+ - Make it relatable for beginners
294
+ - Highlight key differences
295
+
296
+ ### 4. Practical Examples
297
+ - Real transaction scenarios
298
+ - Numbers and metrics where applicable (e.g., Transfer costs ~300 Bandwidth)
299
+ - Common scenarios
300
+ - Edge cases or gotchas
301
+
302
+ ### 5. Relevance to Users
303
+ - Why should developers/users care?
304
+ - How does it affect transactions/costs?
305
+ - How to optimize (e.g., Staking for resources)?
306
+ - Common mistakes to avoid
307
+
308
+ ## Output Format
309
+
310
+ Provide explanation in sections:
311
+
312
+ **What is ${concept}?**
313
+ [Definition and overview]
314
+
315
+ **How Does It Work?**
316
+ [Mechanics and process]
317
+
318
+ **Example**
319
+ [Real or hypothetical scenario]
320
+
321
+ **Key Takeaways**
322
+ [Bullet points of important facts]
323
+
324
+ **Common Questions**
325
+ - Question 1? Answer
326
+ - Question 2? Answer
327
+
328
+ ## Important
329
+ - Use clear, non-technical language first
330
+ - Progress to technical details
331
+ - Include concrete numbers where helpful
332
+ - Be honest about complexity
333
+ - Suggest further learning if needed
334
+ `,
335
+ },
336
+ },
337
+ ],
338
+ }));
339
+ // ============================================================================
340
+ // WALLET ANALYSIS PROMPTS
341
+ // ============================================================================
342
+ server.registerPrompt("analyze_wallet", {
343
+ description: "Get comprehensive overview of wallet assets, balances, and activity",
344
+ argsSchema: {
345
+ address: z.string().describe("Wallet address to analyze"),
346
+ network: z.string().optional().describe("Network name (default: mainnet)"),
347
+ tokens: z.string().optional().describe("Comma-separated token addresses to check"),
348
+ },
349
+ }, ({ address, network = "mainnet", tokens }) => {
350
+ const tokenList = tokens ? tokens.split(",").map((t) => t.trim()) : [];
351
+ return {
352
+ messages: [
353
+ {
354
+ role: "user",
355
+ content: {
356
+ type: "text",
357
+ text: `# Wallet Analysis
358
+
359
+ **Objective**: Provide complete asset overview for ${address} on ${network}
360
+
361
+ ## Information Gathering
362
+
363
+ ### 1. Address Resolution
364
+ - Call \`convert_address\` to get both Hex and Base58 formats
365
+
366
+ ### 2. Native Token Balance
367
+ - Call \`get_balance\` to fetch TRX balance
368
+ - Report both sun and TRX formats
369
+
370
+ ### 3. Token Balances
371
+ ${tokenList.length > 0
372
+ ? `- Call \`get_token_balance\` for each token:\n${tokenList.map((t) => ` * ${t}`).join("\n")}`
373
+ : `- If specific tokens provided: call \`get_token_balance\` for each`}
374
+
375
+ ## Output Format
376
+
377
+ Provide analysis with clear sections:
378
+
379
+ **Wallet Overview**
380
+ - Address (Base58): [address]
381
+ - Address (Hex): [hex]
382
+ - Network: [network]
383
+
384
+ **TRX Balance**
385
+ - TRX: [formatted amount]
386
+ - Sun: [raw amount]
387
+
388
+ **Token Holdings** (if requested)
389
+ - Token: [address]
390
+ - Symbol: [symbol]
391
+ - Balance: [formatted]
392
+ - Decimals: [decimals]
393
+
394
+ **Summary**
395
+ - Primary holdings
396
+ - Notable observations
397
+ `,
398
+ },
399
+ },
400
+ ],
401
+ };
402
+ });
403
+ // ============================================================================
404
+ // NETWORK & EDUCATION PROMPTS
405
+ // ============================================================================
406
+ server.registerPrompt("check_network_status", {
407
+ description: "Check current network health and conditions",
408
+ argsSchema: {
409
+ network: z.string().optional().describe("Network name (default: mainnet)"),
410
+ },
411
+ }, ({ network = "mainnet" }) => ({
412
+ messages: [
413
+ {
414
+ role: "user",
415
+ content: {
416
+ type: "text",
417
+ text: `# Network Status Check
418
+
419
+ **Objective**: Assess health and current conditions of ${network}
420
+
421
+ ## Status Assessment
422
+
423
+ ### 1. Gather Current Data
424
+ Call these read-only tools:
425
+ - \`get_chain_info\` for chain ID and current block number
426
+ - \`get_latest_block\` for block details and timing
427
+ - \`get_chain_parameters\` for current resource costs
428
+
429
+ ### 2. Network Health Analysis
430
+
431
+ **Block Production**:
432
+ - Current block number
433
+ - Block timing (normal ~3 sec for Tron)
434
+ - Consistent vs irregular blocks
435
+
436
+ **Resource Market**:
437
+ - Energy Fee
438
+ - Bandwidth Fee
439
+
440
+ **Overall Status**:
441
+ - Operational: Yes/No
442
+ - Issues detected: Yes/No
443
+
444
+ ## Output Format
445
+
446
+ **Network Status Report: ${network}**
447
+
448
+ **Overall Status**
449
+ - Operational Status: [Online/Degraded/Offline]
450
+ - Current Block: [number]
451
+ - Network Time: [timestamp]
452
+
453
+ **Performance Metrics**
454
+ - Block Time: [seconds] (normal: 3s)
455
+ - Energy Fee: [amount]
456
+ - Bandwidth Fee: [amount]
457
+
458
+ **Recommendations**
459
+
460
+ For **sending transactions now**:
461
+ - Status is Green/Yellow/Red
462
+ `,
463
+ },
464
+ },
465
+ ],
466
+ }));
467
+ }
468
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/core/prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,+EAA+E;IAC/E,sBAAsB;IACtB,+EAA+E;IAE/E,MAAM,CAAC,cAAc,CACnB,kBAAkB,EAClB;QACE,WAAW,EAAE,oEAAoE;QACjF,UAAU,EAAE;YACV,SAAS,EAAE,CAAC;iBACT,IAAI,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;iBACtB,QAAQ,CAAC,6DAA6D,CAAC;YAC1E,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;YACnD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;YACzE,OAAO,EAAE,CAAC,CAAC,MAA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AAE;YACV,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;SAC3E;KACF,EACD,CAAC,EAAE,OAAO,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5B,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;yDAEuC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;2BA2BrC,OAAO;;;;;;;;;;;;;;;;CAgBjC;iBACU;aACF;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ /**
3
+ * Register TRON-related resources with the MCP server
4
+ *
5
+ * Resources are application-driven, read-only data that clients can explicitly load.
6
+ * For an AI agent use case, most data should be exposed through tools instead,
7
+ * which allow the model to discover and autonomously fetch information.
8
+ *
9
+ * The supported_networks resource provides a static reference list that clients
10
+ * may want to browse when configuring which networks to use.
11
+ *
12
+ * @param server The MCP server instance
13
+ */
14
+ export declare function registerTRONResources(server: McpServer): void;
@@ -0,0 +1,42 @@
1
+ import { getSupportedNetworks } from "./chains.js";
2
+ /**
3
+ * Register TRON-related resources with the MCP server
4
+ *
5
+ * Resources are application-driven, read-only data that clients can explicitly load.
6
+ * For an AI agent use case, most data should be exposed through tools instead,
7
+ * which allow the model to discover and autonomously fetch information.
8
+ *
9
+ * The supported_networks resource provides a static reference list that clients
10
+ * may want to browse when configuring which networks to use.
11
+ *
12
+ * @param server The MCP server instance
13
+ */
14
+ export function registerTRONResources(server) {
15
+ server.registerResource("supported_networks", "tron://networks", {
16
+ description: "Get list of all supported TRON networks and their configuration",
17
+ mimeType: "application/json",
18
+ }, async (uri) => {
19
+ try {
20
+ const networks = getSupportedNetworks();
21
+ return {
22
+ contents: [
23
+ {
24
+ uri: uri.href,
25
+ text: JSON.stringify({ supportedNetworks: networks }, null, 2),
26
+ },
27
+ ],
28
+ };
29
+ }
30
+ catch (error) {
31
+ return {
32
+ contents: [
33
+ {
34
+ uri: uri.href,
35
+ text: `Error: ${error instanceof Error ? error.message : String(error)}`,
36
+ },
37
+ ],
38
+ };
39
+ }
40
+ });
41
+ }
42
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/core/resources.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACrD,MAAM,CAAC,gBAAgB,CACrB,oBAAoB,EACpB,iBAAiB,EACjB;QACE,WAAW,EAAE,iEAAiE;QAC9E,QAAQ,EAAE,kBAAkB;KAC7B,EACD,KAAK,EAAE,GAAG,EAAE,EAAE;QACZ,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,oBAAoB,EAAE,CAAC;YACxC,OAAO;gBACL,QAAQ,EAAE;oBACR;wBACE,GAAG,EAAE,GAAG,CAAC,IAAI;wBACb,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;qBAC/D;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,QAAQ,EAAE;oBACR;wBACE,GAAG,EAAE,GAAG,CAAC,IAAI;wBACb,IAAI,EAAE,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBACzE;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Service for handling address conversions (Hex <-> Base58)
3
+ */
4
+ export declare function toHexAddress(address: string): string;
5
+ export declare function toBase58Address(address: string): string;
6
+ export declare function isBase58(address: string): boolean;
7
+ export declare function isHex(address: string): boolean;
8
+ export declare const resolveAddress: (nameOrAddress: string, _network?: string) => Promise<string>;
@@ -0,0 +1,52 @@
1
+ import { TronWeb } from "tronweb";
2
+ /**
3
+ * Service for handling address conversions (Hex <-> Base58)
4
+ */
5
+ export function toHexAddress(address) {
6
+ if (address.startsWith("T")) {
7
+ return TronWeb.address.toHex(address);
8
+ }
9
+ return address;
10
+ }
11
+ export function toBase58Address(address) {
12
+ if (address.startsWith("41")) {
13
+ return TronWeb.address.fromHex(address);
14
+ }
15
+ if (address.startsWith("0x")) {
16
+ // TronWeb expects 41 prefix for hex addresses usually, but 0x might be passed from EVM habits
17
+ // 0x prefix usually needs to be replaced with 41 if it's a valid Tron address in hex
18
+ // However, TronWeb.address.fromHex handles 0x prefix by assuming it's an ETH address and converting?
19
+ // Let's rely on TronWeb's robust handling
20
+ return TronWeb.address.fromHex(address);
21
+ }
22
+ return address;
23
+ }
24
+ export function isBase58(address) {
25
+ return address.startsWith("T") && TronWeb.isAddress(address);
26
+ }
27
+ export function isHex(address) {
28
+ // Base58 addresses start with T, Hex addresses don't (0-9, a-f)
29
+ if (address.startsWith("T"))
30
+ return false;
31
+ let cleanAddress = address;
32
+ if (address.startsWith("0x")) {
33
+ cleanAddress = address.substring(2);
34
+ }
35
+ // If it's a 20-byte hex (40 chars), prefix with 41 to verify as a Tron address
36
+ // TronWeb.address.fromHex handles this auto-prefixing, so isHex should validate it too
37
+ if (cleanAddress.length === 40) {
38
+ cleanAddress = "41" + cleanAddress;
39
+ }
40
+ return TronWeb.isAddress(cleanAddress);
41
+ }
42
+ // Re-export utility for convenience
43
+ export const resolveAddress = async (nameOrAddress, _network) => {
44
+ // Tron doesn't have ENS exactly like ETH.
45
+ // If it's a valid address, return it.
46
+ if (TronWeb.isAddress(nameOrAddress)) {
47
+ return nameOrAddress;
48
+ }
49
+ // Future: Implement Tron NS resolution if needed
50
+ throw new Error(`Invalid address or unsupported name service: ${nameOrAddress}`);
51
+ };
52
+ //# sourceMappingURL=address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../../../src/core/services/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;GAEG;AAEH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,8FAA8F;QAC9F,qFAAqF;QACrF,qGAAqG;QACrG,0CAA0C;QAC1C,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,OAAe;IACnC,gEAAgE;IAChE,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAE1C,IAAI,YAAY,GAAG,OAAO,CAAC;IAC3B,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAED,+EAA+E;IAC/E,uFAAuF;IACvF,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC/B,YAAY,GAAG,IAAI,GAAG,YAAY,CAAC;IACrC,CAAC;IAED,OAAO,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AACzC,CAAC;AAED,oCAAoC;AACpC,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,aAAqB,EAAE,QAAiB,EAAmB,EAAE;IAChG,0CAA0C;IAC1C,sCAAsC;IACtC,IAAI,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,CAAC;QACrC,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,iDAAiD;IACjD,MAAM,IAAI,KAAK,CAAC,gDAAgD,aAAa,EAAE,CAAC,CAAC;AACnF,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Get TRX balance for an address
3
+ */
4
+ export declare function getTRXBalance(address: string, network?: string): Promise<{
5
+ wei: bigint;
6
+ ether: string;
7
+ formatted: string;
8
+ symbol: string;
9
+ decimals: number;
10
+ }>;
11
+ /**
12
+ * Get TRC20 token balance
13
+ */
14
+ export declare function getTRC20Balance(tokenAddress: string, walletAddress: string, network?: string): Promise<{
15
+ raw: bigint;
16
+ formatted: string;
17
+ token: {
18
+ symbol: any;
19
+ decimals: number;
20
+ address: string;
21
+ };
22
+ }>;
23
+ /**
24
+ * Get TRC1155 balance
25
+ */
26
+ export declare function getTRC1155Balance(contractAddress: string, ownerAddress: string, tokenId: bigint, network?: string): Promise<bigint>;