0

i'm currently learning solidity and was toying around with the now keyword. This function is supposed to mint new tokens at an inflation rate of 0.05% per year. I'm just not sure if the now keyword is reliable since, from my understanding, it is based on information from miners which could be faulty. Any thoughts? Does this code work and is it reliable?

uint256 public deploymentTime = now; uint256 public year = 0; uint256 public supply = 90000000;

function checkInflation() returns (bool success)
{
    if(year >= 5) {
        return false;
    }
    else if (now >= deploymentTime + 31557600) { //31557600 seconds per year
        uint256 supplyIncrease = (supply*5) / 100;
        mintToken(0x8E73AEF2448068d4e31F86Aa08279465339fF601, supplyIncrease);
        year+=1; // increase the current year count
        supply += supplyIncrease; // increase supply count 
        deploymentTime += 31557600; // increase the time since deployment
        return true;
    }
    else {
        return false;
    }
}
0

I think this is your best option and I wont expect anything wrong with it. Other than that you could use services like ETH-Tempus to call your contract at the particular time you are asking for. ETH-Tempus is free to use in the test net.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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