[Ethereum] Smart contract erc20 code snippet to prevent buyer token transfers

erc-20go-ethereumsmart-locktokens

I´m going to start a token pre-sale and I want to be able to send the tokens to the buyer but prevent the buyer to send tokens to another wallet.

I tried the following in my ERC20 smart contract but It actually prevent myself, the contract creator, to transfer tokens. I need to be able to send tokens to buyers and prevent buyers to transfer tokens till certain time in the future.

here is the test smart contract contract: https://etherscan.io/address/0x5783f4e4a1bec72f41f246c50ba3d06265d984a6#code

function transfer( address _to, uint _value) public {
require( now > 1514764800 );
/* Rest of Function */
}

Best Answer

You can do this.

modifier notPaused {
    require(now > 1514764800  || msg.sender == owner);
    _;
}

function transfer(address to, uint256 amount) public notPaused returns(bool) {
    //rest of function
}
Related Topic