What am I doing wrong? When I use the ctrl + left mouse key combination, vscode displays the Transfer function in the ERC20.sol file with no errors. But when I call the Transfer function at the file that uses the import file ERC20.sol, I get this error

enter image description here

The contents of the Transfer function at ERC20.sol are:

  event Transfer(address indexed _from, address indexed _to, uint256 _value) ;

I assume you are following this or an equivalent interface:


pragma solidity ^0.4.24;

 * @title ERC20 interface
 * @dev see https://github.com/ethereum/EIPs/issues/20
interface IERC20 {
  function totalSupply() external view returns (uint256);

  function balanceOf(address _who) external view returns (uint256);

  function allowance(address _owner, address _spender)
    external view returns (uint256);

  function transfer(address _to, uint256 _value) external returns (bool);

  function approve(address _spender, uint256 _value)
    external returns (bool);

  function transferFrom(address _from, address _to, uint256 _value)
    external returns (bool);

  event Transfer(
    address indexed from,
    address indexed to,
    uint256 value

  event Approval(
    address indexed owner,
    address indexed spender,
    uint256 value

If so, Transfer here is an event, not a function. Thus, if you are intending to emit an event, you should preface the event call with emit:

emit Tranfer(...);

Read more here: Solidity // Contracts // Events.

  • I'm actually using this interface. So your idea is that I should change the Transfer (msg.sender, _to, _value) to emit Transfer (msg.sender, _to, _value) – xPain Sep 4 '18 at 3:36
  • 1
    What are you expecting that line of code to do? Take a look at this which looks to be exactly what you are trying to emulate. It looks to me like you want to emit an event, thus yes you should simply add emit to the beginning of the line. – Shawn Tabrizi Sep 4 '18 at 3:41
  • I did not use is TokenInterface after import "./TokenInterface .sol". This causes Vscode to not determine the Transfer event. Thank you so much. – xPain Sep 4 '18 at 3:47

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.