I copy and pasted the code found here: https://www.ethereum.org/token into a file called TokenERC20.sol

When I run

truffle compile

I get this error:

SyntaxError: Expected "contract", "import", "library", "pragma", "using", comment, end of input, end of line, or whitespace but "i" found.
    at peg$buildStructuredError (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:177767:12)
    at Object.peg$parse [as parse] (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:181366:11)
    at Object.parse (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:89808:23)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:57847:36
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:50141:5
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:66021:16
    at next (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:75933:18)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:50126:7
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:96942:5
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:75838:16

Anyone know what could be causing this?

EDIT The problem appears to be here:

pragma solidity ^0.4.8;

interface tokenRecipient {
   function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public;

contract TokenERC20 {
    // Public variables of the token
    string public name;
    string public symbol;
    uint8 public decimals = 18;
    // 18 decimals is the strongly suggested default, avoid changing it
    uint256 public totalSupply;

If I comment out the interface and every line that uses it then it compiles fine. Is there some problem with how the interface is declared?

  • Which editor are you using to edit the file? Can you save your file as utf8 and try again? – Ismael Oct 28 '17 at 21:01
  • @Ismael I'm using Atom and at the bottom of the file it says its utf8 already – user714171 Oct 29 '17 at 17:20
  • @Ismael Thanks for the help, i posted an edit to the question. I found the line that is causing the problem, but im not sure how to rewrite it? – user714171 Oct 29 '17 at 17:32
  • 1
    What's your Solidity compiler version? It seems that it requires 0.4.11 or higher (the pragma notwithstanding). – benjaminion Oct 29 '17 at 17:52

Interface contracts were introduced in Solidity version 0.4.11:

Version 0.4.11

This release ... adds interface contracts and implements some additional safety checks.



  • Support interface contracts.


Compilers older than 0.4.11 give the error you report.

Check your compiler version, but your pragma solidity ^0.4.8; doesn't look promising.

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.