0

In an attempt to compile my ABI and verify my contract, I am getting the following warning: "ParserError: Expected pragma, import directive or contract /interface/library definition" on the first line as shown. Kindly, assist me in overcoming this hurdle. My ABI source code is as follows: pragma solidity ^0.5.8; import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";

{
^ "contractName": "Salemcash",
  "abi": [
{
  "inputs": [],
  "payable": false,
  "stateMutability": "nonpayable",
  "type": "constructor" 
}, {
  "constant": true,
  "inputs": [
    {
      "name": "account",
      "type": "address"
    }
  ],
  "name": "getBalance",
  "outputs": [
    {
      "name": "",
      "type": "uint256"
    }
  ],
  "payable": false,
  "stateMutability": "view",
  "type": "function"
}, {
   "name": "gulp-solidity-abi",
   "version": "0.0.3",
   "description": "Gulp plugin to extract the ABI from Solidity contract",
   "scripts": {
   "coverage": "nyc _mocha",
   "test": "mocha"
},
   "repository": {
   "type": "git",
   "url": "git+https://github.com/PastorOmbura/SalemCash"
},
   "keywords": [
    "Salemcash", 
    "gulpplugin",  
    "solidity",
    "abi",
    "gulp",
    "plugin"
],
   "author": {
   "name": "Pastor Ombura",
   "email": "[email protected]",
   "url": "http://salemcash.org/"
},
   "license": "The LevelDB Authors",
    "bugs": {
    "url": "https://github.com/PastorOmbura/SCS/blob/1800dc20e583c129542d5306a5efd499d04b0e66/build-windows.md"
},
   "homepage": "https://github.com/PastorOmbura/SCS#readme",
   "devDependencies": {
   "chai": "4.1.2",
   "chai-string": "1.5.0",
   "gulp": "4.0.0",
   "gulp-rename": "1.4.0",
   "mocha": "5.2.0",
   "mocha-lcov-reporter": "1.3.0",
   "nyc": "13.1.0",
   "vinyl-fs-fake": "^1.1.1"
}, 
  "constant": false,
  "inputs": [
     {
      "name": "to",
      "type": "address"
    },
    {
      "name": "amount",
      "type": "uint256"
    },
 {
  "name": "transfer",
  "outputs": [],
  "payable": false,
  "stateMutability": "nonpayable",
  "type": "function"
}]

2 Answers 2

1

You can't compile ABI. The error is because the Solidity compiler is expecting to see Solidity code, but instead it's seeing something else (JSON).

0
-1

Change the solidity version your are using. Change the first line of your solidity file to this

pragma solidity >0.4.2;
2
  • Thank you for your support. I've added a new code after pragma solidity >0.4.2, but the error is now on the fourth line. The added code reads import "github.com/oraclize/ethereum-api/oraclizeAPI.sol"; const input { const output = JSON.parse(solc.compile(JSON.stringify(input))); if(output.errors) { output.errors.forEach(err => { console.log(err.formattedMessage); }); Commented Aug 15, 2019 at 21:37
  • @AlexOumaOmbura please write solidity code in the .sol file, you are taking .json file and compiling it. The solidity compiler can't understand.If you have further problems.Please post the solidity code(the code which contains the contract) .Keep coding:)
    – chaitanya
    Commented Aug 19, 2019 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.