Docs
Docs
Home
Getting Started
Agent Tooling
CLI
Supported Chains
Acala
Aptos
Arbitrum
Arc
Asset Hub
Astar
Avalanche
Base
Berachain
Bifrost
Binance Smart Chain
Bittensor
Blast
Boba Network
Bridge Hub
Celo
Centrifuge
Chiliz
Cronos
Enjin
Ethereum
Etherlink
Flow EVM Gateway
Gnosis
Hydration
Hyperliquid
Immutable
Ink
IoTeX
Kusama
Linea
LISK
Manta Atlantic
Manta Pacific
Mantle
MegaETH
Monad
Movement
Neuroweb
opBNB
Optimism
Plasma
Polkadot
Polygon
Pulsechain
Robinhood
Ronin
Scroll
Sonic
Starknet
Taiko
Tempo
Sui
TRON
Unichain
Viction
World Chain
XDC Network
XX Network
Zetachain
zkSync Era
Zora
Supported ChainsTRONTRON HTTP API

wallet/triggerconstantcontract - Call View Func...

Call smart contract view functions without creating transactions, read contract state data instantly via Dwellir's optimized TRON RPC endpoint.

TRON RPC endpoint: endpoint URLs, plans and pricing.

Zero-Cost Contract Reads

Dwellir's TRON infrastructure enables instant contract state queries without consuming energy or bandwidth. Read smart contract data in real-time without transaction fees.

Start querying contracts

Execute smart contract view/pure functions without creating a blockchain transaction. Perfect for reading contract state, calculating values, or retrieving stored data.

Use Cases

wallet/triggerconstantcontract is essential for:

  • Token Balance Queries - Check TRC20 token balances
  • Price Feeds - Read oracle price data
  • Game State - Query game contract states
  • DeFi Positions - Check liquidity pool shares
  • Contract Verification - Test function outputs
JSON-RPC request
{
  "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
  "function_selector": "balanceOf(address)",
  "parameter": "000000000000000000000000a614f803b6fd780986a42c78ec9c7f77e6ded13c",
  "owner_address": "TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN",
  "visible": true
}

Implementation Examples

Common Use Cases

1. Token Balance Checker

JavaScript
async function checkTokenBalance(tokenAddress, userAddress) {
  const token = new TRC20Contract('API_KEY', tokenAddress);
  
  try {
    const [symbol, decimals, balance] = await Promise.all([
      token.symbol(),
      token.getDecimals(),
      token.balanceOf(userAddress)
    ]);
    
    return {
      token: symbol,
      balance: balance.formatted,
      decimals: decimals,
      hasBalance: BigInt(balance.raw) > 0n
    };
  } catch (error) {
    return {
      error: 'Failed to fetch token data',
      details: error.message
    };
  }
}

2. DEX Price Monitor

JavaScript
async function monitorDexPrice(poolAddress) {
  const getPrice = async () => {
    const result = await callContractView(
      poolAddress,
      'getReserves()'
    );
    
    const reserves = parseReserves(result.constant_result[0]);
    return calculatePrice(reserves.token0, reserves.token1);
  };
  
  return setInterval(async () => {
    const price = await getPrice();
    console.log(`Current price: ${price}`);
  }, 10000); // Check every 10 seconds
}

3. Multi-Call Pattern

JavaScript
async function getCompleteTokenInfo(tokenAddress) {
  const functions = [
    'name()',
    'symbol()',
    'decimals()',
    'totalSupply()'
  ];
  
  const results = await Promise.all(
    functions.map(fn => 
      callContractView(tokenAddress, fn)
    )
  );
  
  return {
    name: decodeString(results[0].constant_result[0]),
    symbol: decodeString(results[1].constant_result[0]),
    decimals: decodeUint256(results[2].constant_result[0]),
    totalSupply: decodeUint256(results[3].constant_result[0])
  };
}

Reverted calls still return result.result: true

result.result reports that the node executed the call. It does not report that the call succeeded. A USDT transfer simulated from an address with no USDT returned this on TRON mainnet on 3 November 2026:

JSON
{
  "result": { "result": true, "message": "REVERT opcode executed" },
  "energy_used": 8624,
  "transaction": { "ret": [{ "ret": "FAILED" }] }
}

With visible: true, message is plain text. Without it, message is hex. Treat a call as successful only when message is empty and transaction.ret is not FAILED:

JavaScript
function constantCallSucceeded(response) {
  const raw = response.result?.message ?? '';
  const message = /^([0-9a-f]{2})+$/i.test(raw) ? Buffer.from(raw, 'hex').toString() : raw;
  const ret = response.transaction?.ret?.[0]?.ret;
  return response.result?.result === true && !message && ret !== 'FAILED';
}

A reverted simulation also reports a low energy_used. Do not size fee_limit from it. For measured USDT transfer energy and fee_limit sizing, see TRON energy for USDT transfers.

Best Practices

  1. Cache Results - Cache view function results appropriately
  2. Batch Calls - Group multiple calls for efficiency
  3. Handle Errors - Check result.result, result.message and transaction.ret together. A revert keeps result.result true
  4. Estimate Energy - Monitor energy_used for optimization
  5. Validate Input - Ensure parameters are properly encoded

Related Methods

  • wallet/triggersmartcontract - Execute state-changing functions
  • wallet/getcontract - Get contract information
  • wallet/estimateenergy - Estimate energy consumption

Need help? Contact support or visit our TRON documentation.

wallet/triggersmartcontract

Execute TRON smart contract functions, read contract state, and interact with TRC20 tokens via Dwellir's optimized smart contract RPC endpoints.

wallet/getcontract

Retrieve TRON smart contract information including bytecode, ABI, and metadata. Essential for contract verification and interaction via Dwellir RPC.

On this page

Use CasesImplementation ExamplesCommon Use Cases1. Token Balance Checker2. DEX Price Monitor3. Multi-Call PatternReverted calls still return result.result: trueBest PracticesRelated Methods