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 */ }


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
  • I have not implemented any IcoDuration function so that might not work in my case. I´m using a standard and basic ERC20 token smart contract. Can you specify in this casa how can i add the IcoDuration function, here is the test contract: etherscan.io/address/… – Jabaco Oct 28 '17 at 11:51
  • Just change now > IcoDuration to now > 1514764800. IcoDuration is not a function, its just an example of a field or variable which holds the duration of your contract. – Zenos Pavlakou Oct 28 '17 at 11:57
  • Ok, I´ll try that and let you know! thanks in advance ;) – Jabaco Oct 28 '17 at 11:59
  • You will also need a variable of type address called owner which will hold your address. – Zenos Pavlakou Oct 28 '17 at 12:00
  • I tried to add this snippet code but I´m getting compile error (undeclared identifier) so I cannot deploy the contract, could you please check the contract address and tell me where exactly should I add the code you provided. Thanks in advance – Jabaco Oct 28 '17 at 12:11
//this is where you declare the identifier owner

address owner;

//whith this modifier, only you can call the transfer function 
//when now <= 1514764800.

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

//the identifier owner is initialized once the contract is deployed and 
//set to the address of the message sender. Note that this should be in 
//the constructor of the contract, which is always the function with the
//same name as the contract.

function ERC20Token() {
    owner  = msg.sender;
    //rest of constructor

//by adding notPaused here, the function will only successfully execute when
//A: you the owner call the function before or after the block 1514764800 or
//B: when anyone else calls the the function after the block 1514764800

function transfer(address to, uint256 amount) public notPaused returns (bool) {
    //rest of function
  • Well thank you but that has make it even a bit more difficult to add the correct code in the correct place. I´m really not an expert in smart contract and I try to copy and paste instructions and code snippets but this is a bit out of my league for now... – Jabaco Oct 28 '17 at 12:45
  • I just made the changes you want. Is there any way I can send you the contract in a private message? – Zenos Pavlakou Oct 28 '17 at 12:51

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.