/jsonrpc, /wallet, /walletsolidity, and gRPC supportChainstack supports all TRON API endpoints:
/jsonrpc — Ethereum-compatible JSON-RPC (read-only operations)
/wallet — TRON HTTP API (full node operations including transactions)
/walletsolidity — TRON HTTP API (confirmed data from solidity node)
gRPC — high-performance binary protocol for efficient data access
Note that the TRON nodes provided are full only (non-archive), which makes some of the methods unsupported.
Get started with a reliable TRON RPC endpoint to use the tools below.
For the full API reference, see the official TRON API Reference .
TRON’s /jsonrpc endpoint provides limited Ethereum compatibility for read operations only . Methods required for transaction submission (eth_sendRawTransaction, eth_getTransactionCount) are not available. This means Ethereum-native tools like Foundry , Hardhat , and web3.py cannot deploy contracts or send transactions to TRON directly. For write operations, use TronWeb.js with the /wallet endpoint. You can still use Foundry or Hardhat for compilation and testing , then deploy with TronWeb.js. See the hybrid workflow section.
WebSocket event subscription not available TRON nodes currently do not support WebSocket connections for event subscriptions. If you need to subscribe to events, please vote and follow the feature request at TRON event plugin support .
gRPC API
TRON nodes on Chainstack support gRPC for high-performance access. gRPC uses HTTP/2 and Protocol Buffers for efficient binary serialization, making it ideal for high-throughput applications and data indexing.
Your TRON gRPC endpoints are available at:
Mainnet : tron-mainnet.core.chainstack.com:443
Nile Testnet : tron-nile.core.chainstack.com:443
Authentication
gRPC endpoints use x-token authentication. Pass your token in the request metadata:
x-token — your authentication token from the Chainstack console
Find your gRPC endpoint and x-token in the Chainstack console under your TRON node’s Access and credentials section.
Proto files
TRON gRPC does not support server reflection, so you need the protocol buffer definitions to make calls. Get them from the official TRON protocol repository:
git clone https://github.com/tronprotocol/protocol.git
The main service definitions are in:
api/api.proto — Wallet service with methods like GetNowBlock, GetBlockByNum, GetAccount
core/Tron.proto — Core data types (blocks, transactions, accounts)
Generate client code
To use gRPC with TRON, generate client code from the proto files.
Install dependencies and generate the Python stubs: pip install grpcio grpcio-tools
# Clone proto files
git clone https://github.com/tronprotocol/protocol.git
mkdir -p googleapis/google/api
# Download Google API dependencies
curl -sL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto \
-o googleapis/google/api/annotations.proto
curl -sL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto \
-o googleapis/google/api/http.proto
# Generate Python code
python -m grpc_tools.protoc \
-I./protocol \
-I./googleapis \
--python_out=./generated \
--grpc_python_out=./generated \
$( find ./protocol -name "*.proto" )
Install dependencies: npm install @grpc/grpc-js @grpc/proto-loader
Clone the proto files: git clone https://github.com/tronprotocol/protocol.git
Install the protoc compiler and Go plugins: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
Clone and generate: git clone https://github.com/tronprotocol/protocol.git
protoc --go_out=. --go-grpc_out=. \
-I./protocol \
protocol/api/api.proto protocol/core/Tron.proto
Usage examples
import grpc
import sys
sys.path.insert( 0 , './generated' )
from api import api_pb2, api_pb2_grpc
ENDPOINT = "tron-mainnet.core.chainstack.com:443"
X_TOKEN = "YOUR_X_TOKEN"
def get_now_block ():
# Create secure channel with TLS
credentials = grpc.ssl_channel_credentials()
channel = grpc.secure_channel( ENDPOINT , credentials)
# Create stub
stub = api_pb2_grpc.WalletStub(channel)
# Add x-token to metadata
metadata = [( "x-token" , X_TOKEN )]
# Call GetNowBlock
response = stub.GetNowBlock(
api_pb2.EmptyMessage(),
metadata = metadata,
timeout = 15
)
print ( f "Block number: { response.block_header.raw_data.number } " )
print ( f "Transactions: { len (response.transactions) } " )
channel.close()
get_now_block()
where YOUR_X_TOKEN is your authentication token from the Chainstack console.
For the full list of available gRPC methods, see the official TRON gRPC documentation .
TronWeb.js
TronWeb is the official JavaScript library for TRON. It supports all TRON operations including contract deployment and transactions.
Get balance
const { TronWeb } = require ( 'tronweb' );
const tronWeb = new TronWeb ({
fullHost: 'YOUR_CHAINSTACK_ENDPOINT'
});
const address = 'TWiEv2wfqQ8FkbAJ6bXt1uA2Uav9ZWvXip' ;
async function getBalance () {
try {
const balanceInSun = await tronWeb . trx . getBalance ( address );
const balanceInTRX = tronWeb . fromSun ( balanceInSun );
console . log ( `Address: ${ address } ` );
console . log ( `Balance in SUN: ${ balanceInSun } ` );
console . log ( `Balance in TRX: ${ balanceInTRX } ` );
} catch ( error ) {
console . error ( 'Error getting balance:' , error );
}
}
getBalance ();
where YOUR_CHAINSTACK_ENDPOINT is your TRON node base endpoint without the /jsonrpc, /wallet, or /walletsolidity postfixes.
Deploy a contract
const { TronWeb } = require ( 'tronweb' );
const tronWeb = new TronWeb ({
fullHost: 'YOUR_CHAINSTACK_ENDPOINT' ,
privateKey: 'YOUR_PRIVATE_KEY'
});
// Contract ABI and bytecode
const abi = [ /* your contract ABI */ ];
const bytecode = 'your_contract_bytecode' ;
async function deployContract () {
try {
console . log ( 'Deploying contract...' );
console . log ( 'From address:' , tronWeb . defaultAddress . base58 );
const transaction = await tronWeb . transactionBuilder . createSmartContract ({
abi: abi ,
bytecode: bytecode ,
feeLimit: 100000000 ,
callValue: 0 ,
userFeePercentage: 100 ,
originEnergyLimit: 10000000
}, tronWeb . defaultAddress . base58 );
const signedTx = await tronWeb . trx . sign ( transaction );
const result = await tronWeb . trx . sendRawTransaction ( signedTx );
if ( result . result ) {
console . log ( 'Contract deployed!' );
console . log ( 'Transaction ID:' , result . txid );
console . log ( 'Contract address:' , tronWeb . address . fromHex ( result . transaction . contract_address ));
}
} catch ( error ) {
console . error ( 'Deployment error:' , error . message || error );
}
}
deployContract ();
where
YOUR_CHAINSTACK_ENDPOINT — your TRON node base endpoint without the /jsonrpc, /wallet, or /walletsolidity postfixes
YOUR_PRIVATE_KEY — the private key of the account that you use to deploy the contract
See also node access details .
web3.py
web3.py can only perform read operations on TRON through the /jsonrpc endpoint. For contract deployment and transactions, use TronWeb.js .
Build DApps using web3.py and TRON nodes deployed with Chainstack.
Install web3.py .
Connect over HTTP.
HTTP
Use the HTTPProvider to connect to your node endpoint and get the latest block number.
Key protected
Password protected
from web3 import Web3
web3 = Web3(Web3.HTTPProvider( 'YOUR_CHAINSTACK_ENDPOINT' ))
print (web3.eth.block_number)
where YOUR_CHAINSTACK_ENDPOINT is your node HTTPS endpoint with the /jsonrpc postfix, protected either with the key or password.
See also node access details .
Hardhat
Hardhat can only perform read operations on TRON through the /jsonrpc endpoint. For contract deployment, use the hybrid workflow or TronWeb.js directly.
Configure Hardhat to compile contracts and perform read operations through your TRON nodes.
Install Hardhat and create a project.
Create a new environment in hardhat.config.js:
require ( "@nomiclabs/hardhat-waffle" );
...
module . exports = {
solidity: "0.8.19" ,
networks: {
tron: {
url: "YOUR_CHAINSTACK_ENDPOINT" ,
},
}
};
where YOUR_CHAINSTACK_ENDPOINT is your node HTTPS endpoint with the /jsonrpc postfix, protected either with the key or password. See node access details .
Compile your contracts with npx hardhat compile, then deploy using TronWeb.js.
Foundry
Foundry can only perform read operations on TRON through the /jsonrpc endpoint. For contract deployment, use the hybrid workflow below.
Install Foundry .
Use --rpc-url to run read operations through your Chainstack node.
Cast
Use cast to query the network.
To get the latest block number:
cast block-number --rpc-url YOUR_CHAINSTACK_ENDPOINT
To get an account balance:
cast balance 0xYOUR_HEX_ADDRESS --rpc-url YOUR_CHAINSTACK_ENDPOINT
where YOUR_CHAINSTACK_ENDPOINT is your node HTTPS endpoint with the /jsonrpc postfix, protected either with the key or password.
Hybrid workflow
Use Foundry for fast compilation and testing, then deploy to TRON with TronWeb.js.
Set up the project
Initialize a Foundry project:
forge init my-tron-project
cd my-tron-project
Write your contract in src/:
// src/MyContract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19 ;
contract MyContract {
string public message;
constructor ( string memory _message ) {
message = _message;
}
function setMessage ( string memory _message ) public {
message = _message;
}
}
Compile with Foundry:
The compiled artifacts are in out/MyContract.sol/MyContract.json.
Deploy with TronWeb.js
Install TronWeb:
npm init -y
npm install tronweb
Create a deployment script deploy.js:
const { TronWeb } = require ( 'tronweb' );
const fs = require ( 'fs' );
const tronWeb = new TronWeb ({
fullHost: 'YOUR_CHAINSTACK_ENDPOINT' ,
privateKey: 'YOUR_PRIVATE_KEY'
});
// Load Foundry artifacts
const artifact = JSON . parse (
fs . readFileSync ( './out/MyContract.sol/MyContract.json' , 'utf8' )
);
async function deploy () {
try {
console . log ( 'Deploying from:' , tronWeb . defaultAddress . base58 );
const transaction = await tronWeb . transactionBuilder . createSmartContract ({
abi: artifact . abi ,
bytecode: artifact . bytecode . object ,
feeLimit: 150000000 ,
callValue: 0 ,
userFeePercentage: 100 ,
originEnergyLimit: 10000000 ,
parameters: [ 'Hello TRON!' ] // Constructor arguments
}, tronWeb . defaultAddress . base58 );
const signedTx = await tronWeb . trx . sign ( transaction );
const result = await tronWeb . trx . sendRawTransaction ( signedTx );
if ( result . result ) {
console . log ( 'Contract deployed!' );
console . log ( 'Transaction ID:' , result . txid );
console . log ( 'Contract address:' , tronWeb . address . fromHex ( result . transaction . contract_address ));
}
} catch ( error ) {
console . error ( 'Error:' , error . message || error );
}
}
deploy ();
Run the deployment:
where
YOUR_CHAINSTACK_ENDPOINT — your TRON node base endpoint without the /jsonrpc, /wallet, or /walletsolidity postfixes
YOUR_PRIVATE_KEY — the private key of the account that you use to deploy the contract
See also node access details .