feat: sign and broadcast a USDT transfer in the React Tron example - #223
feat: sign and broadcast a USDT transfer in the React Tron example#223rtomas wants to merge 1 commit into
Conversation
Adds a "Send USDT" action to react/react-tron that transfers 0.01 USDT (TRC-20) to the connected account: the TriggerSmartContract transaction is built with tronweb, signed by the wallet, then broadcast. AppKit's typed sendTransaction only moves native TRX, and neither Tron connector accepts a plain tron_signTransaction request in appkit 1.8.21 -- the injected TronLink connector throws "Unsupported method" and only accepts tron_sendTransaction (which signs without broadcasting), while TronWalletConnectConnector.request() delegates to an internalRequest method that the base WalletConnectConnector doesn't define. The new signTransaction helper picks the right path per connector type. Also: - register the MetaMask Tron wallet adapter alongside TronLink - fix "Send tx", which self-transferred TRX from and to the connected account; TRON rejects that outright, so it now sends to RECIPIENT_ADDRESS - surface errors and the USDT tx hash (with an explorer link) in InfoList - add tronweb + vite-plugin-node-polyfills, which tronweb needs under Vite - use the shared networks export in createAppKit instead of an inline copy - document the actions in the README Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Claude finished @rtomas's task in 2m 58s —— View job Code Review
Found 4 issue(s)Issue 1: Hardcoded fallback project ID committed to source (pre-existing, flagged by data classification scan)ID: dcl-config-hardcoded-project-id-a3f1 Context:
Recommendation: Remove the fallback; fail loudly: export const projectId = import.meta.env.VITE_PROJECT_ID
if (!projectId) {
throw new Error('VITE_PROJECT_ID is not set — get one at https://dashboard.reown.com')
}Issue 2:
|
Adds a Send USDT action to
react/react-tronthat transfers 0.01 USDT (TRC-20) to the connected account — theTriggerSmartContracttransaction is built with tronweb, signed by the wallet, then broadcast — since AppKit's typedsendTransactiononly moves native TRX.Neither Tron connector accepts a plain
tron_signTransactionrequest in appkit 1.8.21: the injected TronLink connector throwsUnsupported methodand only acceptstron_sendTransaction(which signs without broadcasting), whileTronWalletConnectConnector.request()delegates to aninternalRequestmethod the baseWalletConnectConnectordoesn't define — so the newsignTransactionhelper picks the right path per connector type.Also registers the MetaMask Tron wallet adapter alongside TronLink, and fixes Send tx, which self-transferred TRX from and to the connected account (TRON rejects that outright with
Cannot transfer TRX to yourself) — it now sends to a configurableRECIPIENT_ADDRESS.Supporting changes: errors and the USDT tx hash (with an explorer link) are surfaced in
InfoList,tronweb+vite-plugin-node-polyfillsare added,createAppKituses the sharednetworksexport instead of an inline copy, and the README documents each action plus the per-network USDT contract addresses.Verified with
tsc -b,eslint, andvite build; the tronweb call was checked against both networks to confirm it produces selectora9059cbbwith amount10000(USDT has 6 decimals). The wallet signing and broadcast steps still need a manual run with a funded account.🤖 Generated with Claude Code