0
pragma solidity >=0.5.0 <0.6.0;

import 'openzeppelin-solidity/contracts/token/ERC20/ERC20.sol';

 contract NautCoin is ERC20 {

  // string public constant name = 'NautCoin';
  // string public constant symbol = '0x0';
  // uint public constant decimals = 18;
  uint public timeLock = now + 1 days;
  uint256 public INITIAL_SUPPLY;
  address public player;

  constructor(address _player) 
  public {
    player = _player;
    INITIAL_SUPPLY = 10000 * (uint256(decimals()));
    // _totalSupply = INITIAL_SUPPLY;
    // _balances[player] = INITIAL_SUPPLY;
    _mint(player, INITIAL_SUPPLY);
    emit Transfer(address(0), player, INITIAL_SUPPLY);
  }
  
  function transfer(address _to, uint256 _value) public returns(bool) {
    super.transfer(_to, _value);
  }
  
 function approve(address _spender, uint256 _value) public returns(bool) {
   super.approve(_spender, _value);  
 }  
   
  // Prevent the initial owner from transferring tokens until the timelock has passed
  modifier lockTokens() {
    if (msg.sender == player) {
      require(now > timeLock);
      _;
    } else {
     _;
    }
  } 
} 

How do you resolve this error?

1
  • I think you have an extra ) in the line in the constructor where you set the INITIAL_SUPPLY. If this is the case, and your contract works afterwards, you may want to delete the question, as typo errors are generally not encouraged to be left up. Happy coding! Dec 7 '20 at 8:10
1

Well that was some strange troubleshooting I just did. I copypasted the contract in Remix and started scratching my head about what's wrong.

In the end it seems that there are some weird space characters around the approve function which the compiler doesn't like. So just remove that function and stuff around it and rewrite it with regular spaces and it works.

2
  • It was strange, but it was solved. Thank you. Dec 6 '20 at 13:55
  • This error can also occur when you have control structures e.g. for loop outside a function.
    – Onshop
    May 6 at 21:40

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.