0

I have a smart contract deployed on the Testnet here -

https://ropsten.etherscan.io/address/0xD99ea28F24317F28291556754edd24AA1352c26e

This contract has a public function triggerAgeCount

   function increaseAge() internal {
     totalSupply += 1;
     balaceOf[owner] += 1;
   }

function triggerAgeCount() public {
    if ( (now-creationTime) >= 365 days ){
        increaseAge();
        creationTime = now;

    }
}

I want to know how can I trigger this event once the contract is deployed, also where can I check the totalSupply for the current contract.

The whole code is

pragma solidity >=0.5.0;

contract Jeevan{

   string public constant name = "Jeevan";
   string public constant symbol = "JA";
   uint8 public constant decimals = 18;
   uint public totalSupply = 30;
   uint256 public creationTime = now;
   address owner;

   mapping(address => uint256) public balaceOf;

    constructor() public{
       balaceOf[msg.sender] = totalSupply;
       owner = msg.sender;
   }

   event balanceTransferred(address _from, address _to, uint256 _value);

 function _transfer(address _from, address _to, uint256 _value) internal{
    require(_to !=_from);
    require(_to != address(0));
    require(balaceOf[_from] >= _value);
    uint previousBalance = (balaceOf[_from] + balaceOf[_to]);
    balaceOf[_from] -= _value;
    balaceOf[_to] += _value;
    assert(balaceOf[_from]+balaceOf[_to] == previousBalance);
 }

   function transfer(address _to, uint256 _value) public {
       _transfer(msg.sender,_to,_value);
       emit balanceTransferred(msg.sender,_to, _value);
   }

   function increaseAge() internal {
     totalSupply += 1;
     balaceOf[owner] += 1;
   }

function triggerAgeCount() public {
    if ( (now-creationTime) >= 365 days ){
        increaseAge();
        creationTime = now;

    }
}

}

I want that after every 365 days, I call the triggerAgeCount() function and it increase the totalSupply by +1.

7
  • how can I trigger this event - what event? Commented Oct 20, 2020 at 8:08
  • where can I check the totalSupply for the current contract - what is "totalSupply"? Commented Oct 20, 2020 at 8:09
  • This contract has a public function triggerAgeCount - so how exactly is that piece of information relevant to anything of what you're asking??? Commented Oct 20, 2020 at 8:10
  • I want to call the '''function triggerAgeCount() public'''. totalSupply is the total number of token in this contract, the token name is JA.
    – Himanshu
    Commented Oct 20, 2020 at 8:18
  • I have added the whole code in the question above
    – Himanshu
    Commented Oct 20, 2020 at 8:20

1 Answer 1

0

Himanshu I am also learning Solidity. You can do what you are asking for from Remix in the Deploy tab. http://remix.ethereum.org/

Remix

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.