在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):web3j/web3j-maven-plugin开源软件地址(OpenSource Url):https://github.com/web3j/web3j-maven-plugin开源编程语言(OpenSource Language):Java 92.6%开源软件介绍(OpenSource Introduction):web3j-maven-pluginweb3j maven plugin is used to create java classes based on the solidity contract files. UsageThe base configuration for the plugin will take the solidity files from <build>
<plugins>
<plugin>
<groupId>org.web3j</groupId>
<artifactId>web3j-maven-plugin</artifactId>
<version>4.9.4</version>
<configuration>
<soliditySourceFiles/>
</configuration>
</plugin>
</plugins>
</build> to run the plugin execute the goal mvn web3j:generate-sources ConfigurationThe are several variable to select the solidity source files, define a source destination path or change the package name.
Configuration of Getting StartedCreate a standard java maven project. Add following <plugin>
<groupId>org.web3j</groupId>
<artifactId>web3j-maven-plugin</artifactId>
<version>4.8.1</version>
<configuration>
<packageName>com.zuehlke.blockchain.model</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>
<abiSourceFiles>
<directory>src/main/resources</directory>
<includes>
<include>**/*.json</include>
</includes>
</abiSourceFiles>
<outputDirectory>
<java>src/java/generated</java>
<bin>src/bin/generated</bin>
<abi>src/abi/generated</abi>
</outputDirectory>
<contract>
<includes>
<include>greeter</include>
</includes>
<excludes>
<exclude>mortal</exclude>
</excludes>
</contract>
<pathPrefixes>
<pathPrefix>dep=../dependencies</pathPrefix>
</pathPrefixes>
</configuration>
</plugin> Add your solidity contract files into the folder Start the generating process:
You find the generated java classes inside the directory Next step is to interact with the smart contract. See for that deploying and interacting with smart contracts in the official web3j documentation. For a multi module project configuration see following post
from @fcorneli. In short: For pick up the generated java source
files, you need the build-helper-maven-plugin configuration. Also, Changelog4.8.1
4.6.5
4.5.11
Changelog4.2.0
4.1.0
4.0.3
0.3.7
0.3.5
0.3.1
0.3.0
0.2.0
0.1.4
0.1.3
0.1.2
0.1.1
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论