运行E:\projects\Greeter-Contract-master\contracts>solcjs --abi Greeter.sol提供:
Greeter.sol:3:1: ParserError:
Source "contracts/Mortal.sol" not found: File import callback not supported
import "contracts/Mortal.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;
}
}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);
}
}发布于 2020-03-23 12:32:09
在import "contracts/Mortal.sol"中本质上有两个不同的问题:
./开头。contracts下,所以不应该将其添加到相对路径中。因此,简单地说,更改一下:
import "contracts/Mortal.sol";import "./Mortal.sol";https://ethereum.stackexchange.com/questions/80793
复制相似问题