The functions remainingToken() and totalContribution() are not working in testnet but working in remix.

function  remainingToken() public view ownable returns (uint remainingSupply)  {

        return (balances[address(this)]);

    //Real time

    function presenTime () public view returns ( uint){
        return block.timestamp;
    //Total Supply
    function totalSupply() public override view returns (uint) {
        return maximumSupply ;
    //Total Ether Contributed  
    function totalContribution() public ownable view returns(uint){
        return address(this).balance;

    //Token balance of any address 

    function balanceOf(address tokenOwner) public override view returns (uint balance) {
        return balances[tokenOwner];

    //Check Allowance

    function allowance(address tokenOwner, address spender) public override view returns (uint remaining) {
        return allowed[tokenOwner][spender];



  • Just wanna know, after deploying the contract to the testnet, have you called the functions from other addresses and contributed eth from those accounts before calling the above functions you have mentioned?
    – Ad-h0c
    Commented Sep 15, 2022 at 11:19

2 Answers 2


Can you share the contract link?

Also can you explain why you applied a "ownable" modifier to view functions?

  • 0x5942a9e591Ef9d84a708C080304dc36B17e33b01 I redeployed the contract Commented Sep 16, 2022 at 10:01
  • Will removing Ownable work??? Commented Sep 16, 2022 at 10:01
  • Removing ownable worked. Commented Sep 16, 2022 at 10:21

I am guessing you haven't used other address to make contributions by sending eth or call other functions after deploying to the testnet.

You should know that whatever the transactions you have made in the remix they belong to the remix only.

And you have to make new transactions in the tesnet to get the expected results.

  • Hii thanks for replying. I used 3 other addresses to send ether to the contract. Everything is working fine. Only these two functions are not returning the expected values they are just returning zero. Commented Sep 15, 2022 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.