Support imports in solcjs CLI
See original GitHub issueGiven the following directory structure:
contracts/
Source.sol
Imported.sol
Where Source.sol
:
pragma solidity ^0.4.0;
import './Imported.sol';
contract Source {
}
Running the following command:
solcjs --optimize --bin contracts/Source.sol
Based on the docs, I would expect the compiler to resolve the import but instead it throws:
contracts/Source.sol:3:1: Error: Source "contracts/Imported.sol" not found: File not supplied initially.
import './Imported.sol';
^---------------------^
If I include Imported.sol
as a source file it will compile without error:
solcjs --optimize --bin contracts/Source.sol contracts/Imported.sol
Could you clarify my understanding here or is this a bug? Thanks! 🙃
Issue Analytics
- State:
- Created 6 years ago
- Comments:20 (4 by maintainers)
Top Results From Across the Web
Using the Compiler — Solidity 0.8.17 documentation
Using solc --help provides you with an explanation of all options. ... The commandline compiler will automatically read imported files from the filesystem, ......
Read more >solc-js - npm
To see all the supported features, execute: solcjs --help. Note: this commandline interface is not compatible with solc provided by the ...
Read more >Solidity compiler command-line utility (solcjs) various problems
First of all, I need to supply in the command-line all the files that are imported by the primary file. Otherwise I get...
Read more >File import callback not supported on MacOS with solcjs
Hi @spizzy,. I am sorry you are having this issue. I believe we only saw this previously with the OpenZeppelin CLI.
Read more >Web3J | Source "@openzeppelin/contracts/token/ERC721 ...
Related. 1 · I need help to build ERC-721 contract with solidity version 5.0 or higher · 1 · Error compiling OpenZeppelin imported...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
so writing import is just a fun activity that solc dont understand ?
I solved this by doing the below as things have been improved as of 0.2.1:
I then read in compiled.json later in a .js file using web3 to use it via a browser using browserify:
Hope this is helpful to someone else.