Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create java Class based on solidity Intelligent contract File

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to create java class based on solidity intelligent contract file". In daily operation, I believe many people have doubts about how to create java class based on solidity intelligent contract file. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "how to create java class based on solidity intelligent contract file". Next, please follow the editor to study!

Usage

The basic configuration of the plug-in will get the solidity file from src/main/resources and generate the java class into the src/main/java folder.

Org.web3j web3j-maven-plugin 0.3.7

Run the plug-in to execute the target generate-sources:

Mvn web3j:generate-sources configuration

There are several variables to select the solidity source file, define the source destination path, or change the package name.

The configuration of outputDirectory takes precedence over sourceDestination.

Introduction

Create a standard java maven project. Add the following configuration to the pom.xml file:

Org.web3j web3j-maven-plugin 0.3.7 com.zuehlke.blockchain.model src/main/java/generated true java,bin src/main/resources * * / * .sol src/java/generated src/bin/generated src/abi/generated

Add your Solidity contract file to the folder src/main/resources. Make sure the solidity file ends with .sol.

Start the build process:

> mvn web3j:generate-sources [INFO]-- web3j-maven-plugin:0.1.2:generate-sources (default-cli) @ hotel-showcase-- [INFO] process' HotelShowCaseProxy.sol' [INFO] Built Class for contract 'HotelShowCaseProxy' [INFO] Built Class for contract' HotelShowCaseV2' [INFO] Built Class for contract 'Owned' [INFO]-- -[INFO] BUILD SUCCESS [INFO]- -[INFO] Total time: 4.681 s [INFO] Finished at: 2017-06-13T07:07:04+02:00 [INFO] Final Memory: 14M/187M [INFO]-Process finished with exit code 0

You can find the generated java class in the directory src/main/java/generated/.

The next step is to interact with smart contracts. Please refer to the Chinese version of the web3j home page for smart contract deployment and interaction.

For multi-module project configuration, see @ fcorneli's post. In short: to get the generated java source file, you need a build-helper-maven-plugin configuration. In addition, the ${basedir} prefix is required in a multi-module project.

Amway 2 java ethernet and Bitcoin blockchain-related interactive online programming tutorials:

The java ethernet development tutorial is mainly for java and android programmers to conduct a detailed web3j explanation of blockchain ethernet development.

Java Bitcoin Development course, for beginners, covers the core concepts of Bitcoin, such as blockchain storage, decentralized consensus mechanisms, keys and scripts, transactions and UTXO, etc., as well as how to integrate Bitcoin support functions into Java code, such as creating addresses, managing wallets, constructing naked transactions, etc., is a rare bitcoin development course for Java engineers.

At this point, the study on "how to create java classes based on solidity intelligent contract files" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report