Trying to find a way or documentation in obtaining the timestamp of when an address received the token in a smart contract.

I have read many reflection based contracts that apply different levels of fees on receiving and sending the token based on the time, but naively, isn't the following just taking from the start of the swap to that point in the function being called?

uint256 private _start_timestamp = block.timestamp;

function _getMultiplier() private view returns (uint256) {
    uint256 time_since_start = block.timestamp - _start_timestamp;
    uint256 hour = 60 * 60;
    if (time_since_start < 1 * hour) {
        return (3);
    } else if (time_since_start < 2 * hour) {
        return (2);
    } else {
        return (1);

Does this get the timestamp of when the current address received the token?

Basically, I need to know if the current address is sending the token, when did they receive the token.

Another thing that has crossed my mind, I had initially thought I could use the Pancakeswap router to identify the timestamp. However, whilst the initial liquidity will be added to Pancakeswap, the same logic needs to be applied to exchanges.

  • Is _start_timestamp updated at some other function? If it isn't updated then it will be initialized when the contract is deployed and time_since_start will measure the time since deployment. – Ismael Jun 14 at 21:06

Your Answer

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

Browse other questions tagged or ask your own question.