5

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.

2 Answers2

2

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.

Lauri Peltonen
  • 29,391
  • 3
  • 20
  • 57
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.

Shane Fontaine
  • 18,036
  • 20
  • 54
  • 82
  • 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 09 '18 at 03:46
  • I do not understand your question. – Shane Fontaine Oct 09 '18 at 03:57
  • You cannot freeze certain amounts of ERC20 tokens unless you are in possession of them. – Shane Fontaine Oct 09 '18 at 04:09
  • 1
    @vhie yes, I want to know feasibility of the solution you are suggesting. – Dhara Patel Oct 09 '18 at 04:09
  • If you are talking about the whitelist, it is very hard. The issue is that you will be able to freeze anybody's tokens whenever you want, and people will likely not want you to have that power. – Shane Fontaine Oct 09 '18 at 04:12
  • 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 09 '18 at 04:25
  • Sure. If it fits in your application. – Shane Fontaine Oct 09 '18 at 04:45
  • 1
    @shane can i please get a reference to the method ERC721 by which we can implement freezing functionality mentioned above. – Dhara Patel Oct 09 '18 at 04:54
  • I've not seen one, but the idea would be that you implement a freeze function for a specific asset ID (each NFT has a specific ID). The transfer function would then check if that specific NFT can be transferred at the time of the attempt. – Shane Fontaine Oct 09 '18 at 04:55