Skip to Content
dApps

Transactions

Connect the provider and use the TronWeb instance associated with that same wallet. Replace abbreviated addresses and contract methods with valid values. Check the selected network before preparing a transaction.

Learn how to sign and send transactions on TRON.


Sign Transaction

Sign a transaction without broadcasting:

// Build transaction const tx = await tronWeb.transactionBuilder.sendTrx( 'TRecipientAddress...', tronWeb.toSun(10), tronWeb.defaultAddress.base58 ) // Sign via provider const signedTx = await provider.sign(tx) console.log('Signed transaction:', signedTx) // Broadcast manually const result = await tronWeb.trx.sendRawTransaction(signedTx)

Smart Contract Interaction

const contract = await tronWeb.contract().at(contractAddress) // Read (view function) const result = await contract.someViewFunction().call() // Write (requires signing) const tx = await contract.someWriteFunction(param1, param2).send({ feeLimit: 100_000_000, // 100 TRX callValue: 0, })

Trigger Smart Contract

const tx = await tronWeb.transactionBuilder.triggerSmartContract( contractAddress, 'transfer(address,uint256)', { feeLimit: 100_000_000 }, [ { type: 'address', value: recipientAddress }, { type: 'uint256', value: amount } ], tronWeb.defaultAddress.base58 ) const signedTx = await provider.sign(tx.transaction) const result = await tronWeb.trx.sendRawTransaction(signedTx)

Using SunWeb

For DappChain (side chain) operations:

const sunWeb = window.sunWeb // Main chain to side chain await sunWeb.depositTrx( amount, depositFee, feeLimit ) // Side chain to main chain await sunWeb.withdrawTrx( amount, withdrawFee, feeLimit )
Last updated on