4

The Freezing functionality is to impose the restrictions on sales of some portion of ERC20 tokens for certain time periods in Admin Dashboard when transferring the ERC20 tokens to buyers. The Admin can randomly specify the freezing portion and freezing period in Admin Dashboard. For example, we must transfer 10,000 ERC20 tokens to a buyer. We transfer 1000 tokens with no restriction, 4000 tokens with 3 months freezing, and 5000 tokens with 5 months freezing. This Freezing functionality is applicable to all phases of ICO (pre-sale, ICO, and post-sale).

Can i have this kind of functionality via smart contract for ERC20 tokens? Please suggest me even if the functionality can be done without smart-contract.

Thank you in advance.

1

I believe @shane's answer is a bit misleading. Yes, you can add freezing functionality in your token contract, as mentioned in the comments.

If you are worried whether this gives "too much power" to the token contract owner, it's just an issue about how the freezing functionality is coded. If you add a generic possibility to freeze whatever transfers whenever the owner wants then I agree that it might not be a good idea business-wise.

However, nothing stops you from implementing the freezing functionality so that (certain) transfers can be frozen only during some time (or other criteria) and after that the freezing functionality would not work anymore and it would be useless.

So your transfer function could have something like this:

pragma solidity ^0.4.25;
contract TokenContract { 
    uint256 freezingPossible = 1539060104; // decides by you
    address oneFrozen = 0x123;


    function transfer(address to, uint tokens) public returns (bool success) {
        if (now < freezingPossible) {
            require(to != oneFrozen, "The account should not be frozen");
        }
        // normal transfer logic
    }
}

The above code actually prevents transferring tokens to the frozen account, not from it as is required, but hopefully you get the idea.

Remember to implement similar functionality also for transferFrom.

  • Thank you! , but is it feasible to implement partially freeze tokens for perticular time? – Dhara Patel Oct 10 '18 at 5:00
  • Depends on your business needs. As I demonstrated, it's not very complicated code-wise. – Lauri Peltonen Oct 10 '18 at 6:05
0

You cannot do this with ERC20 tokens, as there are no unique identifiers for each token, meaning you cannot freeze only a certain number of them. To do this, you would need to use ERC721.

An alternative is to set up a whitelist that is checked each time a transfer occurs. You can specify which addresses can and cannot spend and when, but this only works if there are not a lot of transactions occurring and you can keep tight control.

Your best option is to put all the tokens in a whitelist contract that distributes tokens to certain buyers after a certain date. See the (outdated) BAT token distribution for this.

  • 1
    Will it not be advisable to put a kind of freeze function on your erc20 token contract and check if a certain amount of the fund is frozen upon transfer? – vhie Oct 9 '18 at 3:46
  • I do not understand your question. – shane Oct 9 '18 at 3:57
  • 1
    @vhie yes, I want to know feasibility of the solution you are suggesting. – Dhara Patel Oct 9 '18 at 4:09
  • 1
    @shane function transfer(address _to, uint256 _value) public returns (bool) { require(Check if frozen) Yes I was talking about something like this but I also do understand the point that it would give so much power to the owner. So I was asking if this is advisable to do. – vhie Oct 9 '18 at 4:25
  • 1
    @shane can i please get a reference to the method ERC721 by which we can implement freezing functionality mentioned above. – Dhara Patel Oct 9 '18 at 4:54

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.