Solidity: ParserError: Expected pragma, import directive or contract /interface/library definition












0















I am getting error with both latest solc (0.5.2 version) and 0.4.25 too while I am writing Simple contract



I have tried following steps




  1. uninstalled Solc: npm uninstall solc

  2. Installed targeted version: npm install --save solc@0.4.25


  3. node compile.js (code given below)



      { contracts: {},
    errors:
    [ ':1:1: ParserError: Expected pragma, import directive or contract
    /interface/library definition.nD:\RND\BlockChain\contracts\Inbox.soln^n' ],sourceList: [ '' ],sources: {} }



Compile.js



const path  = require('path');
const fs = require('fs');
const solc = require('solc');
const inPath = path.resolve(__dirname,'contracts','Inbox.sol');
const src = fs.readFileSync(inPath,'UTF-8');
const res = solc.compile(inPath, 1);

console.log(res);


Inbox.sol



pragma solidity ^0.4.25;

contract Inbox {
string message;


function Inbox(string passedName) public {
message = passedName;
}

function setMessage(string newMsg) public {
message = newMsg;
}

function getMessage() public view returns(string){
return message;
}
}


Code worked well on Remix, for version 0.5.2 I have added memory tag to make it compile on Remix.



ex:   function setMessage(string **memory** newMsg) 









share|improve this question



























    0















    I am getting error with both latest solc (0.5.2 version) and 0.4.25 too while I am writing Simple contract



    I have tried following steps




    1. uninstalled Solc: npm uninstall solc

    2. Installed targeted version: npm install --save solc@0.4.25


    3. node compile.js (code given below)



        { contracts: {},
      errors:
      [ ':1:1: ParserError: Expected pragma, import directive or contract
      /interface/library definition.nD:\RND\BlockChain\contracts\Inbox.soln^n' ],sourceList: [ '' ],sources: {} }



    Compile.js



    const path  = require('path');
    const fs = require('fs');
    const solc = require('solc');
    const inPath = path.resolve(__dirname,'contracts','Inbox.sol');
    const src = fs.readFileSync(inPath,'UTF-8');
    const res = solc.compile(inPath, 1);

    console.log(res);


    Inbox.sol



    pragma solidity ^0.4.25;

    contract Inbox {
    string message;


    function Inbox(string passedName) public {
    message = passedName;
    }

    function setMessage(string newMsg) public {
    message = newMsg;
    }

    function getMessage() public view returns(string){
    return message;
    }
    }


    Code worked well on Remix, for version 0.5.2 I have added memory tag to make it compile on Remix.



    ex:   function setMessage(string **memory** newMsg) 









    share|improve this question

























      0












      0








      0








      I am getting error with both latest solc (0.5.2 version) and 0.4.25 too while I am writing Simple contract



      I have tried following steps




      1. uninstalled Solc: npm uninstall solc

      2. Installed targeted version: npm install --save solc@0.4.25


      3. node compile.js (code given below)



          { contracts: {},
        errors:
        [ ':1:1: ParserError: Expected pragma, import directive or contract
        /interface/library definition.nD:\RND\BlockChain\contracts\Inbox.soln^n' ],sourceList: [ '' ],sources: {} }



      Compile.js



      const path  = require('path');
      const fs = require('fs');
      const solc = require('solc');
      const inPath = path.resolve(__dirname,'contracts','Inbox.sol');
      const src = fs.readFileSync(inPath,'UTF-8');
      const res = solc.compile(inPath, 1);

      console.log(res);


      Inbox.sol



      pragma solidity ^0.4.25;

      contract Inbox {
      string message;


      function Inbox(string passedName) public {
      message = passedName;
      }

      function setMessage(string newMsg) public {
      message = newMsg;
      }

      function getMessage() public view returns(string){
      return message;
      }
      }


      Code worked well on Remix, for version 0.5.2 I have added memory tag to make it compile on Remix.



      ex:   function setMessage(string **memory** newMsg) 









      share|improve this question














      I am getting error with both latest solc (0.5.2 version) and 0.4.25 too while I am writing Simple contract



      I have tried following steps




      1. uninstalled Solc: npm uninstall solc

      2. Installed targeted version: npm install --save solc@0.4.25


      3. node compile.js (code given below)



          { contracts: {},
        errors:
        [ ':1:1: ParserError: Expected pragma, import directive or contract
        /interface/library definition.nD:\RND\BlockChain\contracts\Inbox.soln^n' ],sourceList: [ '' ],sources: {} }



      Compile.js



      const path  = require('path');
      const fs = require('fs');
      const solc = require('solc');
      const inPath = path.resolve(__dirname,'contracts','Inbox.sol');
      const src = fs.readFileSync(inPath,'UTF-8');
      const res = solc.compile(inPath, 1);

      console.log(res);


      Inbox.sol



      pragma solidity ^0.4.25;

      contract Inbox {
      string message;


      function Inbox(string passedName) public {
      message = passedName;
      }

      function setMessage(string newMsg) public {
      message = newMsg;
      }

      function getMessage() public view returns(string){
      return message;
      }
      }


      Code worked well on Remix, for version 0.5.2 I have added memory tag to make it compile on Remix.



      ex:   function setMessage(string **memory** newMsg) 






      node.js ethereum solidity






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 27 '18 at 7:36









      yogesh sharmayogesh sharma

      313




      313
























          2 Answers
          2






          active

          oldest

          votes


















          0














          You don't seem to be using solc-js correctly. Please see the documentation: https://github.com/ethereum/solc-js



          Specifically, you need to construct an input object and then stringify it and pass that to solc.compile().






          share|improve this answer
























          • thanks DAnsermino for your time. I have tried using as const res = solc.compile(JSON.stringify(inPath), 1); But it still giving me same error

            – yogesh sharma
            Jan 2 at 10:45













          • You can't just pass in the path, you need to construct an import object. why are you including the 1? If you read the docs you will see the second argument is an optional parameter for an import callback.

            – DAnsermino
            Jan 8 at 20:50





















          0














          solc <= v0.4.25



          Your primary issue using Solidity/solc v0.4.25 is your constructor definition.



          You currently have your constructor defined as:



          function Inbox(string passedName) public


          However, defining constructors with the same name as the contract has been deprecated in Solidity. Try defining your constructor using the constructor keyword instead.



           constructor(string passedName) public


          If you are using solc v0.4.25, please refer to the documentation in order to understand how to properly pass input to the compile function. See my reference below:



          const input = { 
          'Inbox.sol': fs.readFileSync(path.resolve(__dirname, 'contracts', 'Inbox.sol'), 'utf8')
          }
          const output= solc.compile({sources: input}, 1);

          if(output.errors) {
          output.errors.forEach(err => {
          console.log(err);
          });
          } else {
          const bytecode = output.contracts['Inbox.sol:Inbox'].bytecode;
          const abi = output.contracts['Inbox.sol:Inbox'].interface;
          console.log(`bytecode: ${bytecode}`);
          console.log(`abi: ${JSON.stringify(JSON.parse(abi), null, 2)}`);
          }


          solc >= v0.5.0



          If you are using Solidity/solc v0.5.2, you will also need to fix your constructor definition. Furthermore, you will need to add the memory keyword to each function that returns or accepts the string type.



          For example:



          function setMessage(string newMsg) public


          should be declared as:



          function setMessage(string memory newMsg) public


          Futhermore, please see the latest documentation in order to understand the differences between the latest Solidity compiler and the older version. See my reference below for how to define the input for the compile function utilizing the latest compiler:



          const input = { 
          language: "Solidity",
          sources: {
          "Inbox.sol": {
          content: fs.readFileSync(path.resolve(__dirname, "contracts", "Inbox.sol"), "utf8")
          }
          },
          settings: {
          outputSelection: {
          "*": {
          "*": [ "abi", "evm.bytecode" ]
          }
          }
          }
          }
          const output = JSON.parse(solc.compile(JSON.stringify(input)));

          if(output.errors) {
          output.errors.forEach(err => {
          console.log(err.formattedMessage);
          });
          } else {
          const bytecode = output.contracts['Inbox.sol'].Inbox.evm.bytecode.object;
          const abi = output.contracts['Inbox.sol'].Inbox.abi;
          console.log(`bytecode: ${bytecode}`);
          console.log(`abi: ${JSON.stringify(abi, null, 2)}`);
          }





          share|improve this answer


























          • thanks Ben for your time, as mentioned in my comment I have tired with v 5 too. For brevity I have added v4 code above. I still get the same error.

            – yogesh sharma
            Jan 2 at 10:44













          • @yogeshsharma, please see my updated answer. I've included code samples for the older and latest versions of solc.

            – Ben Beck
            Jan 3 at 0:09











          • Thanks for your time and help. I will try this and let you know

            – yogesh sharma
            Jan 7 at 9:18











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53941422%2fsolidity-parsererror-expected-pragma-import-directive-or-contract-interface%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You don't seem to be using solc-js correctly. Please see the documentation: https://github.com/ethereum/solc-js



          Specifically, you need to construct an input object and then stringify it and pass that to solc.compile().






          share|improve this answer
























          • thanks DAnsermino for your time. I have tried using as const res = solc.compile(JSON.stringify(inPath), 1); But it still giving me same error

            – yogesh sharma
            Jan 2 at 10:45













          • You can't just pass in the path, you need to construct an import object. why are you including the 1? If you read the docs you will see the second argument is an optional parameter for an import callback.

            – DAnsermino
            Jan 8 at 20:50


















          0














          You don't seem to be using solc-js correctly. Please see the documentation: https://github.com/ethereum/solc-js



          Specifically, you need to construct an input object and then stringify it and pass that to solc.compile().






          share|improve this answer
























          • thanks DAnsermino for your time. I have tried using as const res = solc.compile(JSON.stringify(inPath), 1); But it still giving me same error

            – yogesh sharma
            Jan 2 at 10:45













          • You can't just pass in the path, you need to construct an import object. why are you including the 1? If you read the docs you will see the second argument is an optional parameter for an import callback.

            – DAnsermino
            Jan 8 at 20:50
















          0












          0








          0







          You don't seem to be using solc-js correctly. Please see the documentation: https://github.com/ethereum/solc-js



          Specifically, you need to construct an input object and then stringify it and pass that to solc.compile().






          share|improve this answer













          You don't seem to be using solc-js correctly. Please see the documentation: https://github.com/ethereum/solc-js



          Specifically, you need to construct an input object and then stringify it and pass that to solc.compile().







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 28 '18 at 13:59









          DAnserminoDAnsermino

          13819




          13819













          • thanks DAnsermino for your time. I have tried using as const res = solc.compile(JSON.stringify(inPath), 1); But it still giving me same error

            – yogesh sharma
            Jan 2 at 10:45













          • You can't just pass in the path, you need to construct an import object. why are you including the 1? If you read the docs you will see the second argument is an optional parameter for an import callback.

            – DAnsermino
            Jan 8 at 20:50





















          • thanks DAnsermino for your time. I have tried using as const res = solc.compile(JSON.stringify(inPath), 1); But it still giving me same error

            – yogesh sharma
            Jan 2 at 10:45













          • You can't just pass in the path, you need to construct an import object. why are you including the 1? If you read the docs you will see the second argument is an optional parameter for an import callback.

            – DAnsermino
            Jan 8 at 20:50



















          thanks DAnsermino for your time. I have tried using as const res = solc.compile(JSON.stringify(inPath), 1); But it still giving me same error

          – yogesh sharma
          Jan 2 at 10:45







          thanks DAnsermino for your time. I have tried using as const res = solc.compile(JSON.stringify(inPath), 1); But it still giving me same error

          – yogesh sharma
          Jan 2 at 10:45















          You can't just pass in the path, you need to construct an import object. why are you including the 1? If you read the docs you will see the second argument is an optional parameter for an import callback.

          – DAnsermino
          Jan 8 at 20:50







          You can't just pass in the path, you need to construct an import object. why are you including the 1? If you read the docs you will see the second argument is an optional parameter for an import callback.

          – DAnsermino
          Jan 8 at 20:50















          0














          solc <= v0.4.25



          Your primary issue using Solidity/solc v0.4.25 is your constructor definition.



          You currently have your constructor defined as:



          function Inbox(string passedName) public


          However, defining constructors with the same name as the contract has been deprecated in Solidity. Try defining your constructor using the constructor keyword instead.



           constructor(string passedName) public


          If you are using solc v0.4.25, please refer to the documentation in order to understand how to properly pass input to the compile function. See my reference below:



          const input = { 
          'Inbox.sol': fs.readFileSync(path.resolve(__dirname, 'contracts', 'Inbox.sol'), 'utf8')
          }
          const output= solc.compile({sources: input}, 1);

          if(output.errors) {
          output.errors.forEach(err => {
          console.log(err);
          });
          } else {
          const bytecode = output.contracts['Inbox.sol:Inbox'].bytecode;
          const abi = output.contracts['Inbox.sol:Inbox'].interface;
          console.log(`bytecode: ${bytecode}`);
          console.log(`abi: ${JSON.stringify(JSON.parse(abi), null, 2)}`);
          }


          solc >= v0.5.0



          If you are using Solidity/solc v0.5.2, you will also need to fix your constructor definition. Furthermore, you will need to add the memory keyword to each function that returns or accepts the string type.



          For example:



          function setMessage(string newMsg) public


          should be declared as:



          function setMessage(string memory newMsg) public


          Futhermore, please see the latest documentation in order to understand the differences between the latest Solidity compiler and the older version. See my reference below for how to define the input for the compile function utilizing the latest compiler:



          const input = { 
          language: "Solidity",
          sources: {
          "Inbox.sol": {
          content: fs.readFileSync(path.resolve(__dirname, "contracts", "Inbox.sol"), "utf8")
          }
          },
          settings: {
          outputSelection: {
          "*": {
          "*": [ "abi", "evm.bytecode" ]
          }
          }
          }
          }
          const output = JSON.parse(solc.compile(JSON.stringify(input)));

          if(output.errors) {
          output.errors.forEach(err => {
          console.log(err.formattedMessage);
          });
          } else {
          const bytecode = output.contracts['Inbox.sol'].Inbox.evm.bytecode.object;
          const abi = output.contracts['Inbox.sol'].Inbox.abi;
          console.log(`bytecode: ${bytecode}`);
          console.log(`abi: ${JSON.stringify(abi, null, 2)}`);
          }





          share|improve this answer


























          • thanks Ben for your time, as mentioned in my comment I have tired with v 5 too. For brevity I have added v4 code above. I still get the same error.

            – yogesh sharma
            Jan 2 at 10:44













          • @yogeshsharma, please see my updated answer. I've included code samples for the older and latest versions of solc.

            – Ben Beck
            Jan 3 at 0:09











          • Thanks for your time and help. I will try this and let you know

            – yogesh sharma
            Jan 7 at 9:18
















          0














          solc <= v0.4.25



          Your primary issue using Solidity/solc v0.4.25 is your constructor definition.



          You currently have your constructor defined as:



          function Inbox(string passedName) public


          However, defining constructors with the same name as the contract has been deprecated in Solidity. Try defining your constructor using the constructor keyword instead.



           constructor(string passedName) public


          If you are using solc v0.4.25, please refer to the documentation in order to understand how to properly pass input to the compile function. See my reference below:



          const input = { 
          'Inbox.sol': fs.readFileSync(path.resolve(__dirname, 'contracts', 'Inbox.sol'), 'utf8')
          }
          const output= solc.compile({sources: input}, 1);

          if(output.errors) {
          output.errors.forEach(err => {
          console.log(err);
          });
          } else {
          const bytecode = output.contracts['Inbox.sol:Inbox'].bytecode;
          const abi = output.contracts['Inbox.sol:Inbox'].interface;
          console.log(`bytecode: ${bytecode}`);
          console.log(`abi: ${JSON.stringify(JSON.parse(abi), null, 2)}`);
          }


          solc >= v0.5.0



          If you are using Solidity/solc v0.5.2, you will also need to fix your constructor definition. Furthermore, you will need to add the memory keyword to each function that returns or accepts the string type.



          For example:



          function setMessage(string newMsg) public


          should be declared as:



          function setMessage(string memory newMsg) public


          Futhermore, please see the latest documentation in order to understand the differences between the latest Solidity compiler and the older version. See my reference below for how to define the input for the compile function utilizing the latest compiler:



          const input = { 
          language: "Solidity",
          sources: {
          "Inbox.sol": {
          content: fs.readFileSync(path.resolve(__dirname, "contracts", "Inbox.sol"), "utf8")
          }
          },
          settings: {
          outputSelection: {
          "*": {
          "*": [ "abi", "evm.bytecode" ]
          }
          }
          }
          }
          const output = JSON.parse(solc.compile(JSON.stringify(input)));

          if(output.errors) {
          output.errors.forEach(err => {
          console.log(err.formattedMessage);
          });
          } else {
          const bytecode = output.contracts['Inbox.sol'].Inbox.evm.bytecode.object;
          const abi = output.contracts['Inbox.sol'].Inbox.abi;
          console.log(`bytecode: ${bytecode}`);
          console.log(`abi: ${JSON.stringify(abi, null, 2)}`);
          }





          share|improve this answer


























          • thanks Ben for your time, as mentioned in my comment I have tired with v 5 too. For brevity I have added v4 code above. I still get the same error.

            – yogesh sharma
            Jan 2 at 10:44













          • @yogeshsharma, please see my updated answer. I've included code samples for the older and latest versions of solc.

            – Ben Beck
            Jan 3 at 0:09











          • Thanks for your time and help. I will try this and let you know

            – yogesh sharma
            Jan 7 at 9:18














          0












          0








          0







          solc <= v0.4.25



          Your primary issue using Solidity/solc v0.4.25 is your constructor definition.



          You currently have your constructor defined as:



          function Inbox(string passedName) public


          However, defining constructors with the same name as the contract has been deprecated in Solidity. Try defining your constructor using the constructor keyword instead.



           constructor(string passedName) public


          If you are using solc v0.4.25, please refer to the documentation in order to understand how to properly pass input to the compile function. See my reference below:



          const input = { 
          'Inbox.sol': fs.readFileSync(path.resolve(__dirname, 'contracts', 'Inbox.sol'), 'utf8')
          }
          const output= solc.compile({sources: input}, 1);

          if(output.errors) {
          output.errors.forEach(err => {
          console.log(err);
          });
          } else {
          const bytecode = output.contracts['Inbox.sol:Inbox'].bytecode;
          const abi = output.contracts['Inbox.sol:Inbox'].interface;
          console.log(`bytecode: ${bytecode}`);
          console.log(`abi: ${JSON.stringify(JSON.parse(abi), null, 2)}`);
          }


          solc >= v0.5.0



          If you are using Solidity/solc v0.5.2, you will also need to fix your constructor definition. Furthermore, you will need to add the memory keyword to each function that returns or accepts the string type.



          For example:



          function setMessage(string newMsg) public


          should be declared as:



          function setMessage(string memory newMsg) public


          Futhermore, please see the latest documentation in order to understand the differences between the latest Solidity compiler and the older version. See my reference below for how to define the input for the compile function utilizing the latest compiler:



          const input = { 
          language: "Solidity",
          sources: {
          "Inbox.sol": {
          content: fs.readFileSync(path.resolve(__dirname, "contracts", "Inbox.sol"), "utf8")
          }
          },
          settings: {
          outputSelection: {
          "*": {
          "*": [ "abi", "evm.bytecode" ]
          }
          }
          }
          }
          const output = JSON.parse(solc.compile(JSON.stringify(input)));

          if(output.errors) {
          output.errors.forEach(err => {
          console.log(err.formattedMessage);
          });
          } else {
          const bytecode = output.contracts['Inbox.sol'].Inbox.evm.bytecode.object;
          const abi = output.contracts['Inbox.sol'].Inbox.abi;
          console.log(`bytecode: ${bytecode}`);
          console.log(`abi: ${JSON.stringify(abi, null, 2)}`);
          }





          share|improve this answer















          solc <= v0.4.25



          Your primary issue using Solidity/solc v0.4.25 is your constructor definition.



          You currently have your constructor defined as:



          function Inbox(string passedName) public


          However, defining constructors with the same name as the contract has been deprecated in Solidity. Try defining your constructor using the constructor keyword instead.



           constructor(string passedName) public


          If you are using solc v0.4.25, please refer to the documentation in order to understand how to properly pass input to the compile function. See my reference below:



          const input = { 
          'Inbox.sol': fs.readFileSync(path.resolve(__dirname, 'contracts', 'Inbox.sol'), 'utf8')
          }
          const output= solc.compile({sources: input}, 1);

          if(output.errors) {
          output.errors.forEach(err => {
          console.log(err);
          });
          } else {
          const bytecode = output.contracts['Inbox.sol:Inbox'].bytecode;
          const abi = output.contracts['Inbox.sol:Inbox'].interface;
          console.log(`bytecode: ${bytecode}`);
          console.log(`abi: ${JSON.stringify(JSON.parse(abi), null, 2)}`);
          }


          solc >= v0.5.0



          If you are using Solidity/solc v0.5.2, you will also need to fix your constructor definition. Furthermore, you will need to add the memory keyword to each function that returns or accepts the string type.



          For example:



          function setMessage(string newMsg) public


          should be declared as:



          function setMessage(string memory newMsg) public


          Futhermore, please see the latest documentation in order to understand the differences between the latest Solidity compiler and the older version. See my reference below for how to define the input for the compile function utilizing the latest compiler:



          const input = { 
          language: "Solidity",
          sources: {
          "Inbox.sol": {
          content: fs.readFileSync(path.resolve(__dirname, "contracts", "Inbox.sol"), "utf8")
          }
          },
          settings: {
          outputSelection: {
          "*": {
          "*": [ "abi", "evm.bytecode" ]
          }
          }
          }
          }
          const output = JSON.parse(solc.compile(JSON.stringify(input)));

          if(output.errors) {
          output.errors.forEach(err => {
          console.log(err.formattedMessage);
          });
          } else {
          const bytecode = output.contracts['Inbox.sol'].Inbox.evm.bytecode.object;
          const abi = output.contracts['Inbox.sol'].Inbox.abi;
          console.log(`bytecode: ${bytecode}`);
          console.log(`abi: ${JSON.stringify(abi, null, 2)}`);
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 3 at 0:08

























          answered Dec 27 '18 at 19:39









          Ben BeckBen Beck

          1,9381616




          1,9381616













          • thanks Ben for your time, as mentioned in my comment I have tired with v 5 too. For brevity I have added v4 code above. I still get the same error.

            – yogesh sharma
            Jan 2 at 10:44













          • @yogeshsharma, please see my updated answer. I've included code samples for the older and latest versions of solc.

            – Ben Beck
            Jan 3 at 0:09











          • Thanks for your time and help. I will try this and let you know

            – yogesh sharma
            Jan 7 at 9:18



















          • thanks Ben for your time, as mentioned in my comment I have tired with v 5 too. For brevity I have added v4 code above. I still get the same error.

            – yogesh sharma
            Jan 2 at 10:44













          • @yogeshsharma, please see my updated answer. I've included code samples for the older and latest versions of solc.

            – Ben Beck
            Jan 3 at 0:09











          • Thanks for your time and help. I will try this and let you know

            – yogesh sharma
            Jan 7 at 9:18

















          thanks Ben for your time, as mentioned in my comment I have tired with v 5 too. For brevity I have added v4 code above. I still get the same error.

          – yogesh sharma
          Jan 2 at 10:44







          thanks Ben for your time, as mentioned in my comment I have tired with v 5 too. For brevity I have added v4 code above. I still get the same error.

          – yogesh sharma
          Jan 2 at 10:44















          @yogeshsharma, please see my updated answer. I've included code samples for the older and latest versions of solc.

          – Ben Beck
          Jan 3 at 0:09





          @yogeshsharma, please see my updated answer. I've included code samples for the older and latest versions of solc.

          – Ben Beck
          Jan 3 at 0:09













          Thanks for your time and help. I will try this and let you know

          – yogesh sharma
          Jan 7 at 9:18





          Thanks for your time and help. I will try this and let you know

          – yogesh sharma
          Jan 7 at 9:18


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53941422%2fsolidity-parsererror-expected-pragma-import-directive-or-contract-interface%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Mossoró

          Error while reading .h5 file using the rhdf5 package in R

          Pushsharp Apns notification error: 'InvalidToken'