I want to compile a smart contract (solidity code) in Java. Currently I am using the web3j library. When I run the method web3j.ethCompileSolidity(contract)
I'm getting the following error: The method eth_compileSolidity does not exist/is not available
I created the following code to compile a smart contract at runtime:
EthCompileSolidity ethCompileSolidity = web3j.ethCompileSolidity(contract).send();
Map<String, EthCompileSolidity.Code> compiledSolidity = ethCompileSolidity.getCompiledSolidity();
The method web3j.ethGetCompilers()
doesn't work either. It's returning the following error: The method eth_compileSolidity does not exist/is not available
On Github I read something about deprecated eth_compile methods.
Is there still a way to compile smart contracts in Java using this library?
solc
with your application and then shell to it to compile. Another alternative (if you support node/javascript) to ship the javascript packagesolc
, but it is less performant.