web3j icon indicating copy to clipboard operation
web3j copied to clipboard

[ERROR] Failed to get solidity version from server

Open creazyCode opened this issue 1 year ago • 3 comments

An error occurred when generating the solidity corresponding java wrapper class through web3j-maven-plugin: [ERROR] Failed to get solidity version from server

running cmd : mvn web3j:generate-sources

web3j

Contract

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract MyContract {
    uint256 public value;

    function setValue(uint256 newValue) public {
        value = newValue;
    }

    function getValue() public view returns (uint256) {
        return value;
    }
}

Pom.xml

<plugin>
                <groupId>org.web3j</groupId>
                <artifactId>web3j-maven-plugin</artifactId>
                <version>4.8.7</version>
                <configuration>
                    <packageName>org.example.com</packageName>
                    <sourceDestination>src/main/java/generated</sourceDestination>
                    <nativeJavaType>true</nativeJavaType>
                    <outputFormat>java,bin</outputFormat>
                    <soliditySourceFiles>
                        <directory>src/main/resources</directory>
                        <includes>
                            <include>**/*.sol</include>
                        </includes>
                    </soliditySourceFiles>
                    <outputDirectory>
                        <java>src/java/generated</java>
                        <bin>src/bin/generated</bin>
                        <abi>src/abi/generated</abi>
                    </outputDirectory>
                </configuration>
            </plugin>

creazyCode avatar Jun 08 '24 03:06 creazyCode

could you provide your whole pom? Maybe you're missing something

Also, yould you try to use a newer version of web3j core? I just tried 4.10.3 and it worked fine

Besides that I would adjust the java output directory to match a valid package, at least add in the "main" /src/main/java/generated

Julius278 avatar Jul 05 '24 15:07 Julius278

@creazyCode additionally you could enhance your pom by generating the Java wrapper on every mvn build like @fcorneli did it here: https://github.com/hyperledger/web3j-maven-plugin/issues/14#issuecomment-368566575

afterwards you can adjust your solidity contracts as you wish and build your application without regenerating the wrapper classes alone

Julius278 avatar Jul 06 '24 11:07 Julius278

@creazyCode Try this: Reduce the solidity version from 0.8.20 to 0.8.16

alok2424 avatar Jul 20 '24 12:07 alok2424