0

I keep getting an error when I try "truffle compile" on the truffle pet shop tutorial. Here is my code

pragma solidity ^0.5.0;

contract Adoption {
  address[16] public adopters;

  function adopt(uint petId) public returns (uint) {
    require(petId >= 0 && petId <= 15);

    adopters[petId] = msg.sender;

    return petId;
  }

  function getAdopters() public view returns (address[16] memory) {
    return adopters;
  }

}

and this is my error

project:/contracts/Adoption.sol:1:1: ParserError: Expected pragma, import directive or contract/interface/library definition.
Adoption.sol
^------^

10
  • can u run: solc --version to get back the version i suspect the main problem is the compiler version
    – haxerl
    Sep 19 at 14:10
  • where do I run that command?
    – user82101
    Sep 19 at 14:26
  • on your terminal
    – haxerl
    Sep 19 at 14:26
  • i've got solc 0.8.7
    – user82101
    Sep 19 at 14:31
  • try pragma ^0.8.0 instead of 0.5.0
    – haxerl
    Sep 19 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.