In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
What this article shares to you is about how to build the web3j ethernet development environment. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Web3j is a lightweight ethernet square Java development kit that can be used in desktop, server or mobile applications to access ethernet block chain smart contracts. The web3j development environment includes nodes for development and testing and the web3j development stack. This article describes how to build a web3j development environment on your own machine.
The construction of the web3j development environment is divided into the following steps:
Install the ethernet development node: Ganache
Install the Java development kit: OpenJDK
Install the Java project build tool: Gradle
Install smart contract command line tools: Solc and Web3j
Web3j application development and debugging: hello web3j
1. Install the ethernet square development node
Web3j accesses the node block chain through the standard Ethernet Square RPC interface, so it can dock with various node software such as geth or parity. However, usually in the development process, we use the development node Ganache, which does not need to synchronize block data from the network, so it is very suitable for rapid verification in the development process.
Install ganache using npm:
~ $npm install-g ganache-cli
After installation, you can start the node by executing it directly:
~ $ganache-cli2. Install JDK
You can install jdk for either openjdk or oracle. Under ubuntu, you can install directly using apt:
~ $sudo apt-get install openjdk-8-jdk
After the installation is complete, verify that the installation is successful using the following command:
~ $java-version3. Install Gradle
Web3j supports maven or gradle as a project build tool. This paper takes gradle as an example to illustrate.
Download the latest version of the precompiled package from the gradle official website, then decompress and configure the environment variables:
~ $wget https://gradle.org/next-steps/?version=5.1&format=bin~$ mkdir / opt/gradle~$ unzip-d / opt/gradle gradle-5.1-bin.zip~$ echo PATH=/opt/gradle/bin:$PATH > > .bashrc ~ $source .bashrc
Verify the installation:
~ $gradle-version4. Install intelligent contract development tools
The development tools for smart contracts include the following two command-line software:
Solc:solidity Intelligent contract Compiler, official download
Web3j:web3j command line tool, official download
You can run solc directly after downloading, such as verifying the installation:
~ $solc
After downloading the web3j command line tool, decompress it with unzip, and then execute the web3j in it. For example:
~ $web3j
These two tools are mainly used for the processing of solidity smart contracts, which we have ignored for the time being.
5. Hello,web3j
Now we can create a directory, as well as App.java and build.gradle files, to implement the hello world application of web3j:
~ $mkdir hubwiz & & cd hubwiz~/hubwiz$ touch App.java build.gradle
Write the following App.java:
Package com.hubwiz.demo;import org.web3j.protocol.Web3j;import org.web3j.protocol.http.HttpService;import org.web3j.protocol.core.Request;import org.web3j.protocol.core.methods.request.*;import org.web3j.protocol.core.methods.response.*;public class App {public static void main (String [] args) throws Exception {Web3j web3j = Web3j.build (new HttpService ("http://localhost:8545")); Request)
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.