[Ethereum] Why is the web3j wrapper failing to generate

solcsolidityweb3j

I've created a smart contract in solidity which I've compiled with solc into a .bin & a .abi file. However, when I run the generator on the .abi and .bin files it returns a JSONParseException citing an unexpected character.
io
This is my smart contract:

    pragma solidity ^0.4.9;

    contract Contract {

      address public creator;


      event Log(uint256 id);


      function Contract() {
        creator = msg.sender;
      }

      function kill() {
        selfdestruct(creator);
      }

      function add(uint256 id) {
        Log(id);
    }
   }

Best Answer

Just tried your contract. It seems correct and I was able to create a wrapper successfully. Here is what I did:

Put a ContractName.sol file wilth you source into d:\tmp> then in that directory executed the following from the command line:

d:\tmp>solc ContractName.sol --bin --abi --optimize -o .

Which generated .abi and .sol files in that same directory. Then:

d:\tmp>web3j solidity generate --binFile=Contract.bin --abiFile=Contract.abi -o . -p org.your.package.name

Generated me a wrapper under the folloring directoty (according to the package structure provided in command line):

d:\tmp\org\your\package\name\Contract.java

Everything seems fine, you should be able to create yours. I installed colc and web3j tools like described here: solc, web3j

Related Topic