Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用不同的版本编译合约表现不一致 #34

Open
13813385093 opened this issue Oct 18, 2023 · 2 comments
Open

使用不同的版本编译合约表现不一致 #34

13813385093 opened this issue Oct 18, 2023 · 2 comments
Labels

Comments

@13813385093
Copy link

我使用v0.4.25.0编译HelloWorld.sol可以编译通过,但是当我切换成v0.6.10.0或0.8.11.1编译同样的合约的时候,就报错了。错误提示:"No input files given. If you wish to use the standard input please specify "-" explicitly."。请问应该如何解决。

@kyonRay
Copy link
Member

kyonRay commented Oct 18, 2023

请提供 0.4.25调用编译时使用的参数。

@kyonRay
Copy link
Member

kyonRay commented Oct 18, 2023

在使用SolidityCompiler.compile(byte[] source, boolean sm, boolean combinedJson, Option... options) 接口时,当solc版本高于0.5的时候,要带上 “-” 的option,和注释描述的一样,在0.5的solc之后对于stdin都需要加上 '-' 的参数。

使用释例:

File file = new File(url.getFile());
byte[] bytes = new byte[(int) file.length()];
try (FileInputStream fileInputStream = new FileInputStream(file)) {
    if (fileInputStream.read(bytes) != bytes.length) {
        throw new IOException("incomplete reading of file: " + file);
    }
}
SolidityCompiler.Option option = new SolidityCompiler.CustomOption("", "-");
Result compile = SolidityCompiler.compile(bytes, false, true, ABI, BIN, METADATA,option);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants