method.call()

Use call to execute a pure or view smart contract method. These methods do not modify the blockchain, do not cost anything to execute and are also not broadcasted to the network.

Usage

//Example 1
let contract = await tronWeb.contract.at('contractAddress'); 
let result = await contract.function_name(para1,para2,...).call();

//Example 2
let contract = await tronWeb.contract.at('contractAddress'); 
let result = await contract["function_name"](para1,para2,...).call();

Parameters
No need to pass parameters

Returns
Object

Example

//example 1
async function triggercontract(){
   let instance = await tronWeb.contract().at('TBBp5VF2q73hfMUoyxr138Kx3kbsi6HQRS');
   let res = await instance.totalSupply().call();
   console.log(res);
}
triggercontract();

//example 2
async function triggercontract(){
   let instance = await tronWeb.contract().at('TBBp5VF2q73hfMUoyxr138Kx3kbsi6HQRS');
   let res = await instance["totalSupply"]().call();
   console.log(res);
}
triggercontract();

//example 3:the ABI of the smart contract is not on-chain
async function triggercontract(){
   let instance = await tronWeb.contract().at('TBBp5VF2q73hfMUoyxr138Kx3kbsi6HQRS');
   instance.loadAbi([{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]);
     let res = await instance.totalSupply().call({_isConstant:true})
   console.log(res);
}
triggercontract();