Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

SolidityFunctionWrapperGenerator creates compile-time error for zero-argument constructor #11

Closed
MaxBinnewies opened this issue Nov 10, 2016 · 2 comments

Comments

@MaxBinnewies
Copy link

Hi Conor,

The following slightly modified example contract:

pragma solidity ^0.4.0;

contract SimpleStorage {
    uint storedData;
    
    function SimpleStorage() {
        storedData = 5;
    }

    function set(uint x) {
        storedData = x;
    }

    function get() constant returns (uint retVal) {
        return storedData;
    }
}

creates this Java code:

...
    public static Future<SimpleStorage> deploy(Web3j web3j, Credentials credentials, BigInteger initialValue) {
        return deployAsync(SimpleStorage.class, web3j, credentials, BINARY, encodedConstructor, initialValue);
    }
...

encodedConstructor cannot be resolved to a variable. This is due to the zero-argument constructor. When I add a fake(as in not used anywhere) uint argument to the constructor everything is fine. I do believe zero-argument constructors are allowed in Solidity, though.
I used the solidity web compiler to create .bin and .abi and am using web3j 1.0.3. I really like that SolidityFunctionWrapperGenerator now logs what its doing :-)

Best regards,
Max

@conor10
Copy link
Contributor

conor10 commented Nov 10, 2016

This should be fixed by release v1.0.4.
Please reopen this ticket if not.

@conor10 conor10 closed this as completed Nov 10, 2016
@conor10
Copy link
Contributor

conor10 commented Nov 11, 2016

FYI - there are now unit tests for the code generator using a number of different compiled smart contracts.

https://github.com/web3j/web3j/blob/master/src/test/java/org/web3j/codegen/SolidityFunctionWrapperGeneratorTest.java

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants