0

I believe I have everything set up correctly as other Web3j and solc commands have been working fine. However, Following the instructions here: https://docs.web3j.io/smart_contracts.html#deploying-and-interacting-with-smart-contracts to create the autogenerated java wrapper has not been working, when I run the last command it shows me the syntax instead of creating the java code. I ommitted the web3j picture text.

>$ ls
>registrar  registrar.sol

>$ solc registrar.sol --bin --abi --optimize -o ./registrar/

>$ ls registrar  
Registrar_Contract.abi  Registrar_Contract.bin

>$ web3j solidity generate ./registrar/Registrar_Contract.bin ./registrar/Registrar_Contract.abi -o ./

and I get this response instead of it generating file:

solidity generate <input binary file>.bin <input abi file>.abi [-p|--package  <base package name>] -o|--output <destination base directory>

I have tested this a decent amount and have not had any success. Any help would be greatly appreciated.

P.S I am on Mac OS Sierra and used homebrew to install everything, the only command that didn't work during installation was "brew linkapps solidity" from http://solidity.readthedocs.io/en/develop/installing-solidity.html#binary-packages but I continued because solidity commands were working anyways.

Adam Kipnis
  • 10,175
  • 10
  • 35
  • 48
Cameron
  • 1
  • 1
  • You need to have 6 arguments in order for it to work. The mentioning of -p being optional in the syntax is incorrect. – Cameron Jun 21 '17 at 17:15
  • Thanks - this has been fixed https://github.com/web3j/web3j/commit/d949cc81358dbaf45639dd8e93a836509cb8e235 – Conor Svensson Jul 23 '17 at 20:18
  • To avoid this kind of issues I would recommend using the Solidity plugin, in case you are using Gradle, at https://github.com/web3j/solidity-gradle-plugin. It will compile automatically all .sol files in the Solidity source sets like is done for Java or Scala. – Xavier Arias Jan 18 '19 at 10:50

3 Answers3

0

You are missing arguments, try the command like this:

web3j solidity generate /registrar/Registrar_Contract.bin ./registrar/Registrar_Contract.abi -o /path/to/yourSrc/main/java -p your.application.id
Alex Bean
  • 493
  • 7
  • 19
0

Use the below command for fix

web3j solidity generate -b Practice.bin  -a Practice.abi -o D:\Solidity\sample-project-gradle-master\src\main\java  -p org.web3j.sample
dbc
  • 104,963
  • 20
  • 228
  • 340
Niraj
  • 31
  • 4
0

Use below command :-

web3j generate solidity -a ./registrar/Registrar_Contract.abi -b ./registrar/Registrar_Contract.bin -o /path/to/yourSrc/main/java -p package.name
Chiya
  • 1
  • 1
  • Have error like ```Unknown options: '-a', 'swapvalue.abi', '-b', 'swapvalue.bytecode', '-o', '.', '-p', 'ru.home.swap'``` for command ```web3j solidity generate -a swapvalue.abi -b swapvalue.bytecode -o . -p ru.home.swap``` – Joe Dow Sep 22 '22 at 10:26