0

I would like to make a contract where people can deposit tokens that were created before the end of 2019. In other words, I need to check the date the contact was released before accepting tokens that minted the tokens as a deposit. Would it be possible to accomplish this in solidity, and how ?

3
  • The question does not make sense. Can you please rephrase the question? Mar 23, 2020 at 15:22
  • 1
    @DanielLucaCleanUnicorn: It's actually an interesting question. It can be done pretty easily off-chain (e.g., using Etherscan API, or more generally, fetching the contract's bytecode and figuring out what block it was deployed at). I'm not so sure that this is possible on Solidity. Need to give it some thought... Mar 23, 2020 at 15:56
  • Now I understand the question. Thanks! Mar 23, 2020 at 17:37

1 Answer 1

1

It's not possible to read previous state in Solidity or EVM.

The only information which can be obtained from the past is the block hash (only for the last 255 blocks).

In this case you would need to check if a contract's address had code attached before a block number. That block number would represent 2020-01-01, any address that did not have code before but has code now means it was not deployed in 2019.

It is possible to do this if you code this in the contract that you monitor and you save the time stamp when the contract was deployed (without any way to edit the value).

TL;DR; It's not possible unless you control the tokens you need to check.

4
  • First off, it is possible. For example, scan the entire blockchain from genesis and until 1/1/2020, find all ERC20 tokens, and hard-code their addresses in a mapping in your contract (or if there are too many of them, then add a setter function to insert them into the mapping one by one). Second, you start with It's not possible and then you carry on explaining how it can be done. So your answer is rather unclear IMO (in particularly the middle paragraph). Mar 23, 2020 at 19:21
  • The full sentence is It's not possible to read previous state in Solidity or EVM. Feel free to add an answer. Mar 23, 2020 at 20:36
  • I still stand by my answer that it is impossible. The question is Is it possible to see a token contract release date in Solidity? That is currently not possible. You can create a list of tokens, but you can't see a token release date in Solidity. Mar 23, 2020 at 20:47
  • 1
    Thanks, that is all I wanted to know, the answer is good enough to be accepted. Mar 24, 2020 at 14:08

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.