1

Private investors usually have tokens locked in their wallet and released by a specific schedule. I want to find this schedule for any given token contract address and a given wallet address (function of locked tokens number in the wallet dependent of the date) using python. How do I do this? I am already using web3.py, does it have such a functionality?

The function should be working for any ERC20 token contract I know the contract address of.

---------EDIT-----------

From checking the answers and comments here, it looks like there is no uniform function in every ERC20 contract that returns the questioned data, but a transfer lock can be implemented in many different ways. Therefore, the only method I can think of to find the data is simulation.

I came up with this idea:

  1. Fork the ethereum mainnet using ganache-cli in a QEMU-KVM virtual machine:

https://www.quicknode.com/guides/web3-sdks/how-to-fork-ethereum-blockchain-with-ganache

  1. unlock all accounts in the forked testnet

  2. find all token holders of the token in question

  3. try to transfer the full token amount for each token holder to a burn address. When the transfer fails, we know there must be a transfer lock for some amount of the tokens

  4. try to find that amount by transferring partially until I know the locked amount up to a good precision

  5. alter the system time in the virtual machine to one day in the future (this assumes the testnet uses the system time to calculate how many tokens are vested, is this indeed the case?)

  6. repeat steps 5 and 6 until all the tokens are unlocked.

Would be great to get some feedback if this will work of if I missed something.

----- EDIT 2--------

After checking multiple token contracts, I came to the conclusion that this problem is probably impossible to solve, because many contracts require a claim function or similar to be called before being able to transfer tokens. In the above steps, I assumed that this check is done by the transfer function itself. A lot of tokens even have a separate vault contract for the private sale investors. I see no way how to make this work automatedly for any deployed contract - because I do not know the details of each implementation. I do no know the address of the correct vault contract if there is one, and I also do not know the steps presale investors need to follow to claim the tokens (name of the function can vary arbitrarily).

If anybody has an idea how to solve this, I'd be interested to know.

To clarify:

  • This question is NOT about writing my own contract.
  • I do NOT want to know how to interact with a particular contract. I know how this is done. I want to find a general solution which works for all ERC20 tokens.
  • I do not know any details about a particular token's code. I only know the contract address of each token from my database.
3
  • Vesting schedules can be implemented in many different ways. One popular way is to use Sablier (disclaimer: I am the founder). You could query our subgraph if you are interested in the vesting schedule of a Sablier user. Aug 31 at 9:07
  • @PaulRazwanBerg querying a subgraph would be a great option. Can you tell me what other ways there are, and how popular they are? I want my code to be as universal as possible and work for as many contracts as possible. I have no problem with implementing 10 different ways.
    – Tom Atix
    Aug 31 at 17:24
  • Another idea... I mean, the smart contracts must lead to the same result, whatever method is used. Do you think it is possible to simulate this? Like for example, launching my own testnet node, deploying the smart Contract exactly as in the Mainnet, then changing the time settings somehow that the whole testnet runs in time lapse, and observing how the tokens are unlocked?
    – Tom Atix
    Aug 31 at 17:29
0

If you have the contract ABI and address, you can use web3.py to call the contract and fetch its past emitted events. Based on this information, you can construct on the Python side what has happened and what is the current contract state.

More information in Web3.py documentation how to interact with the contracts.

12
  • Thank you for your answer, but this wasn't my question. I know smart contracts cannot be programmed in python. I said I want to "determine the schedule", I want to investigate the vesting schedule of an existing token. I don't want to create a new smart contract. And I guess this should be possible somehow by using web3.py, as it allows interacting with smart contracts (for example, fetching the total supply is also possible).
    – Tom Atix
    Aug 31 at 17:22
  • Ok I misunderstood. Let me edit the answer. Sep 1 at 8:23
  • Does the method of fetching past emitted events allow me to figure out the future vesting schedule?
    – Tom Atix
    Sep 1 at 8:37
  • I know how to interact with contracts in general, but I haven't found any standard ERC20 function which returns what I want to get. And the challenge of this question is that it should work for any ERC20 contract, not only a specific one. Simulation is the only way I can think of so far. But this would be a hassle, I guess.
    – Tom Atix
    Sep 1 at 8:40
  • Here is an existing vesting smart contract, study it github.com/TokenMarketNet/smart-contracts/blob/master/contracts/… Sep 2 at 4:59

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.