Sample project to illustrate connecting Java to Ethereum
First install Ganache
npm install -g ganache-cli
Run ganache-cli. The account information should display and the connection details should be displayed.
Or install Ganache
https://truffleframework.com/ganache/
Default connection is https://localhost:8545
Now add web3j as a dependency
<dependency>
<groupId>org.web3j</groupId>
<artifactId>web3j-spring-boot-starter</artifactId>
<version>1.5.0</version>
</dependency>
Running the application and navigating to clientversion should now display client version details
Go to remix. Paste the following into the editor.
Follow the guide for more details on how to deploy a smart contract.
Navigate to
src/main/solidity
and run the following command
solcjs counter.sol --bin --abi --optimize -o target/
You should now have two files in the target directory - counter_sol_Counter.abi
and counter_sol_Counter.bin
After having installed web3j command line tools
Then run the wrapper generation command
web3j solidity generate /path/to/counter_sol_Counter.bin /path/to/counter_sol_Counter.abi -o /path/to/src/main/java -p com.naughtyzombie.eth.springeth.wrapper