I am trying to access some values from the contract to display on the front end. I did this by calling some getter methods, only two of the three work and for the third, I get this "Uncaught (in promise) TypeError: Cannot read property 'tronWeb' of undefined" in the console.
Here is the Javascript/React
await Utils.setTronWeb(window.tronWeb, contractAddress);
...
// this one works
async getTron2Balance()
{
const bal = (await Utils.contract.getMyTron2().call()).toNumber();
console.log("Tron² Balance:", bal);
document.getElementById("tron2").innerHTML = bal;
this.getMicroTronBalance();
}
// this one doesn't
async getMicroTronBalance()
{
const bal = (await Utils.contract.getMyMicroTron().call()).toNumber();
console.log("MicroTron Balance:", bal);
document.getElementById("microTron").innerHTML = bal;
}
Now here is the solidity code
function getMyTron2() public
view
returns
(uint256)
{
return safeTron[msg.sender];
}
function getMyMicroTron() public
view
returns
(uint256)
{
updatePlayersMicroTron(msg.sender);
tempOldTime = block.timestamp;
return rewardedMicroTron[msg.sender];
}
I feel like it's something to do with the block.timestamp, anyone got an idea?