I've been exploring web3j and got the credentials working so I'm able to send transactions from an ethereum address. Now I want to send a transaction to an already existing smart contract and use a function in the smart contract. I've been trying to find a way to do this in the documentation and online but haven't had any luck with it.

How to sent a transaction to an already existing smart contract address and use a function / method in the smart contract?


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


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


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.