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();