简体   繁体   中英

Web3j Android java solidity wrapper errors

Trying to use web3j to invoke some functions in a contract. I followed solidity guide and got the .abi and .bin of this contract - https://etherscan.io/address/0x9dda40dabd849bbb087dcbcf0c5223ec5ffa0ad7#code . Then used web3j commandline to make the .java file wrapper, outputted to the correct directory.

Everything works but these lines:

public static final Event FUNDSWITHDRAWN_EVENT = new Event("FundsWithdrawn",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Uint256>() {}));
;

public static final Event FUNDSDEPOSITED_EVENT = new Event("FundsDeposited",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Uint256>() {}));
;

public static final Event SERVERADDED_EVENT = new Event("ServerAdded",
        Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
;

public static final Event SERVERREMOVED_EVENT = new Event("ServerRemoved",
        Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
;

public static final Event GAMESTARTED_EVENT = new Event("GameStarted",
        Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<DynamicArray<Address>>() {}));
;

public static final Event GAMEENDED_EVENT = new Event("GameEnded",
        Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Address>() {}, new TypeReference<Address>() {}, new TypeReference<Address>() {}));
;

throw error:

Event() in Event cannot be applied to:
Expected Parameters:
Actual Arguments:

name:
String
"ServerAdded"  
indexedParameters:
List<TypeReference<?>>
Arrays...new TypeReference<Uint256>() {})  
nonIndexedParameters:
List<TypeReference<?>>

And these two lines:

    public static final Event OWNERSHIPRENOUNCED_EVENT = new Event("OwnershipRenounced",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}));
;

public static final Event OWNERSHIPTRANSFERRED_EVENT = new Event("OwnershipTransferred",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}));
;

Give error: TypeReference( ) in TypeReference cannot be applied to (boolean)

I'm not the contract creator, but it does work correctly in its web3js and metamask implementation. One thing I'm thinking as these events are for serverside, do I even need to include them? (although as you can see they are referenced later) but I'm just wondering if the use of the .bin file forces you to not change things? New to this anyway so any help or direction pointing appreciated, thanks.

It happens to me, seems a problem with the version because the generation of the Java class has syntax errors.

All you can do is try to fix the issue manually: delete the true, and change a bit the code.

public static final Event OWNERSHIPRENOUNCED_EVENT = new Event("OwnershipRenounced",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}),
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM