I completely stuck on modules importing into Solidity contract. Here is my files/directory layout:
.
|-> contracts/
|-> contract1.sol
|-> contract2.sol
File contract1.sol
contains only pragma
and import
statements like:
pragma solidity ^0.4.0;
import "./contract2" as c2;
File contract2.sol
conntains only pragma
statement:
pragma solidity ^0.4.0;
Then I open node
shell and input following code:
> solc = require('solc')
> solc.compile(fs.readFileSync('contracts/contract1.sol').toString())
{ contracts: {},
errors: [ ':3:1: ParserError: Source "contract2" not found: File not supplied initially.\nimport "./contract2" as c2;\n^-------------------------^\n' ],
sourceList: [ '' ],
sources: {} }
I already tried to:
- specify full path in
contract1.sol
- add extension
.sol
- remove
./contracts/
prefix and run commands insidecontracts
folder.
Nothing works. Accordingly to this article begin import with dot and slash is enough but, damn, no!
How to include one sol
file into another?
Node version is 8.1.13, solcjs version is 0.4.13+commit.0fb4cb1a.Emscripten.clang