Send your first transaction
End-to-end tutorial: install TronWeb, generate keys, fund a Shasta testnet account, and broadcast your first TRX transfer in 15 minutes.
Prerequisites
This tutorial walks through your first TRX transaction on the TRON Shasta testnet. You will install TronWeb, generate a key pair, obtain test tokens, build and sign a transaction, broadcast it, and verify the result on TronScan. The full flow takes about 15 minutes.
Just want the code?See the Send your first transaction recipe — same flow, condensed to a copy-paste snippet with a cost summary and error table.
Step 1 — Install TronWeb
Create a new project and install TronWeb, the JavaScript SDK for TRON (analogous to Ethereum's web3.js):
mkdir tron-hello && cd tron-hello
npm init -y
npm install tronwebStep 2 — Generate a key pair
Every TRON account is controlled by a private key. Generate a new key pair:
const { TronWeb } = require('tronweb');
// Generate a random account
const account = TronWeb.utils.accounts.generateAccount();
console.log('Address (Base58):', account.address.base58);
console.log('Private Key:', account.privateKey);
// Save these — you will need them in the next steps
Never share your private keyAnyone with the private key controls the account. This tutorial uses the testnet, where tokens have no real value, but treat the key the same way you would on Mainnet.
Step 3 — Get testnet TRX
Visit the Faucet and paste your Base58 address to receive test TRX. You need approximately 11 TRX to cover the 10 TRX transfer plus the small Bandwidth-fallback fee in case your daily free Bandwidth is exhausted.
Step 4 — Send 10 TRX
Create a file called send.js:
const { TronWeb } = require('tronweb');
const tronWeb = new TronWeb({
fullHost: 'https://api.shasta.trongrid.io',
privateKey: 'YOUR_PRIVATE_KEY' // from Step 2
});
async function sendTrx() {
const to = 'TN2YqTv745dEHRsaLfUzqBgR2RZBGqYbMV'; // any valid address
const amount = 10 * 1_000_000; // 10 TRX in sun (1 TRX = 1,000,000 sun)
// Build → Sign → Broadcast
const tx = await tronWeb.transactionBuilder.sendTrx(to, amount);
const signed = await tronWeb.trx.sign(tx);
const result = await tronWeb.trx.sendRawTransaction(signed);
console.log('Transaction ID:', result.txid);
console.log('Success:', result.result);
}
sendTrx();Run it:
node send.js
# Output: Transaction ID: 5f3e4e0a... Success: trueStep 5 — Verify on TronScan
Open https://shasta.tronscan.org/#/transaction/<YOUR_TX_ID> in your browser. You will see the sender, recipient, amount (10 TRX), and confirmation status. TRON confirms transactions in approximately 3 seconds (one block).
Java alternative (Trident SDK)
import org.tron.trident.core.ApiWrapper;
public class SendTrx {
public static void main(String[] args) throws Exception {
ApiWrapper client = ApiWrapper.ofShasta("YOUR_PRIVATE_KEY");
var tx = client.transfer("SENDER_ADDRESS", "RECIPIENT_ADDRESS", 10_000_000L);
var signed = client.signTransaction(tx);
String txid = client.broadcastTransaction(signed);
System.out.println("Transaction ID: " + txid);
}
}What happened under the hood
- Transaction construction. TronWeb created a
TransferContracttransaction — one of TRON's system contract types. - Signing. Your private key produced an ECDSA (secp256k1) digital signature.
- Broadcasting. The signed transaction was sent to a full node via HTTP API.
- Packaging. A Super Representative package it in the next block (~3 seconds).
- Fee. This simple transfer consumed Bandwidth but no Energy. Each account receives 600 free Bandwidth per day; a typical TRX transfer consumes about 270 Bandwidth, so the first one or two of the day are free.
Next steps
- Resource model — understand Bandwidth and Energy in detail
- Deploy a smart contract — deploy your first Solidity contract on TRON
- Connect to the TRON network — endpoints and SDK initialization reference
Related resources
- Query balance and resources — check an account's TRX, tokens, Bandwidth, and Energy
- Blockchain browsers — explore transactions, blocks, and accounts on TronScan
Updated 4 days ago