I'm working on a new Smart Contract for TRON. I need to sum each amount of paying. But when I get the value, I got a REVERT error:
pragma solidity ^0.8.0;
contract Test {
uint counter = 0;
function add() public payable {
counter += msg.value;
}
function getCounter() public view returns(uint){
return counter;
}
}
The "getCounter" return REVERT error. Why? How can I manage sum of msg.value's ?