Closed aleksvujic closed 2 years ago
I encountered same issue
@YuboLong Did you manage to solve it?
I encountered same issue
I encountered same issue
use 4.84 solve
I encountered same issue
use 4.84 solve
But the CLI does not have this version.
Hello @aleksvujic , I have been researching on this topic, it seems that the latest version of web3j has support for struct to some extent, that is, it is still not possible to return lists of structures as you have in the example that you show.
Furthermore, structures with addresses are not supported at this time either.
https://github.com/web3j/web3j/issues/1361#issuecomment-835760015
I encountered same issue
use 4.84 solve
But the CLI does not have this version.
He's talking about web3j version
I have five structs used in different public functions in my solidity program. None of them contains address. web3j created static Java classes for just two of them. So I am getting errors for the other three. I could not figure out the pattern of usage of these structs in the solidity program for which web3j failed to generate the java classes. Is this a known issue? If needed I may be able to create a reproducible test case for it.
1 year Later. I am also getting this issue
I have 2 structs in my code.
`struct EmpExceStruct{ address addr; string name; string age; string sex; uint timestamp; uint calories; string exerciseType; string extra; } struct Employee { bool created; string name; string age; string sex; uint256 exerciseCount; mapping(uint => Exercise) et; uint etSize; // TODO connect to address of user
}
`
after generaing them with web3j, both structs have been brought in as Classes that do not exist. heres one of the functions that have been created in Java
` public RemoteFunctionCall getUserExcersises() {
final Function function = new Function(FUNC_GETUSEREXCERSISES,
Arrays.
(function,
new Callable
() {
@Override
@SuppressWarnings("unchecked")
public List call() throws Exception {
List
`
here the exact script i used to generate the abi and bin. its includes the solc version since I use solc-select.
~/.solc-select/artifacts/solc-0.8.13 Health.sol --bin --abi --optimize -o ./generated/
EDIT: sorry its formatted so bad, I thought the add code button will format it nicely for me. Ah well. let me know if you need more information or indeed better formatted code. Im just a grad school student trying his best to finish a project he doesnt necessarily enjoy working on, lol.
Okay I found a workaround That im only now implementing. I think it has to do with how solidity never used to be able to return structs. Im gonna use the workaround found in this video and I am assuming it will solve the issue. Essentially it seems the wrapper generator isnt hype to the newer solidity functionality of allowing the return of structs. I hope they sort that out soon but whatever.
https://www.youtube.com/watch?v=QGjshWJjPPI
I figured this is the issue as the only problems im getting have to do with getters but not setters
Was fixed in PR. https://github.com/web3j/web3j/pull/1673
I'm still facing this issue, struct are not generate by web3j.
I have problems with generating contract wrapper code when smart contract uses
ABIEncoderV2
and structs. I am usingweb3j CLI v1.4.1
. I have the following demo smart contract:When I compile it with
Solidity 0.6.12+commit.27d51765
, it generates the following ABI:When I run
web3j generate solidity -a MyContract.json -o ".\org\company" -p mypackage
it generates the following Java file:However, it reports an error that
MyStruct
can't be resolved to a type. I read here that it should support structs. Quote:From Web3j version 4.6.x onwards, the generator supports ABIv2 for contract compiled with Solidity compiler version 0.6.x. This means that you can have structs as input/output/event parameters in your smart contract.
Why is it not working?