0

Running E:\projects\Greeter-Contract-master\contracts>solcjs --abi Greeter.sol gives:

Greeter.sol:3:1: ParserError:
Source "contracts/Mortal.sol" not found: File import callback not supported
import "contracts/Mortal.sol";
^----------------------------^

Greeter.sol:

pragma solidity ^0.6.4;

import "contracts/Mortal.sol";

contract Greeter is Mortal {
    string greeting;
   constructor( string memory _greeting) public {
        greeting = _greeting;
    }

    function changeGreeting(  string memory _greeting) public {
        greeting = _greeting;
    }

    function greet() public view returns (string memory) {
        return greeting;
    }
}

Mortal.sol:

pragma solidity ^0.6.4;

contract Mortal {
    /* Define variable owner of the type address */
    address payable owner;

    /* This function is executed at initialization and sets the owner of the contract */
    constructor() public { owner = msg.sender; }

    /* Function to recover the funds on the contract */
    function kill() public {
        if (msg.sender == owner) 
            selfdestruct(owner); 
    }
}
4
  • What are you trying to accomplish? Trying to deploy a contract? Mar 23, 2020 at 12:01
  • @balajipachai: solcjs --abi Greeter.sol - compile a contract (obviously). Mar 23, 2020 at 12:33
  • i wanted to create bin and abi files for the contract . im doing the application in android studio
    – aki abi
    Mar 23, 2020 at 15:09
  • Try deleting the Build Artifacts (.json files) and run the command again. Jul 12, 2021 at 12:47

1 Answer 1

1

There are essentially two different problems in import "contracts/Mortal.sol":

  1. For a local files, the input path name must start with ./
  2. Since your files reside under folder contracts, you should not add it to the relative path

So in short, change this:

import "contracts/Mortal.sol";

To this:

import "./Mortal.sol";
3
  • I tried that it didnt work
    – aki abi
    Mar 23, 2020 at 15:08
  • E:\projects\Greeter-Contract-master\contracts>solcjs --abi Greeter.sol Greeter.sol:3:1: ParserError: Source "Mortal.sol" not found: File import callback not supported import "./Mortal.sol"; ^--------------------^
    – aki abi
    Mar 23, 2020 at 15:11
  • Try deleting the Build Artifacts (.json files) and run the command again. Jul 12, 2021 at 12:47

Your Answer

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

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