Skip to content

TRON Phase 2: transaction preparation (preview-only) - #21

Merged
szhygulin merged 1 commit into
mainfrom
feat/tron-phase2-prepare
Apr 14, 2026
Merged

TRON Phase 2: transaction preparation (preview-only)#21
szhygulin merged 1 commit into
mainfrom
feat/tron-phase2-prepare

Conversation

@szhygulin

Copy link
Copy Markdown
Collaborator

Summary

  • Adds three TRON prepare_* tools: prepare_tron_native_send, prepare_tron_token_send, prepare_tron_claim_rewards. Each calls TronGrid (createtransaction / triggersmartcontract / withdrawbalance) with visible: true, validates base58 addresses and amounts, and issues an opaque handle.
  • Keeps TRON tx shape (UnsignedTronTx) and its handle store separate from EVM so send_transaction's EVM-only security pipeline (eth_call re-simulation, chain-id check, spender allowlist) can't be silently shortcut by type confusion. TRON handles are preview-only in this release; send_transaction refuses them until Phase 3 lands USB HID signing via @ledgerhq/hw-app-trx.
  • TRC-20 preparation is restricted to the canonical set (USDT/USDC/USDD/TUSD) whose decimals live in the hardcoded table — unknown TRC-20s are rejected with an explicit error rather than rendered as UNKNOWN in the preview.
  • Hand-rolled base58check decoder + TRC-20 ABI param encoder (no new deps; base58 alphabet + double-sha256 checksum verify in ~30 LOC).

Test plan

  • npx vitest run — 285/285 pass (17 new tests in test/tron-phase2-prepare.test.ts covering base58 decode, TRC-20 param layout, POST body shape, handle issuance, and both TronGrid error shapes).
  • npm run build — clean tsc.
  • Manual: build-and-link the MCP, call each prepare_tron_* against a real address and cross-reference txID with a direct TronGrid call.
  • Manual: confirm send_transaction refuses a TRON handle (EVM-only consume path).
  • Manual: hit the 24h-cooldown branch on prepare_tron_claim_rewards and confirm TronGrid's message is surfaced verbatim.

Follow-ups

  • Phase 2b: freezeBalanceV2, unfreezeBalanceV2, withdrawExpireUnfreeze for Stake 2.0 bandwidth/energy management.
  • Phase 3: USB HID signing via @ledgerhq/hw-app-trx (Ledger Live's WalletConnect relay does not honor tron: — verified 2026-04-14).

🤖 Generated with Claude Code

Prepares (preview-only) native TRX sends, canonical TRC-20 transfers
(USDT/USDC/USDD/TUSD), and WithdrawBalance claims via TronGrid. The TRON
tx shape (raw_data_hex + fee_limit) diverges from the EVM UnsignedTx, so
handles live in a separate tron-tx-store to keep send_transaction's
EVM-only security pipeline from being shortcut by type confusion.
Signing lands with Phase 3 via @ledgerhq/hw-app-trx over USB HID.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@szhygulin
szhygulin merged commit 39a74b4 into main Apr 14, 2026
2 checks passed
@szhygulin
szhygulin deleted the feat/tron-phase2-prepare branch April 25, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant