Skip to main content

/jsonrpc, /wallet, /walletsolidity support

Chainstack supports all three 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)
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.

Ethereum tooling limitations

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.

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.
  1. Install web3.py.
  2. Connect over HTTP.

HTTP

Use the HTTPProvider to connect to your node endpoint and get the latest block number.
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.
  1. Install Hardhat and create a project.
  2. 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.
  3. 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.
  1. Install Foundry.
  2. 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

  1. Initialize a Foundry project:
    forge init my-tron-project
    cd my-tron-project
    
  2. 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;
        }
    }
    
  3. Compile with Foundry:
    forge build
    
    The compiled artifacts are in out/MyContract.sol/MyContract.json.

Deploy with TronWeb.js

  1. Install TronWeb:
    npm init -y
    npm install tronweb
    
  2. 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();
    
  3. Run the deployment:
    node deploy.js
    
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.
Last modified on January 5, 2026