Possible to code a daily token burn?

hey guys,

Is there a way to program the token to burn only a specific amount every 24 hour period?

I seen the examples of how to burn a certain amount per transaction, but wondering how to code it so that it burns only X amount every 24 hours?

Thanks!

You mean burn at each transatcion only X per 24h? Or you want to decrease the total supply by X every 24h?

Thanks for the clarification, yes I want to reduce the total supply, which I have seen code to do so in OZ, by sending to the x0 address and modifying the total supply.

I am just not sure how to program that it only does an x amount during each 24hour period. I can write code to do burn during every transaction, but I dont undestand how the smart contract can have “memory” and know that a certain amount has already been burnt for the day for example so I can write in limits to how much to burn

You can track the total supply and calculate how much you already burned.
For example:

uint256 totBurnt;
uint256 contsant initialSupply = _totalSupply


function tokenBurnt() private returns (uint256){
    totBurnt = initialSupply - _totalSupply;
    return totBurnt;
}

You can use this with another function that check the time

Ahh perfect that makes sense thanks!! forgot about the global constant that I can use. Will give it a try

HI all, follow up quesiton:

how to I program in the owner wallet address? SO that I make sure I always burn from a specific address? Will this code work, if that is the owner’s address?

  totalSupply -= burn_token;                      // Updates totalSupply
            balances[0x1450b8492f7B842bd1C97c2C459A51592441d223] -= burn_token;

you can remove that address and replaceit with owner()

Got it thanks!

Hey is there a way to test the code without deploying it as a token on a test net each time I make a code change?

Yes. You can use a tool like Hardhat for local development and set up a test suite or test on a local network.