A sample Ethereum blockchain run on Ganache with client calls from Web3j Java
Client: Java Web3j
Server: Local Ethereum Node using Ganache
Install Ganache
Download Ganache GUI tool at https://trufflesuite.com/ganache/
Install Truffle (Development tool for Smart Contracts)
npm install -g truffle
Clone the project
git clone https://github.com/Msrikrishna/ethereum-server-client.git
Go to the project directory
cd ethereum-server-client
Run a local blockchain using Ganache GUI (Create a one click blockchain). This should run a blockchain at http://127.0.0.1:7545
Deploy smart contract to blockchain using truffle
cd HelloWorldSolidity
truffle compile
truffle migrate --network development
Find and update the smart contract blockchain address to Java client
On the Ganache GUI under Contracts, add HelloWorldSolidity/truffle-config.js. This will allow us to
view the contract address on the blockchain
Now update CONTRACT_ADDRESS under Web3jJavaClient/src/main/java/EthereumNodeCaller.java with the address
of the "Counter" contract
To run client side tests, run the following command
cd Web3jJavaClient
mvn test