0

I have developed one app in ethereum which contains smart contract, js and html (for web app).

I have developed it using truffle, ganache and solidity. I am accessing it in html and call the functions of smart contract using web3 library inside my js code.

Now, I want to use this in Java, so if in java if I write my html code inside jsp, so what will be the flow for calling smart contract and back end js (which is calling smart contract functions).

Should I need any API or I need to make any restful service ? What can be the flow for using it in Java ?

1

You can use java to interact with your smart contract using web3j.

https://web3j.readthedocs.io/en/latest/smart_contracts.html

You can still use solidity and truffle for the smart contract development and use the web3j command:

$ web3j truffle generate [--javaTypes|--solidityTypes] /path/to/.json -o /path/to/src/main/java -p com.your.organisation.name

(the .json file is in your build/contracts folder in truffle)

to create a java wrapper of your contract. Using web3j and this generated java file you can interact with the smart contract from java.

check out this post from the web3j creator about using truffle/solidity and java

https://medium.com/blk-io/ens-and-truffle-support-in-web3j-3-1-0-release-e71c36701016

In summary - the library web3j is your answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.