web3j-maven-plugin icon indicating copy to clipboard operation
web3j-maven-plugin copied to clipboard

No compatible solc release could be found for the file:

Open imdsc opened this issue 4 years ago • 11 comments

image

my solidity file: pragma solidity ^0.8.0;

imdsc avatar Jun 09 '21 06:06 imdsc

Hi, could you give more context?

  • OS: Linux, MacOS, Windows?
  • Plugin version
  • Project POM

Thanks

xaviarias avatar Jun 10 '21 08:06 xaviarias

@xaviarias OS: Windows 10 Home 2004(19041.985) Plugin version: 4.8.2 maven version:Apache Maven 3.8.1

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>

<groupId>org.imdsc</groupId>
<artifactId>blockchain</artifactId>
<version>1.0-SNAPSHOT</version>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.1.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
</properties>

<dependencies>

    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>5.0.0</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>5.0.0</version>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.68</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter -->
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-boot-starter</artifactId>
        <version>3.4.0</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.web3j</groupId>
        <artifactId>core</artifactId>
        <version>4.8.4</version>
    </dependency>

    <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp</artifactId>
        <version>4.9.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.jasypt/jasypt -->
    <dependency>
        <groupId>org.jasypt</groupId>
        <artifactId>jasypt</artifactId>
        <version>1.9.3</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.web3j</groupId>
            <artifactId>web3j-maven-plugin</artifactId>
            <version>4.8.2</version>
            <configuration>
                <packageName>org.blockchain.contract</packageName>
                <soliditySourceFiles>
                    <directory>src/main/resources</directory>
                    <includes>
                        <include>**/*.sol</include>
                    </includes>
                </soliditySourceFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

imdsc avatar Jun 10 '21 09:06 imdsc

I ran into a simillar problem. Go to C:\Users\<User>\.web3j\solc and check the releases.json file. There should be an entry with the desired solidity version. Check if a valid windows_url is provided. For me it wasn't so the plugin was not able to download the needed version as it does not know from where. You can manually download the desired version and place it alongside the other installed versions in C:\Users\<User>\.web3j\solc

Fredi100 avatar Aug 03 '21 15:08 Fredi100

It doesn't work, I'd like to use version 0.8.4 and I downloaded the version from this link: https://github.com/ethereum/solidity/releases/download/v0.8.4/solc-windows.exe and put that file to the directory C:\Users<User>.web3\solc\0.8.4 but still doesn't work with the same result. Do you have any idea?

KamilBemowskiGFT avatar Oct 12 '21 13:10 KamilBemowskiGFT

I ran into a simillar problem.After version 0.7.1, windows_url lacks the corresponding mapping, how can I solve it?

it-honghui avatar Oct 16 '21 13:10 it-honghui

encountering a similar issue, any update on this?

novakorr avatar Dec 07 '21 20:12 novakorr

You just have to mention in your solidity contract this line pragma solidity >=0.7.0 <0.9.0;. This issue can be explained by the solidity version choose for your OS. It works fine on Windows for the 0.7.1 of solidity. You can't use a recent version because of the solc-windows.zip instead of solc-windows.exe which changes the way it works.

N4YC avatar Dec 14 '21 11:12 N4YC

adding pragma solidity >=0.7.0 <0.9.0; in .sol file worked

kpganvir avatar Jun 24 '22 13:06 kpganvir

如果sol版本编译超过0.7.1,就会出现上述问题,原因是因为 web3j会先从本地 C:\Users<User>.web3j\solc\release.json 获取最新的windows可用url,在 maven web3j 4.9.4 版本中,引入了子依赖 web3j-sokt 0.2.1, 在源代码 https://github.com/web3j/web3j-sokt/blob/release/0.2.1/src/main/kotlin/org/web3j/sokt/VersionResolver.kt 中可用看到 从 https://internal.services.web3labs.com/api/solidity/versions/ 下载了 release.json 文件,但是文件中从 0.7.1 之后windows_url一直为 “”, 所以无法找到合适的编译版本solc。 image

在 web3j-sokt 0.2.2 中 https://github.com/web3j/web3j-sokt/blob/release/0.2.2/src/main/kotlin/org/web3j/sokt/VersionResolver.kt ,release.json 的下载地址变更为 https://raw.githubusercontent.com/web3j/web3j-sokt/master/src/main/resources/releases.json ,截至目前文件内的最新可用版本为 solidity 0.8.13

所以我认为解决方案应该是 maven 排除 web3j-sokt 0.2.1, 引入新的 web3j-sokt 0.2.2.

doumuxie avatar Sep 15 '22 03:09 doumuxie

<plugin>
	<groupId>org.web3j</groupId>
	<artifactId>web3j-maven-plugin</artifactId>
	<version>4.9.4</version>
	<dependencies>
		<dependency>
			<groupId>org.web3j</groupId>
			<artifactId>web3j-sokt</artifactId>
			<version>0.2.2</version>
		</dependency>
	</dependencies>
</plugin>

zhang988925 avatar Nov 11 '22 16:11 zhang988925

<plugin>
	<groupId>org.web3j</groupId>
	<artifactId>web3j-maven-plugin</artifactId>
	<version>4.9.4</version>
	<dependencies>
		<dependency>
			<groupId>org.web3j</groupId>
			<artifactId>web3j-sokt</artifactId>
			<version>0.2.2</version>
		</dependency>
	</dependencies>
</plugin>

我配置了 web3j-sokt 0.2.2. 但是不生效。请问有遇到这样的情况吗?

bububear avatar Apr 18 '23 07:04 bububear

<plugin>
	<groupId>org.web3j</groupId>
	<artifactId>web3j-maven-plugin</artifactId>
	<version>4.9.4</version>
	<dependencies>
		<dependency>
			<groupId>org.web3j</groupId>
			<artifactId>web3j-sokt</artifactId>
			<version>0.2.2</version>
		</dependency>
	</dependencies>
</plugin>

我配置了 web3j-sokt 0.2.2. 但是不生效。请问有遇到这样的情况吗?

已解决; 解决方案供参考:

  1. 下载插件源码,解压缩,导入IDEA ,修改 web3j-sokt 依赖版本。
  2. 执行 mvn clean install

最后刷新依赖项目maven仓库,即可。

bububear avatar Apr 19 '23 06:04 bububear