tronweb.contract()

smart contract instance

Usage

tronWeb.contract(abi,contractAddress);

Parameters

ParametersDescriptionType
abiThe abi of the smart contractArray
contractAddressThe contract address(Hex format or Base58 format)String

Returns
Object - smart contract instance

Example

let abi = [{"inputs":[{"internalType":"string","name":"initMessage","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"message","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"newMessage","type":"string"}],"name":"update","outputs":[],"stateMutability":"nonpayable","type":"function"}];

async function getContract(){
    let res = await tronWeb.contract(abi,"416A2383E04DF36C74A7EA415E554147C3EE0AF4C7");
    console.log(res);
}
getContract();// Execute the function