I am just getting started with smart contract programming and was trying to implement the pet-shop example as per this tutorial https://medium.com/tomochain/how-to-build-a-dapp-on-tomochain-85532a1192e7. The contract code is as under

pragma solidity ^0.5.0;
contract Adoption {
  address[16] public adopters;
  // Adopting a pet
  function adopt(uint petId) public returns (uint) {
    // check that petId is in range of our adopters array
    require(petId >= 0 && petId <= 15);
    // add the address who called this function to our adopter array
    adopters[petId] = msg.sender;
    // return the petId provided as a confirmation
    return petId;
  // Retrieving the adopters
  function getAdopters() public view returns (address[16] memory) {
    return adopters;

compiler throws the following error: Error parsing /Users/Zubair/pet-shop-tutorial/contracts/Adoption.sol: ParsedContract.sol:1:1: ParserError: Expected pragma, import directive or contract/interface/library definition. {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf470 ^ Compilation failed. See above. Truffle v5.0.3 (core: 5.0.3) Node v10.15.1

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.